• 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!

Windows Global test????

J

Jaydon

Guest
I have set this in a script:
global.point =0;

and in another script:
global.point +=5;

but I cant seem to figure out how to test this variable :(

I have tried a few things but I just keep getting errors.

I want to test this variable so that i can delete an instance of an object but can't figure it out.

Thanks for the help :)
 
R

Rabid_Ghost

Guest
i would just put this in a draw event.

draw_self()
draw_text(0,0,global.point)

this should draw the value of global.point
 
Code:
if ( global.point > 100 ) // example...change this to the appropriate condition for your game.
{
    with ( <put_instance_id_here>  )
    {
         instance_destroy()
    }
}
Edit: Because it is a global variable you can run this anywhere.

What exactly have you tried so far and post the code and error messages you are getting, it will be easier to provide more specific help.
 
J

Jaydon

Guest
well what I am trying to do is when you move the player over an object it gets destroyed then you get a score point once you get the 25 points the exit will open, i have everything except the point on destroy.
 
Last edited by a moderator:
In the DESTROY Event for the enemy object, put

Code:
global.point +=5
If you have many different enemy objects, instead, create an obj_enemy_parent. Make all your enemy objects children of the obj_enemy_parent, then put the DESTROY Event code in the obj_enemy_parent object.

In the player CREATE Event:
Code:
exit_open = false
Then in the player STEP Event put the following check:

Code:
if ( global.point >= 25 && !exit_open) // example...change this to the appropriate condition for your game.
{
    exit_open = true
    // Write the code to open the exit here.
}
 
J

Jaydon

Guest
so this is what I have in my mine:


And in the Gate:

not sure if I did this right.
 
There's a few problems that I can see there. The mine will just constantly add +25 to global.points every step the player is touching it, even though the sprite has changed. So it will quickly add many many many points for just a second of touching. Secondly, why is the open gate code in an alarm? You should have it in the step event.
 
Also, GameMaker is case-sensitive. So global.point is not the same as global.Point (note the Capital P you used in one piece of code, in the other you used a small p...you need to make the spelling exactly the same for starters).

After the player collides with the mine, should you be calling instance_destroy()? So that the instance no longer exists and the player will not continuously get 5 points added to their score?

Will have a better look later, need to go for now.
 
Top