I thought you wanted it to move with the ship.
Hodgey got the right line to fix. Change it to this:
SetVirtualResolution (320, 480)
// create the sprites
Ship = CreateSprite (LoadImage ("playership.png"))
Enemy1 = CreateSprite (LoadImage ("enemyship.png"))
Enemy2 = CreateSprite (LoadImage ("enemyship.png"))
Laser = CreateSprite (LoadImage ("laser.png"))
// set the sprite positions
SetSpritePosition (Ship, 0,200.0)
SetSpritePosition (Laser, 35.0 , 200.0)
LaserY# = 200.0
SetSpritePosition (Enemy1, Random ( 100, 280 ), Random ( 0, 300 ))
SetSpritePosition (Enemy2, Random ( 100, 280 ), Random ( 0, 300 ))
// turn off the left wall
SetPhysicsWallLeft(0)
rem Loop
do
// get position for ship
y# = GetPointerY()
// move the ship
SetSpritePosition (Ship, 0.0, y#)
rem Sets collision for enemy1
if GetSpriteCollision ( Laser, Enemy1 )
SetSpritePosition ( Enemy1, Random ( 100, 280 ), Random ( 0, 300 ))
endif
rem Sets collision for enemy2
if GetSpriteCollision ( Laser, Enemy2 )
SetSpritePosition ( Enemy2, Random ( 100, 280 ), Random ( 0, 300 ))
endif
// get ship location
ShipY# = GetSpriteY ( Ship )
ShipX# = GetSpriteX ( Ship )
// move laser along and keep in line with ship
SetSpritePosition ( Laser, GetSpriteX ( Laser ) + 3.0 , LaserY#)
// check for gone far enough
if ( GetSpriteX ( Laser ) > 280.0 )
// move back to ship position
LaserY# = ShipY#
SetSpritePosition ( Laser, 35.0 , LaserY# )
endif
Print (ShipY#)
Print (ShipX#)
Sync()
loop
Two lines added, two lines changed.
Cheers,
Ancient Lady
AGK Community Tester