Collisions
create event for ball - see previous Movement page (has not changed)
better way (note this is now in a Step event):
note:
- relative - i.e. relative to its current (previous) value
- investigate different Collision Masks (in ball sprite) e.g. Precise or Ellipse.. add more balls. what happens? game will eventually slow down (with enough balls on precise collision)
- be careful with marking objects as "Solid". for collision events for "Solid" objects, the two objects colliding cannot overlap. the object "bumping" into the other object will be kicked back to the last (~hopefully~) non-colliding position. so if your object is moving and touches a solid object, it will be moved out of it. however, if the object starts there or gets placed (or bumped) to a position that is still overlapping the solid object - your objects will "stick" together
Create event:
myDirection = random(360) motion_set(myDirection,3)
Step event:
if(place_meeting(x+hspeed,y,objWall)) or (place_meeting(x+hspeed,y,objBall)) { hspeed *= -1; } if(place_meeting(x,y+vspeed,objWall)) or (place_meeting(x,y+vspeed,objBall)) { vspeed *= -1 }
note - the previous step event could be shortened to: move_bounce_all(true)