Hello everyone,
I've had a bash at creating a 2D GTA-1 style control method - UpKey() moves player forward, LeftKey() rotates avatar left, etc...
At the moment I'm just working on the algorythm to get the numbers correct, then I'm going to enter the sprite code. However, I can't seem to get my numbers to rotate correctly. Can anyone see what I'm doing wrong?
Thanks
Chris
REM // This is the setup phase for variables and any other startup neccessities.
sync rate 60
sync on
backdrop on
REM // Set up system variables
UpdateLoop = 0
DrawLoop = 1
EndGame = 0
REM // Set up the screen...
f_ScreenX# = Screen Width()
f_ScreenY# = Screen Height()
REM // Set up some constants
g_Pi# = 3.1415927
REM // Set up player values
iMaxNumPlayers = 8
DIM g_PlayerX(iMaxNumPlayers)
DIM g_PlayerY(iMaxNumPlayers)
DIM g_PlayerSpeed(iMaxNumPlayers)
DIM g_PlayerDirection(iMaxNumPlayers)
g_CurrentPlayer = 0
g_MaxSpeed = 4
g_MinSpeed = 0
g_PlayerX(g_CurrentPlayer) = f_ScreenX# / 2
g_PlayerY(g_CurrentPlayer) = f_ScreenY# / 2
REM // This is the beginning of the game loop.
Repeat
REM // This is the update loop.
IF UpdateLoop = 0
Repeat
IF RightKey()=1
g_PlayerDirection(g_CurrentPlayer) = g_Playerdirection(g_CurrentPlayer) + (g_Pi#/100.0)
Print "Right key pressed!"
ENDIF
IF LeftKey()=1
g_PlayerDirection(g_CurrentPlayer) = g_Playerdirection(g_CurrentPlayer) - (g_Pi#/100.0)
Print "Left key pressed!"
ENDIF
IF UpKey()=1 AND g_PlayerSpeed(g_CurrentPlayer) <= g_MaxSpeed
g_PlayerSpeed(g_CurrentPlayer) = g_PlayerSpeed(g_CurrentPlayer) + 1
Print "Up key pressed!"
ENDIF
IF DownKey()=1 AND g_PlayerSpeed(g_CurrentPlayer) >= g_MinSpeed
g_PlayerSpeed(g_CurrentPlayer) = g_PlayerSpeed(g_CurrentPlayer) - 1
Print "Down key pressed!"
ENDIF
g_PlayerX(g_CurrentPlayer) = g_PlayerX(g_CurrentPlayer) + (g_PlayerSpeed(g_CurrentPlayer) * sin(g_PlayerDirection(g_CurrentPlayer)))
g_PlayerY(g_CurrentPlayer) = g_PlayerY(g_CurrentPlayer) + (g_PlayerSpeed(g_CurrentPlayer) * cos(g_PlayerDirection(g_CurrentPlayer)))
UpdateLoop = 1
DrawLoop = 0
Until UpdateLoop = 1
ENDIF
REM // This is the draw loop.
IF DrawLoop = 0
Repeat
box g_PlayerX(g_CurrentPlayer),g_PlayerY(g_CurrentPlayer),g_PlayerX(g_CurrentPlayer) + 20,g_PlayerY(g_CurrentPlayer) + 20
Print g_PlayerX(g_CurrentPlayer)
Print g_PlayerY(g_CurrentPlayer)
Print g_PlayerSpeed(g_CurrentPlayer)
Print g_PlayerDirection(g_CurrentPlayer)
sync
DrawLoop = 1
UpdateLoop = 0
Until DrawLoop = 1
ENDIF
REM // This is the end of the game loop.
Until EndGame = 1
http://www.bizarrecreations.com