• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker 52/5000 question for a new project, destructible element

D

diester

Guest
Hello to all.

first of all thank you for the help that was brought to me here, it allowed me to finish my first small project.

on the other hand for my future project (the first my license to familiarize me with gms2 and language gml that I only know since 1 month and a half).

is it possible to make a material (cardboard, fabric, sponge, .....) destructible?

for example on the following drawing I would like the bombs in black to destroy only the material in red and in no case the material in blue. that it digs it as bombs fall?



is it possible on gms2 and if yes is there a tutorial?
To my regret I can not find anything on this specific point

thank you for reading me and sorry for my english so bad
 

nesrocks

Member
I imagine that making bombs destroy images like that is the hardest part, but I think there are tutorials for that out there. The rest is simple.

1 - Sepparate the images by material.
2 - Set "resistance" values for example cardboard_resistance = 1; fabric_resistance = 2; sponje_resistance = 3;
3 - Assign a "strenght" value to the bomb strength = 2.2;
4 - When destroying images check if the strength is bigger than that material's resistance.
 
D

diester

Guest
for that yes yes I know how to do it (I think) but what I want is that the red matter be destroyed by patient not all at once.

for example a bomb detruis 2% of a cube, a second bomb 2% (which makes that the cube is destroyed at 4 °%) ex ......

I have not managed to do it and that's what I need.
 
D

diester

Guest
I miss it more than find how sprites can this moved that on the white part

22% of a cube? Is your game 3D?

@Alexx I'll check that out, it might be useful for my graphics editor
no, I use gms2 only for 1 month and a half and do something clean and pretty in 3d is not for me I am very far.

do it in 2d already will be really good
 
D

diester

Guest
the idea would be (to have the same result as the small demo) shared by Alexx, but in physical system.
that the bomb falls but does not explode immediately and can be moved by the player. and that the bombs be subjected to the apesenteur as in reality
 
D

diester

Guest
Good evening, I found how to handle collisions and gravity between two different objects. on the other hand how to manage the collision of an object with itself? if a square object bears the same no is it possible to make it hangs like a player on a wall for example ??
 

Yal

🐧 *penguin noises*
GMC Elder
I'd say the most robust solution is this:
  • Have a list of all destructions caused (x, y, sprite, size etc)
  • Create a surface covering the destructible area, fill in all the destructions from the list
  • Use the surface as an alpha mask to draw the destructible area (e.g. fill it in the the destructible texture first, then use alpha-erasure to fill in the destruction)
  • For collision checking, a point has collision if it's in the destructible zone and the part it is at is not inside any of the caused destructions.
The reason you don't want to use the surface for the collision data is because surfaces get destroyed easily, so you need a backup. Also it's faster to loop through a list and do maths than it is checking pixels on a surface.
 
D

diester

Guest
il me semble être au-dessus de mes compétences actuelles. mais je vais creuser dans cette direction. merci pour la réponse, elle est la bienvenue
 
D

diester

Guest
Hello,
I managed with my current skill (lol) to do what I wanted to a close detail.

I have two different object of collision the first one is obj_collision1 which is on the layer instances the character has well the collision in horizontal and vertical.

on object 2 which is o_solid on the same layer the instances the character has no collision with the same code.


Code:
if (place_meeting(x,y+vspd,obj_collision1))
   {
    while (!place_meeting(x,y+sign(vspd),obj_collision1))
       {
        y = y + sign(vspd);
        }
    vspd =0;
   
    }
y = y + vspd;

if (place_meeting(x,y+vspd,o_solid))
   {
    while (!place_meeting(x,y+sign(vspd),o_solid))
       {
        y = y + sign(vspd);
        }
    vspd =0;
   
    }
y = y + vspd;
Why ?
 

Rob

Member
Sprite origin point is different for the collision sprites?

Also - to save doubling up on code you could make a collision parent object, add those 2 collision objects as children and then just check for a collision with the parent.

It will benefit you in multiple ways.

You should make a separate thread for new issues too, if they're unrelated to the original topic. It's easier to answer/find answers for.
 
Last edited:
D

diester

Guest
Sprite origin point is different for the collision sprites?
no, they are two different pieces of different size but the point of collision is the whole piece

You should make a seperate thread for new issues too, if they're unrelated to the original topic. It's easier to answer/find answers for.
I just thought that if I create a new subject I would argue because it's the same project. ;)

I already look at parent and child but it did not give anything that I had done wrong
 
Top