Taking one example:
if KeyboardMovementTimer = 0
if JoystickDirection = JoyLEFT
if PlayerPosY > 0
colorToMove = Playfield[PlayerPosX, PlayerPosY-1]
Playfield[PlayerPosX, PlayerPosY-1] = 0
Playfield[PlayerPosX, PlayerPosY] = colorToMove
KeyboardMovementTimer = 3
PlayfieldChangedSoDrawIt = TRUE
PlaySound(1)
endif
elseif JoystickDirection = JoyRIGHT
if PlayerPosY < 6
colorToMove = Playfield[PlayerPosX, PlayerPosY+1]
Playfield[PlayerPosX, PlayerPosY+1] = 0
Playfield[PlayerPosX, PlayerPosY] = colorToMove
KeyboardMovementTimer = 3
PlayfieldChangedSoDrawIt = TRUE
PlaySound(1)
endif
elseif JoystickDirection = JoyUP
if PlayerPosX > 0
colorToMove = Playfield[PlayerPosX-1, PlayerPosY]
Playfield[PlayerPosX-1, PlayerPosY] = 0
Playfield[PlayerPosX, PlayerPosY] = colorToMove
KeyboardMovementTimer = 3
PlayfieldChangedSoDrawIt = TRUE
PlaySound(1)
endif
elseif JoystickDirection = JoyDOWN
if PlayerPosX < 6
colorToMove = Playfield[PlayerPosX+1, PlayerPosY]
Playfield[PlayerPosX+1, PlayerPosY] = 0
Playfield[PlayerPosX, PlayerPosY] = colorToMove
KeyboardMovementTimer = 3
PlayfieldChangedSoDrawIt = TRUE
PlaySound(1)
endif
endif
else
dec KeyboardMovementTimer, 1
endif
Replace the If/ElseIf/ElseIf.... with a Select/Case construct.
Place them in the order that the player is most likely to use them in.
I assume this code runs every cycle. At 60FPS you are running 60 instances of sound 1 per second while they are using the joystick. The sound is 400 milliseconds long, therefore you are running 25 instances of this one sound concurrently!
Use GetSoundsPlaying() and only play it again if it returns 0.
There's many instances of For loops where you run the same calculation every loop. Precalculate it once before the loops starts into a temporary variable.
This list isn't exhaustive, it's just a couple of tips I saw at a glance.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt