Jump to content
  • Advertisement
  • entries
  • comments
  • views

A C64 game - Step 7

Sign in to follow this  


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:


          !byte 0
          !byte 8,7,5,3,2,1,1,1,0,0
          !byte 0
          !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:


          inc PLAYER_JUMP_POS
          lda PLAYER_JUMP_POS
          cmp #JUMP_TABLE_SIZE
          bne .JumpOn
          lda #0
          sta PLAYER_JUMP_POS
          jmp .JumpComplete
          ldx PLAYER_JUMP_POS
          lda PLAYER_JUMP_TABLE,x
          beq .JumpComplete
          sta PARAM5
          jsr PlayerMoveUp
          beq .JumpBlocked
          dec PARAM5
          bne .JumpContinue
          jmp .JumpComplete
          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.

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


Previous Step 6 Next Step 8


Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!