nimos100's Forum Posts

  • Oh well it didn't work, it just seemed like it.

    nimos100 - checking 500 objects against 500 others is 250,000 collision checks per tick. That's a lot. There are ways you can cycle through them and only check them in batches, and a lot of what's going on in that video with the moving objects doesn't actually require collisions at all.

    Yeah that's the same amount i got to, but i cant seem to figure out how to do that, because it my eyes, it doesn't really make sense to check for collision if the objects are not even close to each other.

    But i tried adding something that would turn collision on/off, based on distance but that doesn't work well, it completely kills it, well i can make it run with 500 objects and get around 38-45 fps, but its not smooth, but look kind of funny as i have made them change color when they turn collision on/off :D

    Im not sure how they do it in that game. But since each of the objects stop when they collide with each other, there must be something that check if that's the case or not. So it would require a lot of tests, regardless of it being "true" collision detection or not.

  • Im not really sure if what you say is correct.

    If i make 500 objects, and tell it to test for collision against the same object. I get 18-19 fps.

    If i make 500 of another type, and test against them i get the same fps.

    So could indicate that it doesn't make any difference, and it does the same amount of tests.

    But my point was, that if you take that game i linked earlier, there must be something in the way they do, or handles collision detection that are different than how C2 handles it. As there are no problems in that game to have several 1000 objects interacting with each other. If its because they use some type of range to determine whether an object should do collision check with another i don't know. But I can place 500 objects on the right side of the screen, and make sure that they would never interact or even come close to the other objects, and still fps would suffer. So my guess is that "On collision" simply take one object, and test against every object that its told, regardless of the other object is even relevant for testing or not. And therefore it doesn't matter whether you test 500 objects of the same type against each other, if its different type, if these objects are even close to each other and so on.

    ADDED***

    Ok fooled around a bit and optimized it a little, so it can now run 5000 objects with around 30 fps, so it was quite and improvement :D

    And can run 2500 objects with 60 fps.

    But it seems that its correct that it just does a straight up comparison when doing collision testing.

  • I agree with you to some extend. However a lot of performance hit also comes from C2.

    I made a small program here, that basically doesn't do anything except moving some small sprites around. You get a massive performance hit.

    Which is caused by "on collision", there are added nothing to it. And you are not able to change the way this event works as its part of C2. Now in the program I have added that it should only trigger this if the speed of the sprite is above 0. Which ofc shouldn't make any difference to whether it should check for collisions or not, so removing it, makes no difference. And since the event doesn't actually do anything, it doesn't matter anyway in this test.

    But that you cant configure when collision detects should take place, you actually get a performance hit, even though non of the objects starts out moving. As you increase the speed of the objects, it just completely kills it.

    On my computer the moment I spawn 350 objects, the fps drop between 20-25 instantly. Even though these objects do absolutely nothing, except being on the screen.

    Increase it to 650 objects, still doing nothing and it drops by 49-50.

    So even though the computer also plays a part, the C2 engine or what to call it, will be the first thing to kill performance. Im pretty sure my computer can handle rendering 650 sprites :D

    In order to improve performance when handling lost of objects, you would need to be able to control when and under what conditions for instant collision testing should even take place.

    Whether you could do that with some distance calculations, and avoid the one that are build into C2 I don't know.

    Here is the capx if you want to try it yourself:

    Performance test

  • I don't know that much about the C2 engine, but I do think that it have limits, or the program might, not sure. But it doesn't seem to handle lots of objects very well.

    But if you play a game like Factorio and the amount of objects it can handle at the same time, its insane. If you don't know it, here is a video to give you an idea.

    Subscribe to Construct videos now

    Basically the game is about building a factory sort of thing, and you produce and extract all kind of different resources or products, which you can then transport around. Each of the small things that you see move around are either a product or resource. And you then have these "arms" that can pick them up and move them around, insert them to machines etc. My point is there are really a lot of things going on, and checks that needs to be made, collisions and so on all the time. Making a game of this kind in C2 I cant see how could be possible, simply because the amount of objects would completely kill it.

    But as I started by saying I don't know that much about the C2 engine, but it doesn't seem very hard to kill it you want. Even if you don't try to on purpose. But it would be very nice if it could do something like this. :D

    Ps. The game is still under construction, but seems very promising.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It should just be a sprite, that you place outside the screen on another layout.

    Alternative, you can also just add another event sheet and include it in the current one, and just add the high score and current score as global variables there.

  • Not 100% sure I understand exactly what you want to do. But if I got it correct, the player have to survive for as long as possible, and the time that he survived will be the score, next game, this score should be the high score if it was higher than the former high score and so on?

    If that's the case, you need to make sure that each time you start a new game, you don't do a reset layout that reset the high score to 0. This can happen if the global variable are in the same event sheet as the game, so when you reset it, it will be whatever it was when the layout was started the first time.

    A simple way to solve this, would be to just make a object where you store the high score, and the current score that the player just made. And make the object global.

    Then after each game, you just check these values against each other, and write the high score from this object.

  • Sure, however my visit to the forum changes quite a lot, sometimes I check it a lot and other times not for several weeks so if I don't answer you know why :D

  • Here is an explanation :)

    1. When you press the button, it will reset the 3 variables that holds the photos. To make sure that they don't hold photos already. Also I destroy all PhotoPlaceholder objects, as I create 3 new ones that should hold the photos that are displayed on the screen. This is to clean up so there are not several objects overlapping each other.

    2. Since I just destroyed all PlaceHolders I need something to copy the frames from, so I make 1 PlaceHolder to copy from.

    3. Then I select how many photos should be displayed, 1 to 3, for each of these, it will check to see if there are already a photo stored in the photo variable if that's the case it will check the next variable and so on.

    4. Then it check each variable to see if there are an photo stored. If that's the case it will create an image on the screen. And it will do that for each variable.

  • Here is an example, I just made it so when you press the button it will show up to 3 random photos on the screen, the photos are chosen from a list of 5 photos, but you can add as many images as you want.

    CAPX:

    Choose random photo

  • I have looked at it, and you almost had it working :)

    To fix it, you have to move the ResultText in the "Platform on landed" to the bottom.

    Just add an empty one below "prevFloor >= Flooring.floor"

    Then change the ResultText to this:

    "Level " & Flooring.Floor & " reached"

    Then it will correctly write which level the player have reached.

  • No worries trust me I have had my share of problems and still do, think that's the same for everyone :D

    A way you could do it, is to make a sprite that hold the images that you would like to randomly choose from, so each frame holds a photo.

    This have some benefits to making them as separate sprites, its easy to randomly select between them, and you can add as many photos to it as you please very easy, without having to add any new code.

    However if you plan on using animations, you shouldn't do it like this.

    Since you know that you at max can get 5 photos to show and to keep it simple, you can just add 5 variables preferable to the object that handles them. If you don't have an object but just use globals you can add them there.

    However just a tip, sometimes it can be a good idea to make a placeholder object in form of a 32x32 sprite which only purpose is just to keep track of something for you, instead of adding everything as globals. As the list of variables can get very long, and you cant use Booleans with globals. So having some small sprites outside the layout to help you keep track of things, wont hurt performance, but will make things a lot easier.

    Anyway :)

    These 5 variable you just add the frame number of the photos that should be shown.

    You can do that by randomly selecting a frame number:

    Assume that the object holding you photos are called Photoholder.

    Set Photo_1 = int(random(0, Photoholder.FrameCount - 1)

    Set Photo_2 = int(random(0, Photoholder.FrameCount - 1)

    Set Photo_3 = int(random(0, Photoholder.FrameCount - 1)

    Set Photo_4 = int(random(0, Photoholder.FrameCount - 1)

    Set Photo_5 = int(random(0, Photoholder.FrameCount - 1)

    You let it start at 0 since frames always start at 0.

    The reason you subtract one from FrameCount is due to the same reason. As it counts the actual number of frames, so if you have 10 photos it return 10. However since you want to store the frame number, and it starts at 0 you just subtract 1 from FrameCount.

    Doing it like this also means that if you decide that you would actually like to use 15 photos instead of 10, you can just add them and the code will include them automatically.

    When you want to show them again, you just read these values. And if there are no value it should just be ignored.

    Since you know that the value will always be greater than 0 if there are a photo stored, you can just check to see if that's the case, and if so it should show the image.

    If photo_1 > than 0 Show photo

    If photo_2 > than 0 Show photo

    If photo_3 > than 0 Show photo

    If photo_4 > than 0 Show photo

    If photo_5 > than 0 Show photo

    So you can either just give them a default value of -1 to start with and every time you want to generate new ones you just start by setting all of them to -1, before setting the photo that should be stored.

    You don't have to use a loop for this, but if you want to do it, then you could do it like this:

    For 0 to int(random(1,5))

    If Photo_1 = -1 then Set Photo_1 = int(random(0, Photoholder.FrameCount - 1)

    If Photo_2 = -1 then Set Photo_2 = int(random(0, Photoholder.FrameCount - 1)

    ...

    ..

    Etc.

    That should do the trick

  • I have looked at it, and its not easy to see what you are actually trying to achieve with it, some explanation would make it easier :)

    Anyway as im not really sure what its suppose to do, I might be way off in what you are trying to do, in that case you can just ignore my post.

    Just as a tips, its rarely a good idea to make a loop run every tick. But make it run in a function or on an event call, as it will otherwise run 60 times a second multiplied with the loop, so that loop you have added, even though it goes to max 5, can actually need up to 300 "checks" per seconds. And since there are no condition for it for whether it should run or not, it run every cycle.

    Just on a side note, its a good idea to name them, especially if you use nested loops, so you are sure you are using the correct loopindex, should you need it.

    The reason I think its not working is because you add 1 to "PhotoPlacement" but since the max times it should run is set at "On start of layout" the photoplacement will always be this number to start with, this might be ok?.

    The reason for that is because the loop will run from 0 to PhotoRandomizer before it moves on. So if PhotoRandomizer on "Start of layout" is 3 then PhotoPlacement will also be 3. Not sure if you change it later on, but if not, then each time you run the loop, PhotoPlacement will keep counting up with 3 each tick. So at second tick Photoplacement is actually 6, so if you take into account that it runs 60 times multiplied by the loop every second, then after a second Photoplacement is actually 180, if im not mistaken :D

    From what I can see, you don't actually need a loop in this case, you could just "Set Photoplacement = PhotoRandomizer" unless you change it some where else.

  • Think you can do it, exactly how to do it, depends on the game you are making. But you can work with elements of the sounds, like peak, frequency, volume etc.

    Exactly how they work I don't know, as I haven't tried something like this before. But I would imagine, that if you use these an link the values that they return to some kind of obstacle creator it might be possible.

  • I have added a game to Kongregate as a test, but its some time ago so cant remember what I did with the scaling.

    However you can actually test it, but creating an account in there and upload it. It wont go live on there site unless you want it to, so you can test it and see what works.

  • Welcome to the forum :)

    There are two different events for switching layouts, not really sure why. But anyway, one of them is where you have to type the name of the layout you want to go to, and the other you just select it in a drop down. Why you wouldn't just use the drop down always im not sure, as it automatically updates if you change the name of the layout anyway, where the other one doesn't. But try to use that one instead.

    Using a new event sheet for every layout, is not a bad idea. As your project grows keeping track of things can be a huge problem, if you throw all the events in one sheet, you will very quickly start to loose track of whats going on. Besides that you can just include event sheets into layouts.

    Some tips for you, as I also started out just throwing everything into one event sheet, which costed some projects and some hair :D

    Make 1 event sheet named the same as layout, and keep this as the standard. Even though you might not actually add anything to it, but then you have it in case it suddenly makes sense to use it. If you need something from the other events sheets just include them.

    Make event sheets that take care of specific things in your game, for instant:

    Enemy

    Player

    Map generator

    Menu

    Sound

    etc.

    And just include them in the layout where you need them.

    If you use functions, never add them to the same event sheet where you have actually events, like "on Mouse", "Key down", "Every 1 sec" etc.

    But put them in there own event sheet, and again just include them where you need them.

    So your event sheet layout might look like something like this:

    Enemy

    Enemy functions

    Player

    Player functions

    ....etc.

    The reason for this, is that functions will never run unless called. So if you add them to the same event sheet as the actual events are, and then include it. Suddenly you might experience weird errors. Because some of these events triggers because you accidently forgot to take something into account.

    In general I would also suggest that you start getting used to use functions as much as possible. As it will speed up making the game. But also make the game a lot easier to troubleshoot. As a function is very easy to test....."You put something in, so you expect something to come out again". And if the output doesn't give you what you expected. You know that either the input or something in the function is wrong, and is much easier to troubleshoot.

    The project im current working on have 3 layouts, 15 events sheets with 1834 events/functions. Imagine having all those in one sheet, without organization and lots of functions this would have gone wrong a lot time ago :D

    So I would strongly suggest you start to organize your projects, even if they might be small now, just so you find a good way to work with them. I promise you it will save you a lot of problems and frustrations later on. :)