Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ryananger

I was wondering if/how impact might be able to handle procedurally generated maps similar to http://jsfiddle.net/CwCz4/.

1 decade ago by Joncom

ImpactJS is perfectly capable of handling procedurally generated maps. It makes no difference to the engine how the maps were created. You'll have to be more specific if you want more information...

1 decade ago by ryananger

Sorry, I was in a hurry when I originally posted.

I notice that by default the engine uses JSON to read the maps (tile type and collision type). I'd rather use 2D arrays to store map information, but I can't seem to find where the 'loadLevel' function is called from to see exactly how the JSON information is being used.

1 decade ago by drhayes

Totally doable. Anything that you could place in Weltmeister you can generate programmatically. Check out loadLevel in lib/impact/game.js.

That said, your better bet would be to make a generic level in Weltmeister, save it, then pretty print it to see what it's doing.

1 decade ago by ryananger

So I completely misunderstood how map information is stored before. Map information IS stored in a 2D array, but it's backwards compared to how I would do it. It's stored 'map[y][x]' instead of 'map[x][y]'.

That said, once I realized this, it didn't take long for me to 'port' my map generation over, I just had to go into the map.js file and switch all of the x and y's in how the map information is stored.

My question now is whether swapping all the x and y's in map.js would affect the same change on collision-map.js, because it calls map.js as a parent?

1 decade ago by Joncom

There's one way to know for sure, check in collision-map.js...

If I recall correctly though, it does indeed store the coordinates swapped...

collisionMap.data[y][x]...

1 decade ago by ryananger

Thanks joncom. It does indeed swap the coordinates, so instead of swapping them manually I just created my own 'collisionConvert' map for the collision to point to.

However, it seems that collision arbitrarily stops working when the player's x position is greater than 64000 pixels. I've debugged to make sure the collision map is actually storing the correct collision data, and it is, but collision still doesn't work. Don't suppose anyone would have an idea why this may be?

http://angerrmanagement.com/

Game is located there so you can see what I mean (A = left, D = right, space = jump). The console log shows player x and y, which tile on the collision map the player is occupying, and whether or not that tile is collision valid (1 = collision, 0 = no collision).

1 decade ago by Joncom

Quote from ryananger
However, it seems that collision arbitrarily stops working when the player's x position is greater than 64000 pixels.
Hmmmm. That's really strange. I would suspect is has something to do with your custom collision map class. May we have a look at it?
Page 1 of 1
« first « previous next › last »