To start in AppGameKit, always i code a simply topdown movement game.
i read the documentation and i made this
Main.agc
#include 'Keycodes.agc'
#include 'Functions.agc'
LoadImage(001, "meh.jpg")
CreateSprite(001, 1)
SetSpriteSize(001, 100, 100)
Playerx = GetScreenWidthCenter(1280) // a function that gets the center of the screen
Playery = GetScreenHeightCenter(720) // the same function
do
SetSpritePosition(1, Playerx, Playery)
Move(Key_Right, 'Right', 10, Playerx, Playery)
Sync()
loop
Keycodes.agc
#Constant Key_Escape 27 // Tecla de escape
#Constant Key_Right 39 // Tecla de flecha derecha
#Constant Key_Left 37 // Tecla de Flecha izquierda
#Constant Key_Up 38 // Tecla de Flecha arriba
#Constant Key_Down 40 // Tecla de flecha abajo
#Constant Key_Z 90 // Tecla Z
#Constant Key_Shift 16 // Tecla Shift
#Constant Key_X 88 // Tecla X
and finally Functions.agc
#include 'Keycodes.agc'
function Move(Key, Direction as String, Speed, SpriteX, SpriteY)
if GetRawKeyState(Key)
if Direction = 'Left'
SpriteX = SpriteX - (Speed * (GetFrameTime() * 10))
elseif Direction = 'Right'
SpriteX = SpriteX + (Speed * (GetFrameTime() * 10))
elseif Direction = 'Up'
SpriteY = SpriteY - (Speed * (GetFrameTime() * 10))
else
SpriteY = SpriteY + (Speed * (GetFrameTime() * 10))
endif
endif
endfunction
i dont know why, but the sprite doesnt move.
pls, some halp
PD: Sorry for my bad english