I want say more clear.
I want make a game Like Flappy Bird. mean when press Space key move to up and when don't Press space key, fall to ground. for this work I want move view and Player together to X Direction.
I wrote a code for space key and move player and direction. but don't work good and view don't move with player position.
Please Guide me for make this game.
SetVirtualResolution (160,120)
SpaceKey = 0
spr = createSprite (0)
SetSpritePosition (spr, 20,50)
SetSpritePhysicsOn (spr, 2)
SetPhysicsGravity (0,50)
do
sprx# = GetSpritePhysicsVelocityX(spr)+0.1
spry# = GetSpritePhysicsVelocityY(spr)
SetSpritePhysicsVelocity (spr, sprx#, spry#)
// Move View to x Dorection
viewX# = GetViewOffsetX ()
SetViewOffset (sprx#,0)
if SpaceKey = 0
if GetRawKeyState (32) = 1
SetPhysicsGravity (0,-150)
SpaceKey = 1
Endif
Endif
if SpaceKey = 1
if GetRawKeyState (32) = 0
SetPhysicsGravity (0,50)
SpaceKey = 0
Endif
Endif
sync ()
loop