P
PRellevart
Guest
Hi guys, I'm running into some of the problem here that I don't know how to fix
I'm trying to add a delay before changing sprite to a different one when two players collide each other. It is a game of tag, therefore I like one person to be "it" and the other to be running away
I ran into some problem about collision as the player collide horizontally, they will go through each other instead of bouncing off in vertical. When the player bounce off, the "it" change to the other person perfectly, but when they go through each other, the "it" keeps on changing between players indefinitely until they are not overlap.
Therefore, I'm trying to add a delay function (or an alarm event) to let the player who got tag and become "it" wait for 3 seconds before they can tag the other again and change "it". However, I don't know the coding aspect of it
This is my code so far
In step event:
in collision event between 2 player:
Many thanks guys
I'm trying to add a delay before changing sprite to a different one when two players collide each other. It is a game of tag, therefore I like one person to be "it" and the other to be running away
I ran into some problem about collision as the player collide horizontally, they will go through each other instead of bouncing off in vertical. When the player bounce off, the "it" change to the other person perfectly, but when they go through each other, the "it" keeps on changing between players indefinitely until they are not overlap.
Therefore, I'm trying to add a delay function (or an alarm event) to let the player who got tag and become "it" wait for 3 seconds before they can tag the other again and change "it". However, I don't know the coding aspect of it
This is my code so far
In step event:
#region //movement and collision with platform
key_left = keyboard_check((vk_left));
key_right = keyboard_check((vk_right));
key_jump = keyboard_check((vk_up));
var move = key_right - key_left;
horispd = move*walkspd;
vertspd = vertspd + grav;
#endregion
#region // collision with platform
if (place_meeting(x,y+1,Obj_floor)) && (key_jump)
{
vertspd = jumppower;
}
if (place_meeting(x+horispd,y,Obj_floor))
{
while (!place_meeting(x+sign(horispd),y,Obj_floor))
{
x = x + sign(horispd);
}
horispd = 0;
}
x = x + horispd;
if (place_meeting(x,y+vertspd,Obj_floor))
{
while (!place_meeting(x,y+sign(vertspd),Obj_floor))
{
y = y+sign(vertspd);
}
vertspd = 0;
}
y = y + vertspd;
#endregion
#region //it not it
if (it = true)
{
image_index = 0;
walkspd =6;
}
else
{
image_index = 1;
walkspd = 4;
}
#endregion
in collision event between 2 player:
if (it = true)
{
image_index = 0;
it = false;
}
else
{
image_index = 1;
it = true;
}
//horizontal
if place_meeting(x+horispd,y,Obj_player1)
{
horispd = -horispd+grav;
}
//vertical
if place_meeting(x,y+vertspd,Obj_player1)
{
vertspd = -vertspd;
}
Many thanks guys