Help with score

S

spottrigger

Guest
Hello everyone, I'm struggling with something about score. It's not the regular "How to give me 10 points if I kill zombie" thing, its more complicated. So basically what I want to do is when the room resets(which is what happens when the player collides with spikes), subtract 50 score. At this point I've tried all I can think of, and nothing works, I did make a score object, drew a score on in my view, and set it to 1000, but I cannot figure out how to subtract 50 from 1000 each time I collide with a deadly object. Any help is greatly appriciated.
 
M

Mann_mit_Hut

Guest
It would help to see what you tried that is not working.
Gm has a build in "score" variable which is global. So just use that and use
score=score-50; room_restart()
To restart.
 

Perseus

Not Medusa
Forum Staff
Moderator
Use a global variable. Don't declare it in a gameplay room, but a boot room, since the global variable might get reset to its default if the room happens to get restarted. For that, create a new room, call it rm_boot or something, then use its creation code to do something like this:

Code:
global.points = 1000;
room_goto(rm_Main);
The code above declares a variable called global.points (this should be the only place where you declare it) and then moves to the rm_Main room, which is the room that is supposed to get displayed when the player starts the game. Make sure that rm_boot is placed at the top of the resource, so that it runs before any other room. Note that creating an entirely new room isn't mandatory. You could use the first room (not a part of the main game) to declare it.

Now that the global variable will persist in memory until the game ends, you don't have to worry about its value getting reset. Simply decrease its value by 50 before restarting the room.
 
Top