D
Duck
Guest
Hello guys, I need help again!
I'm trying to make a space game, where a unit circling back when they are about to leave to screen.
First off all here is what I got for the code:
------------------------------------------------------------------------------------
EnteringAngle = image_angle
if y <= 100 && EnteringAngle >= 90 //top
{
motion_add(EnteringAngle + 20, speed/10)
}
else if y <= 100 && EnteringAngle < 90
{
motion_add(EnteringAngle - 20 , speed/10)
}
if y >= room_height - 100 && EnteringAngle >= 270 //bottom
{
motion_add(EnteringAngle + 20, speed/10)
}
else if y >= room_height - 100 && EnteringAngle < 270
{
motion_add(EnteringAngle - 20 , speed/10)
}
if x <= 100 && EnteringAngle >= 180 //left
{
motion_add(EnteringAngle + 20, speed/10)
}
else if x <= 100 && EnteringAngle < 180
{
motion_add(EnteringAngle - 20 , speed/10)
}
if x >= room_width - 100 && EnteringAngle >= 0 //right
{
motion_add(EnteringAngle + 20, speed/10)
}
else if x >= room_width - 100 && EnteringAngle < 359
{
motion_add(EnteringAngle - 20 , speed/10)
}
------------------------------------------------------------------------------------
So I try to tell them if they are coming from the right towards the border, they should circle to the left,
if they are coming from the left side towards the border, they should circle to the right.
Mostly it works fine, except for the top and the bottom border, everytime when they should turn to the right side of the screen ( turning right from the top border or turning left from the bottom border), they just turn straight to the right and go on until they left the screen.
At the top border I never see them again, at the bottom border I can see them circling in and out of the screen and sometimes one of them just come back after I don't know how many rounds.
Occasionally they also having troubles at the edges and just leave.
I guess maybe something is wrong with my borders at 100 from each side?
So is my code somewhere at the right direction or completely wrong for this case?
Thank you in advance for the answers!
-Duck
I'm trying to make a space game, where a unit circling back when they are about to leave to screen.
First off all here is what I got for the code:
------------------------------------------------------------------------------------
EnteringAngle = image_angle
if y <= 100 && EnteringAngle >= 90 //top
{
motion_add(EnteringAngle + 20, speed/10)
}
else if y <= 100 && EnteringAngle < 90
{
motion_add(EnteringAngle - 20 , speed/10)
}
if y >= room_height - 100 && EnteringAngle >= 270 //bottom
{
motion_add(EnteringAngle + 20, speed/10)
}
else if y >= room_height - 100 && EnteringAngle < 270
{
motion_add(EnteringAngle - 20 , speed/10)
}
if x <= 100 && EnteringAngle >= 180 //left
{
motion_add(EnteringAngle + 20, speed/10)
}
else if x <= 100 && EnteringAngle < 180
{
motion_add(EnteringAngle - 20 , speed/10)
}
if x >= room_width - 100 && EnteringAngle >= 0 //right
{
motion_add(EnteringAngle + 20, speed/10)
}
else if x >= room_width - 100 && EnteringAngle < 359
{
motion_add(EnteringAngle - 20 , speed/10)
}
------------------------------------------------------------------------------------
So I try to tell them if they are coming from the right towards the border, they should circle to the left,
if they are coming from the left side towards the border, they should circle to the right.
Mostly it works fine, except for the top and the bottom border, everytime when they should turn to the right side of the screen ( turning right from the top border or turning left from the bottom border), they just turn straight to the right and go on until they left the screen.
At the top border I never see them again, at the bottom border I can see them circling in and out of the screen and sometimes one of them just come back after I don't know how many rounds.
Occasionally they also having troubles at the edges and just leave.
I guess maybe something is wrong with my borders at 100 from each side?
So is my code somewhere at the right direction or completely wrong for this case?
Thank you in advance for the answers!
-Duck