Added player constructor
- Fixed horizontal object clipping
This commit is contained in:
parent
1f4051b9db
commit
22ebc76c61
|
@ -23,6 +23,10 @@ beginGameplay:
|
|||
jsr compileTerrain
|
||||
jsr clipTerrain
|
||||
|
||||
; Create players
|
||||
lda #600
|
||||
jsr playerCreate
|
||||
|
||||
ldy #0
|
||||
jsr renderPlayerHeader
|
||||
|
||||
|
@ -86,6 +90,9 @@ scrollMap:
|
|||
sta mapScrollPos
|
||||
asl
|
||||
sta leftScreenEdge
|
||||
clc
|
||||
adc #160-GAMEOBJECTWIDTH/4
|
||||
sta rightScreenEdge
|
||||
|
||||
jsr clipTerrain
|
||||
lda #$ffff
|
||||
|
@ -143,8 +150,11 @@ activePlayer:
|
|||
|
||||
; Position of map viewing window. Can be visualized in two ways:
|
||||
; a) Word-distance from right edge of terrain data (which is in memory right-to-left) to left edge of visible screen
|
||||
; b) Word-distance from left edge of logical terrain to left edge of visible screen
|
||||
; b) Byte-distance from left edge of logical terrain to left edge of visible screen
|
||||
; c) Byte-distance from left edge of logical terrain to right edge of visible screen minus game object width in words
|
||||
mapScrollPos:
|
||||
.word 0
|
||||
leftScreenEdge:
|
||||
.word 0 ; In pixels
|
||||
.word 0
|
||||
rightScreenEdge:
|
||||
.word 160-GAMEOBJECTWIDTH/4
|
||||
|
|
50
gameobject.s
50
gameobject.s
|
@ -8,17 +8,49 @@
|
|||
GAMEOBJECTWIDTH = 8
|
||||
GAMEOBJECTHEIGHT = 8
|
||||
|
||||
|
||||
gameobjectData:
|
||||
.word 40 ; X pos in pixels (from left terrain edge)
|
||||
.word 38 ; Y pos in pixels (from bottom terrain edge)
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
||||
; Base class sample:
|
||||
;gameobjectData:
|
||||
; .word 40 ; X pos in pixels (from right terrain edge)
|
||||
; .word 38 ; Y pos in pixels (from bottom terrain edge)
|
||||
; .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
||||
|
||||
GO_POSX = 0 ; Byte offsets into gameobject data structure
|
||||
GO_POSY = 2
|
||||
GO_BACKGROUND = 4
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; placeGameObjectOnTerrain
|
||||
;
|
||||
; PARAML0 = Pointer to gameobject data
|
||||
; Trashes SCRATCHL
|
||||
;
|
||||
placeGameObjectOnTerrain:
|
||||
SAVE_AY
|
||||
|
||||
ldy #GO_POSX
|
||||
lda (PARAML0),y
|
||||
clc ; Map into reversed terrain X space
|
||||
adc #GAMEOBJECTWIDTH
|
||||
sta SCRATCHL
|
||||
lda #TERRAINWIDTH
|
||||
sec
|
||||
sbc SCRATCHL
|
||||
|
||||
lsr ; Convert to bytes and force even
|
||||
and #$fffe
|
||||
tay
|
||||
lda terrainData,y
|
||||
|
||||
clc
|
||||
adc #GAMEOBJECTHEIGHT
|
||||
ldy #GO_POSY
|
||||
sta (PARAML0),y
|
||||
|
||||
RESTORE_AY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; RENDER_GAMEOBJECT
|
||||
;
|
||||
|
@ -35,11 +67,13 @@ GO_BACKGROUND = 4
|
|||
; X
|
||||
lda ptr+GO_POSX,y
|
||||
lsr
|
||||
sec
|
||||
sbc leftScreenEdge
|
||||
cmp leftScreenEdge
|
||||
bmi renderGameobjectSkip ; Gameobject is off left edge of screen
|
||||
cmp #320 - GAMEOBJECTWIDTH
|
||||
cmp rightScreenEdge
|
||||
bpl renderGameobjectSkip ; Gameobject is off right edge of screen
|
||||
|
||||
sec ; Convert byte x-pos to screenspace
|
||||
sbc leftScreenEdge
|
||||
sta SCRATCHL
|
||||
|
||||
; Y
|
||||
|
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
16
player.s
16
player.s
|
@ -8,8 +8,8 @@
|
|||
|
||||
playerData:
|
||||
; gameobject data
|
||||
.word 40 ; X pos in pixels (from left terrain edge)
|
||||
.word 38 ; Y pos in pixels (from bottom terrain edge)
|
||||
.word 0 ; X pos in pixels (from left terrain edge)
|
||||
.word 0 ; Y pos in pixels (from bottom terrain edge)
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
||||
|
||||
.word 45 ; Angle in degrees from +X
|
||||
|
@ -27,6 +27,18 @@ PD_POWER = 38
|
|||
.endmacro
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; playerCreate
|
||||
;
|
||||
; A = Player X pos
|
||||
;
|
||||
playerCreate:
|
||||
sta playerData+GO_POSX
|
||||
lda #playerData
|
||||
sta PARAML0
|
||||
jsr placeGameObjectOnTerrain
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; playerDeltaAngle
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue