u no in that asteroids game if the ship goes of the screen it appears the other side im having trouble doing it on a similar game on scratch
someone help plz
Offline
When green flag clicked
forever:
If touching edge and x > 0
Go to (Insert the far right side here)
If touching edge and x < 0
Go to (Insert the far left side here)
:end forever
And when you do the far right or left side, make sure the x is closer to zero by about fifteen, or you'll just blink back and forth.
Offline
Here is an image;
http://i54.tinypic.com/hsmbn6.png
Sorry, I can't put in image tags, or URL tags.
Just copy and paste in your address bar.
Offline
Well that only works for the x-axis, and if the player touches the top or bottom, they'd be sent there too
I'd advise:
forever
if < (x position) > (480) >
set x to (-480)
end if
if < (x position) < (-480) >
set x to (480)
end if
if < (y position) > (360) >
set y to (-360)
end if
if < (y position) < (-360) >
set y to (360)
end if
end forever
That would work for all sides and I'm pretty sure it won't switch back and forth all that much.
Offline
TuffGhost wrote:
Well that only works for the x-axis, and if the player touches the top or bottom, they'd be sent there too
![]()
I'd advise:
forever
if < (x position) > (480) >
set x to (-480)
end if
if < (x position) < (-480) >
set x to (480)
end if
if < (y position) > (360) >
set y to (-360)
end if
if < (y position) < (-360) >
set y to (360)
end if
end forever
That would work for all sides and I'm pretty sure it won't switch back and forth all that much.
Almost, but you got the screen measurements wrong. Here's what it should look like:
forever
if < (x position) > (240) >
set x to (-240)
end if
if < (x position) < (-240) >
set x to (240)
end if
if < (y position) > (180) >
set y to (-180)
end if
if < (y position) < (-180) >
set y to (180)
end if
end forever
Offline
ScratchReallyROCKS wrote:
TuffGhost wrote:
Well that only works for the x-axis, and if the player touches the top or bottom, they'd be sent there too
![]()
I'd advise:
forever
if < (x position) > (480) >
set x to (-480)
end if
if < (x position) < (-480) >
set x to (480)
end if
if < (y position) > (360) >
set y to (-360)
end if
if < (y position) < (-360) >
set y to (360)
end if
end forever
That would work for all sides and I'm pretty sure it won't switch back and forth all that much.Almost, but you got the screen measurements wrong. Here's what it should look like:
forever
if < (x position) > (240) >
set x to (-240)
end if
if < (x position) < (-240) >
set x to (240)
end if
if < (y position) > (180) >
set y to (-180)
end if
if < (y position) < (-180) >
set y to (180)
end if
end forever
Oh haha sorry I forgot to divide by 2
Offline