I see the code, I see results of it, but don’t understand WHY it works. After finishing Gravicannon, I plan to make platformer with destruction engine similar to one of Liero, but to do that I must first understand how this example works. Can you help me with that?
//edit: Additional help would be to make simpler destruction example, without these debris that fly around after shooting things.
The principle is quite simple : When a missile is in collision with a solid object, a blank image is pasted on the object, at the position of the missile.
Note that the position of the pasted image is relative to the position of the target object. Thus, the blank image is pasted at position ( Missile.X() - TargetObject.X() ; Missile.Y() - TargetObject.Y() ).
The blank image is in fact an image containing transparent pixel, so that a hole is created in the target object.
EDIT : Here is an example. I’m using a slightly different technique : I paste an pink image, taking in account the transprent pixel, and I then make the pink pixel transparent. It allow to use custom shapes.destruction.zip (86.7 KB)
OK, thanks. Though I managed to discover how it works by myself few minutes ago (will check your example though as your technique seems superior). Can you help me with my naughty pea problem?
Hm… Your method don’t exactly work for me.
Download and try shooting corner of the box. Supposed behavior is to make hole in the box and the box next to it (if “hole” image overlaps it). Instead hole is being cut off. I can’t afford this as levels in my game will consist of tiles (making level as one image wouldn’t be good - game would weight a ton or have very few levels).
Also there is some funky pea’s movement when going inside holes made with rockets (going up on it’s own when it is supposed to stop if something is blocking it way). I can accept moving on its way down (gravitation & sliding of slopes), but climbing up on its own or sliding through ground is way too much.
//edit: fixed some typos.