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 McCann

One thought I had was for my map to be dynamically generated and change over time. For example, if I shoot a block, it won't blow up. But, if I change to a bigger gun, it will blow up. From the threads I was looking at, it appears that the map is stored in an array.

Can we easily change the behavior of the blocks?
Can we add new behavior to blocks? (i.e. how it impacts the user or how we can interact with it)

1 decade ago by MikeH

It's possible, but you have to do a bit more work yourself. The game I'm working on now has dynamically generated levels, and to do that you have to override some of the impact methods with your own. Take a look at the 'drop' source code to see how that generates levels on the fly, and you should get a good idea how you can manipulate the collision and background maps while the game is running. You could use handleMovementTrace to see which tile a bullet entity has collided with an change it in the background map.

1 decade ago by McCann

Thank you!

1 decade ago by Alex

Dynamic maps ftw! Mine's working great, however a question - how would you guys implement health to collision tiles? Similar to entity, so that it'd take more hits/collisions to get destroyed. Is there some easy way to add a property to a tile?

1 decade ago by fugufish

@Alex - this might be a temporary fix, but how about creating a new entity that resembles the tile, and assign it a health? that way, you can put as many of them in your dynamic mac as you wish (via spawnEntity)

1 decade ago by Graphikos

@fugufish

This is the approach I took and found that recreating a level with entities is a performance nightmare. I'd be interested in finding the best way to do this either way.

1 decade ago by Alex

Well, if it's only 1 tile destruction at a time, all I can imagine of right now is that when tile collision(bullet, whatever), remove tile and then spawn an entity looking as a tile there with some health.

This is not perfect, but would work. I think there's some easier way to do it.

1 decade ago by dominic

If you need "health" on tiles, here&039;s what I'd do: create a separate 2D array for the health with the same size as your background map and initialize all entries to the desired health. Then, when #handleMovementTrace() look up the health for that tile in your array and decrease the health or destroy the tile in your background map.

1 decade ago by paste120

I know this thread is a little old but, when you remove a tile from your background map does it also update the collision?

1 decade ago by dominic

It depends.

Have a look a the Drop source code (in DropGame.init()) - it creates a BackgroundMap and CollisionMap from the exact same data array. If you modify this data array, the background and collision map will reference that modified array. So in this case, the background and the collision are changed at the same time.

If you build your level with Weltmeister, it creates to separate data arrays for the background and collision map. This means you have to change both data array yourself.
Page 1 of 1
« first « previous next › last »