R0J0hound's Forum Posts

  • You can improve the rendering speed of the tilemaps by setting "seamless mode" to off in the tilemap properties.

    In addition to that set "pixel rounding" to on and "fullscreen scaling" to low quality.

    Here's the latest of my capx that saves chunks that were modified.

    https://dl.dropboxusercontent.com/u/542 ... lemap.capx

  • Using the "is within angle" should do it.

    Angle(player.x, player.y, object.x, object.y is within 90 degrees of player.angle

    ---- (object is in front)

    Else

    --- (object is behind)

    That's for one player and one object. To work with multiple of each, add a "for each" player and object condition and put the events above as sub-events.

  • There's an example here that draws the path of the object.

    It doesn't do collisions though.

  • Prominent

    That should work. I'll have to look at it tomorrow to see why it doesn't.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad it was useful. I'll take a look at what your capx tomorrow.

    I thought of a simple way to save changes to the array.

    Basically just change the tiles on the tilemap like normal, but when you do, set a Boolean variable to save that tilemap.

    When that Boolean is set and before moving a tilemap that moved off screen, store that tilemap in a dictionary object.

    With this key

    X&" "y

    And this value:

    Tilemap.asjson

    Then after moving check if the current tilemap position is in the dictionary. If it is, load that json. If it isn't call update.

    That way only tilemaps that are changed are saved.

    Enemies could be tricky if they're off screen since they would no longer have a tilemap to interact with. Two ways around that come to mind. One would be to put the object to sleep if offscreen. Another would be to maintain some tilemaps around the enemies, however this could prove complex.

  • Ok, here's the result:

    https://dl.dropboxusercontent.com/u/542 ... lemap.capx

    Probably should have called it spelunking turtle.

    I set it up with 64x64 tilemaps with 4x4 tile size and it works decently. I get about 30fps on my machine, so I assume most others will get a higher fps. I briefly tried 128x128 tiles but it seemed to stall a bit more. Also I had some more fun with perlin noise in this one. I found you can combine it in various ways to create some interesting terrain.

    It can be made faster I think if I use some javascript to do what the update function does, and create a json that can be loaded into the tilemap. But for now it's decent.

  • You may be able to work around that by resizing the sprites first so they overlap before that check. Then afterwards resizing them back.

    Or you could move the imagepoints a bit further off the collision polygon.

  • What could be done is a chunk based approach so the tilemap could be used. The idea would be to do the same as my example but use multiple tilemap objects that you move around and update the tiles in them when they're moved around.

    I'll try to give that a go tomorrow, it sounds promising.

    The next problem to consider is a way to keep track of terrain changes if you want to be able to add/remove tiles as the game runs.

  • Using a tilemap for this could be tricky and may not give any gains since it looks like you'd have to update the whole tilemap every time you scroll. I'll have to think about it some more though.

    Scrolling in other directions will only take one event a piece, and will look much like the one to scroll right. I'm away from my PC atm.

    Only the randomize seed action sets the state. The perlin2 expression will always give the same value for an xy if the seed is the same.

  • You can still use that method with the built in physics.

    I'm saying if you used chipmunk physics instead there's an expression to get the point of collision under a "on post collide" condition.

  • That particular formula doesn't use perlin noise, it's just a sine wave.

    Most of the values are pretty arbitrary, but the general form of the equation is:

    https://www.google.com/webhp?sourceid=c ... 0of%20sine

    y = amplitude * sin(frequency*x + phase)

    amplitude is how high the waves go.

    frequency is how close the peaks are.

    phase is the initial x offset.

    In the formula as I wrote it in the capx.

    rnd1, rnd2, rnd3... are just some random numbers I saved. And the Array.curX/40 basically scales it to the array which is 40x30. The other numbers just tweak it a bit.

    I used grater than because i wanted to fill in everything below that graph.

    As far as an example here's how I would do infinite terrain with perlin noise.

    https://dl.dropboxusercontent.com/u/542 ... croll.capx

    It matches the "perlin noise with vertical gradient" in that previous capx.

    The scrolling is done by covering the screen with the blocks, and disabling/making invisible the blocks that should be clear. Then as the blocks go off the left of the screen they're moved to the right and updated.

    The shape of the terrain is defined in the update function. Just by fiddling with the numbers you can get a wide variety of terrain shapes.

  • If you use the chipmunk behavior it can give you this info.

    If one of the objects is a circle you could also do this:

    viewtopic.php?f=147&t=153479&p=967445&hilit=collision#p967445

    Another idea that would work ok in most cases is add an image point to every corner of the object's shape. Then loop over the image points and see if they overlap the other object. For every one that does get an average position and that will be your point of collision.

    https://www.dropbox.com/s/ndzxmp4mwc5sd ... .capx?dl=0

  • You could possibly create an effect to draw a circle. I didn't find one with a quick search though. Another idea is to use the third party canvas plugin to draw the circle.

    For using a sprite I'd just go with a size that looks good to you.

  • With that plugin you set a seed then use the perlin2d(X,y) to get a value from -1 to 1 for any position. So yes, it's like a cloud.

    For terrain the usual method is to use a threshold on the result. Like if the value is greater than 0 make a tile, else leave that spot empty.

    The only gotcha of the plugin is if x or y are integers (no decimal part) the result of the perlin expression is 0 so you usually should multiply X and y by some decimal number before using it as a parameter. Also you'll be doing that anyway to scale the noise to your preference.

    That said, it's just and idea and may not work well enough in some cases.

    Edit:

    Here's an example of getting 2d terrain with that plugin.