Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

A C64 game - Step 7

A C64 game - Step 7

Endurion
Endurion
New Old Things · · 1 min read
7,906 0

Now it's starting to resemble a game. Loosely.


In this step we add gravity and jumping. The player will fall if there is no blocking char below. On joystick up the player jumps in a curve.
Both fall speed and jump speed are non linear and based on tables.

This step shows:
-gravity (accelerating)
-jumping (following a delta y curve)

Most prominent addition are the jump and fall table. These hold the deltas we use to make the movement not look linear but somewhat naturalistic:


PLAYER_JUMP_POS
          !byte 0
PLAYER_JUMP_TABLE
          !byte 8,7,5,3,2,1,1,1,0,0
PLAYER_FALL_POS
          !byte 0
FALL_SPEED_TABLE
          !byte 1,1,2,2,3,3,3,3,3,3


The jump is only possible if the player is not falling. Once the player jumped the PLAYER_JUMP_POS is increased on every frame and the player moved upwards for entry-of-jump-table pixel. If the player is blocked moving upwards the jump is aborted:




.PlayerIsJumpinginc PLAYER_JUMP_POS
          lda PLAYER_JUMP_POS
          cmp #JUMP_TABLE_SIZE
          bne .JumpOn
          
          lda #0
          sta PLAYER_JUMP_POS
          jmp .JumpComplete
          
.JumpOn
          ldx PLAYER_JUMP_POS
          lda PLAYER_JUMP_TABLE,x
          beq .JumpComplete
          
          sta PARAM5
.JumpContinue
          jsr PlayerMoveUp
          beq .JumpBlocked
          dec PARAM5
          bne .JumpContinue
          jmp .JumpComplete
          
.JumpBlocked
          lda #0
          sta PLAYER_JUMP_POS
          jmp .JumpStopped


To check for falling an attempt is made to move the player down one pixel. If he is blocked he is standing on solid ground. If he can fall the fall counter is increased. The fall counter is increased in every frame up to the max number of entries in the fall table.

If the player is falling the player is moved down entry-of-fall-table pixel.

.PlayerFell
          ldx PLAYER_FALL_POS
          lda FALL_SPEED_TABLE,x
          beq .FallComplete
          sta PARAM5
          
.FallLoopdec PARAM5
          beq .FallComplete
          jsr PlayerMoveDown
          jmp .FallLoop
          
.FallComplete
          lda PLAYER_FALL_POS
          cmp #( FALL_TABLE_SIZE - 1 )
          beq .FallSpeedAtMax
          inc PLAYER_FALL_POS
.FallSpeedAtMax


step7.zip


Previous Step 6 Next Step 8

Discussion

Loading comments...