Big player

This commit is contained in:
2026-02-17 09:26:32 -05:00
parent e992cd6ae2
commit 2eb3aec80e
2 changed files with 55 additions and 31 deletions

86
plat.s
View File

@@ -335,7 +335,7 @@ level:
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0
.byte 0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0
@@ -362,8 +362,10 @@ example_palette:
.segment "ZEROPAGE"
buttons: .res 1
vel_x: .res 1
vel_y: .res 1
player_pos_x: .res 1
player_pos_y: .res 1
player_vel_x: .res 1
player_vel_y: .res 1
cursor_x: .res 1
cursor_y: .res 1
@@ -411,10 +413,32 @@ main:
@draw:
jsr update_background
jsr draw_player
jsr ppu_update
jmp @loop
draw_player:
lda player_pos_y
sec
sbc #1
sta oam + (4 * 2) + 0
sta oam + (4 * 3) + 0
sec
sbc #8
sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0
lda player_pos_x
sta oam + (4 * 1) + 3
sta oam + (4 * 3) + 3
sec
sbc #8
sta oam + (4 * 0) + 3
sta oam + (4 * 2) + 3
rts
init_objects:
lda #0
sta var_n
@@ -425,8 +449,8 @@ init_objects:
adc #8
sta var_n
sta oam+0, X ; Set Y position
sta oam+3, X ; Set X position
sta player_pos_y, X ; Set Y position
sta player_pos_x, X ; Set X position
txa
lsr
@@ -441,8 +465,8 @@ init_objects:
bne :-
lda #0
sta vel_x
sta vel_y
sta player_vel_x
sta player_vel_y
rts
@@ -458,7 +482,7 @@ movement:
beq :+
ldx #1
lda #3
sta vel_x
sta player_vel_x
:
jsr btn_left
@@ -466,7 +490,7 @@ movement:
beq :+
ldx #1
lda #253
sta vel_x
sta player_vel_x
:
cpx #1
@@ -477,20 +501,20 @@ movement:
bne @end
lda #0
cmp vel_x
beq @end ; If vel_x = 0, skip decay
cmp player_vel_x
beq @end ; If player_vel_x = 0, skip decay
; If vel_x > 0, decrement
; If player_vel_x > 0, decrement
bpl :+
ldx vel_x
ldx player_vel_x
dex
stx vel_x
stx player_vel_x
jmp @end
:
; Else if vel_x < 0, increment
ldx vel_x
; Else if player_vel_x < 0, increment
ldx player_vel_x
inx
stx vel_x
stx player_vel_x
@end:
; Jump
@@ -503,7 +527,7 @@ movement:
; Jump newly pressed this frame
lda #250
sta vel_y
sta player_vel_y
@fail_jump:
@@ -516,42 +540,42 @@ movement:
and #1
cmp #0
bne :+
lda vel_y
lda player_vel_y
clc
adc #1 ; Add 2 to velocity
sta vel_y
sta player_vel_y
:
; Apply Y velocity
lda oam+0
lda player_pos_y
clc
adc vel_y
sta oam+0
adc player_vel_y
sta player_pos_y
; Keep grounded
cmp #200
bcc :+
lda #0
sta vel_y
sta player_vel_y
lda #200
sta oam+0
sta player_pos_y
:
; Bonk
lda #8
cmp oam+0
cmp player_pos_y
bcc :+
lda #0
sta vel_y
sta player_vel_y
lda #8
sta oam+0
sta player_pos_y
:
; Apply X velocity
lda oam+3
lda player_pos_x
clc
adc vel_x
sta oam+3
adc player_vel_x
sta player_pos_x
rts