// Create Sprite Player = CreateSprite( LoadImage( "player.png" ) ) Do x# = GetSpriteX(Player) y# = GetSpriteY(Player) // Move Sprite To Left If GetRawKeyState ( 37 ) SetSpritePosition ( Player, GetSpriteX( Player ) - 3, GetSpriteY( Player ) + 0 ) EndIf // Move Sprite Up If GetRawKeyState ( 38 ) SetSpritePosition ( Player, GetSpriteX( Player ) + 0, GetSpriteY( Player ) - 3 ) EndIf // Move Sprite To Right If GetRawKeyState( 39 ) SetSpritePosition ( Player, GetSpriteX( Player ) + 3, GetSpriteY( Player ) + 0 ) EndIf // Move Sprite Down If GetRawKeyState ( 40 ) SetSpritePosition ( Player, GetSpriteX( Player ) + 0, GetSpriteY( Player ) + 3 ) EndIf Sync() Loop
// Create Sprite CreateSprite (1, 0) /******************************************************** GetRawKeyState should use the constants defined at http://www.appgamekit.com/documentation/guides/scancodes.htm ********************************************************/ #constant KEY_LEFT 37 #constant KEY_UP 38 #constant KEY_RIGHT 39 #constant KEY_DOWN 40 delta_x = 0 delta_y = 0 do x# = GetSpriteX(1) y# = GetSpriteY(1) if GetRawKeyState( KEY_LEFT ) // Move Sprite to Left delta_x = -2 delta_y = 0 SetSpritePosition ( 1, GetSpriteX( 1 ) + delta_x, GetSpriteY ( 1 ) + delta_y ) elseif GetRawKeyState ( KEY_UP ) // Move Sprite Up delta_x = 0 delta_y = -2 SetSpritePosition ( 1, GetSpriteX( 1 ) + delta_x, GetSpriteY ( 1 ) + delta_y ) elseif GetRawKeyState ( KEY_RIGHT ) // Move Sprite to Right delta_x = 2 delta_y = 0 SetSpritePosition ( 1, GetSpriteX( 1 ) + delta_x, GetSpriteY ( 1 ) + delta_y ) elseif GetRawKeyState ( KEY_DOWN ) // Move Sprite to Down delta_x = 0 delta_y = 2 SetSpritePosition ( 1, GetSpriteX( 1 ) + delta_x, GetSpriteY ( 1 ) + delta_y ) endif Sync() loop
rem rem AGK Application 2017.01.09 rem MR 25.01.2017 SetWindowSize(1280,720,0) SetVirtualResolution(100,100) local i as Integer Do for i=0 to 255 if GetRawKeyState(i) then print("Key "+str(i)+" State "+str(GetRawKeyState(i))) next If GetPointerPressed() exit EndIf sync() Loop end