P
PPowerrr
Guest
Hey everyone,
I am trying to learn Gamemaker Studio 2 and I gave myself the task to make a 2player game of tag.
I now have 2 players, who can walk around and bump into walls. I also started on the tagging but I came across a problem.
For tagged and not tagged I use a variable
or
where 1 means you are the tagger and 0 means you're not.
So this is the code I use for tagging:
I only have this code in oPlayer1 since I'm afraid that if I put it in both it will mess up the game.
My problem:
If I play the game and the tagger and the other player bump into eachother, it works perfectly fine. The tagger becomes the non-tagged player and other way around. But after this it doesn't work another time. The collision part works only once. I also tried the same piece of code without the if statement in a collision event but it gives the same result.
Can anybody help me with this problem?
And does anyone perhaps have a tip for me to make my code easier?
Thanks in advance,
Pim
I am trying to learn Gamemaker Studio 2 and I gave myself the task to make a 2player game of tag.
I now have 2 players, who can walk around and bump into walls. I also started on the tagging but I came across a problem.
For tagged and not tagged I use a variable
GML:
tagged = 1;
GML:
tagged = 0;
So this is the code I use for tagging:
GML:
//tagging
if (collision_rectangle(x-0.5*sprite_width,y-0.5*sprite_height,x+0.5*sprite_width,y+0.5*sprite_height,oPlayer2,true,false))
{
if (tagged = 1)
{
tagged = 0;
oPlayer2.tagged = 1;
}
if (tagged = 0)
{
tagged = 1;
oPlayer2.tagged = 0;
}
}
My problem:
If I play the game and the tagger and the other player bump into eachother, it works perfectly fine. The tagger becomes the non-tagged player and other way around. But after this it doesn't work another time. The collision part works only once. I also tried the same piece of code without the if statement in a collision event but it gives the same result.
Can anybody help me with this problem?
And does anyone perhaps have a tip for me to make my code easier?
Thanks in advance,
Pim