Skip to content

Commit

Permalink
Transition Fix
Browse files Browse the repository at this point in the history
Remove offscreen Monsters during transitions.
  • Loading branch information
Arkia committed Sep 29, 2021
1 parent 2c53751 commit ba6e6aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Engine/GameModes/Level.asm
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ Level_TransitionUp:
ld a,[Engine_CameraY]
sub SCRN_Y/16
ld [Engine_CameraY],a
call TransitionUpdateMonsters
call BeginSprites
call DrawPlayer
call RenderMonsters
Expand Down Expand Up @@ -570,6 +571,7 @@ Level_TransitionDown:
ld a,[Engine_CameraY]
add SCRN_Y/16
ld [Engine_CameraY],a
call TransitionUpdateMonsters
call BeginSprites
call DrawPlayer
call RenderMonsters
Expand Down
30 changes: 27 additions & 3 deletions Engine/Object.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
; Object System
; ==============

; TODO
; - Object Behaviors

section "Object Memory",wram0

MONSTER_COUNT equ 16 ; maximum number of monster slots
Expand Down Expand Up @@ -1508,6 +1505,33 @@ UpdateMonsters:
ld [Engine_CurrentScreen],a
ret
TransitionUpdateMonsters:
ld b,0
ld c,MONSTER_COUNT-1
ld a,[Engine_CameraY]
ld d,a
.updateLoop:
ld hl,Monster_ID
add hl,bc
ld a,[hl]
or a
jr z,.nextMonster
ld hl,Monster_YPosition
add hl,bc
ld a,[hl]
cp d
jr c,.removeMonster
sub SCRN_Y
cp d
jr c,.nextMonster
.removeMonster:
call DeleteMonster
.nextMonster:
dec c
bit 7,c
jr nz,.updateLoop
ret
; Update Monster animations
AnimateMonsters:
ld b,0
Expand Down

0 comments on commit ba6e6aa

Please sign in to comment.