nimos100's Forum Posts

  • [quote:2vimrvlb]Having multiple tilemaps like Nimos100 said is also a nice solution, as it is easier to read/write in the events maybe. I'm not sure it is best performance-wise, but as the map isn't drawn, I don't see any problem. For a debug purpose it's a lot better this way (as you showed us).

    Performance wise I think using arrays are faster, but in my game as its automatic turn based or what to call it, meaning that each time the player does something it will do a turn. So I don't have to update my tilemaps all the time. but only when something trigger some change, which would be to one tile at the time.

    Another benefit is that the player can hide and show different things, like showing the territory of the different empires, building areas and so on. Since they are separated showing and storing these information in tilemaps make it very easy to work with. So for me I don't really get a lot from using arrays over just using the tilemaps them self, as the performance is not really affected a lot by having several tilemaps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What he means is that if you have a tilemap that are 20x30, so 20 tiles in X direction and 30 tiles in Y direction. Then you should make an array that are 20x30 as well, the Z value (the 5) are the one that holds the information for that tile, in his example it can hold 5 different information, if you need more you just increase it to whatever you need.

    An example:

    If the tile in your map at position (1,1) is a rock. Then the array at (1,1,0) could hold rock.

    The reason he use 5 is simply if you need a tile to store several information. So lets say that this tile also have a defence value of 2.

    Then your array would be like this:

    Array(1,1,Rock)

    Array(1,1,Defence value 2)

    So the first two numbers in the array refers to the position of a tile in your tilemap.

  • I use something similar in my game, the way i do it, is by using several tilemaps.

    So one tilemap are the terrain informations, meaning that this is where the map is actually drawn, stuff like grass, mountains, deserts, water etc.

    Next there are a tilemap that holds road, rivers etc.

    A collision tilemap that hold all informations about which tiles are impassable and how costly it is for a unit to move on a given tile.

    There are some other tilemaps as well.

    So what i can do, is simply use each tilemap to check certain things. For instant it is more costly to move in mountains than on grass. So ill check each tile during start of the game, and save these information to the collision tilemap. And then i just check for roads and if there are a road on a tile with mountain it will then use the road settings and not the mountain.

    In my game, if i render the collision map it will look like this:

    Now there are some tiles that are not added.... but the color goes from none to black, where red cost a lot, and black is impassable, such as water. So it works fine, and units prefer moving on roads, avoid mountains etc. And it gives a good amount of flexsability as you can add several different tiles on top of each other and just read the information from a given tilemap when you need it.

  • You can use an "Overlapping another object" and then just invert it, by right clicking it and choose invert

  • The coordinate of the layout starts with 0,0 in top left corner.

    All objects have an x,y value thats fits it.

    So if you want an object to move Down 50 pixel, you can just add X-amount to y. To move up you subtract X-amount from Y.

    So in your case to make it very simple, you can store store the current X,Y value of your object. And every 1 sec for instant, you move the object X-amount in the direction you want to. And then test:

    starting value - current value > 50

    If thats the case you stop the object from moving. This check you just put in the event/function that handles movement of the object. And modify it so it fits the different directions you want it to move.

    Then it will slowly move in that direction.

  • Why not simply split it up into several functions?

    function foo(){
       ...
       call Anotherfunction(){
         ...
         if( returnvalue = 1) 
            return 1;
         else(call YetAnotherFunction ){
            ...
            if(Returnvalue = 2){
                return 2;
            }
    
         }
       }
    }
    [/code:2m08bv8y]
    
    To me it looks a bit like you try to just throw everything into one function where they might not be needed. Instead of just splitting them into several functions that does something more specific.
    
    Function Set car() : Set values of the car with UID
    
    Function Find car() : Return the UID of the car based on some input.
    
    Function Delete car() : Delete car with UID.
    
    etc...
    
    In your example it looks like you have a function, that should do something to something, and based on what it does it might have to do something else. But you are not really sure what it is suppose to do. But maybe i misunderstood what you are trying to do, or what exactly your problem is.
  • You can just add a condition to the event that count down the timer, so if timer > 0 then it will do the count down.

  • You can add either a pick nearest or pick top/bottom as another condition when checking collision between the bullet and an enemy that should fix it.

  • You can use the emulation Tool XDK from Intel, it will let you test it on a lot of different phones. Its free if i remember correct, and you can export your project directly from C2, just choose the INTEL AGI.

    However its some time since i played with it. But from what i remembered it was really cool

    You can find it here:

    http://software.intel.com/en-us/html5/tools

  • You can do it with the distance command.

    The way you use it is by adding a comparison from the system and in the first value you just write:

    Distance(x1,y1,x2,y2) that will give you the distance between two objects.

    In your case it would probably look something like this:

    Distance(Flashlight.X, Flashlight.Y, Enemy.X, Enemy.Y) < 50

    You can use the Distance function in any comparison event, so just use the one that fits, what you try to do.

  • I don't think it will make a huge difference in performance whether you are using a 1024 compared to a 512 one.

    As you would need twice as many 512 ones, would also mean that all the stuff that have to check against the 1024, would need to do it twice if you use 512 ones.

    Think the best you can do is just keep track of how much memory and cpu your game requires as you make it, and if something you add suddenly makes requirements jump, then try to remake it. If you can figure out, what limits would be acceptable for the game to run on a older mobile phone, and you just try to make sure that you stay within those limits I think you will be fine, no matter which way you do it.

  • Yeah it almost does that. The only thing it would need was to search all event sheets, and show a menu with a prev and next button :D

    But that will be helpful for now, actually never tried it <img src="smileys/smiley9.gif" border="0" align="middle" />

  • I was wondering if you think or all ready might have thought about a functionality that let you find events in the event sheets, would be a good idea.

    The way I thought it could work could be something like this.

    If you for instant have an object, such as a button, text etc. you would be able to navigate through all events that involved it.

    Kind of what you would find in a word program, where you can type a word, and then press next and it would go to the next instance of that word.

    So imagine that it could work something like that, think that would be very helpful, when you have big projects, and have to go back and correct something but forgot exactly where you put it :D

    Also if you have to for instant replace a button with a spritefont, then you could use it to find all the places where the button is used, and be 100% sure that you replaced all of them before removing the button.

  • So i made a new version :D

    And got it running better by using a distance check. So can do around 2500 objects (1250 since half of them are colliding objects) and still keep it around 30 frames.

    <img src="https://dl.dropboxusercontent.com/u/109921357/Image_1.jpg" border="0">

    I tried to see if i could do some kind of Quadtree collision detection that i saw on the internet, that apparently divide the screen into areas for testing. So one area doesn't test against another area and so on. but couldn't really get it to work. :( And think it should probably be implemented into C2 it self, if it should even have a chance of being possible :D

    Anyway here is the new Capx, if anyone is interested:

    Collision test

  • "Your capx is far away from just moving some sprites around. It's moving 650 sprites around and doing 422,500 collision checks every tick."

    I understand what you mean, but i meant "IM" not doing anything, that i don't trigger anything for these objects, C2 does a lot of things, that's why the fps drops.

    "On sprite collision with sprite

    Sprite bullet speed is > 0

    This means c2 misses out on all the performance benefits because it does all the collision checks first, which is the more intensive task. The filtering happens top to bottom, so what you should have done was:

    Sprite bullet speed is > 0

    If sprite is overlapping sprite"

    You are correct about that, did a test earlier of these events, and found that the "On collision" is the one that does the biggest performance hit.

    1000 objects, will reduce fps by 92.5% where the same test using overlapping, only reduce fps by 62.5%. So that could explain why you don't suffer that much when you use that.

    "I want to make sure you understand that just because the object don't appear to be doing anything, doesn't mean you're not slamming the CPU. The act of checking for collisions on them all every tick is intensive, even though there is no visible result."

    Yeah im aware of that :)

    "Which you can. You can set conditions, but they need to be BEFORE the collision check. That's why you use 'is overlapping' rather than 'on collision' so you can put conditions before it. "

    Yeah it does way better than the other. Agree.