Game Development Reference
In-Depth Information
with (other){
instance_destroy();
}
The first line in the preceding code basically tells GameMaker to start executing code
from within the object we have collided with. The other variable holds the ID of the in-
stance we collided with at this point.
In between the brackets, we use instance_destroy to destroy the instance. This
means that we destroy the collectable object that we collided with.
If we run the game now, we should be able to move around the screen and collect the col-
lectable objects. A new object should be created every time we collect one.
Now, we need to tell the game to give us a point every time we collect an object. Inside
the collision event with obj_Collect , go to a new line and enter S++; . Remember
that ++ means plus one. This will add one point to our score variable.
Right now, the player can't actually see the score, so we need to draw it to the screen for
them to see. To do this, add a Draw GUI event under the Draw section.
Search WWH ::




Custom Search