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

5 years ago by eLouai

this question is with regards to creating permanent changes to the landscape or environment without populating it with entities.

i.e. tire marks on asphalt, or bullet casings or skate marks on ice. You don't want to delete those images but you don't want to assign it to entities, you should be able to 'draw' it permanently onto an image layer.

Question: What is an optimal or preferred way of doing this in impactjs

5 years ago by Apiheld

Good question. I'd create an ig.Image where the marks on asphalt are rendered onto. Alternatively, you make a second canvas. This serves as a buffer basically. Once they're drawn into this buffer, you can stop drawing them every frame.

Then, in your drawing routine: Impact clears the canvas every frame. After clearing the canvas, you either draw the ig.Image (or swap the canvas content with the second canvas). Basically, you put the entire buffer content on the screen.

Then, you render your normal entities / game world.

5 years ago by Joncom

A few options:

1) Have a layer in your level where you set tiles according to where you want certain visual effects to be drawn. If a tile should have a bullet hole, set that tile to the "bullet hole" tile. I would not do it this way.

2) Use entities. Unless you're running into performance issues (because you have too many entities), why not use them? It would allow you to place visual effects exactly where you want.

3) Apiheld's idea. You could create an off-screen canvas the same size as your level, and whenever a visual effect needs to be added to the level, draw it to this canvas. Then draw this canvas every frame.

Option 2 is probably simpler to implement.
Option 3 would probably give the better performance.
Page 1 of 1
« first « previous next › last »