Fire: Difference between revisions
Content added Content deleted
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
Line 15: | Line 15: | ||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
! Address !! Length !! [[Data types|Type]] !! Description |
! Address !! Length !! [[Data types|Type]] !! Name !! Description |
||
|- |
|- |
||
| $00 || 2 || int16 || X position |
| $00 || 2 || int16 || x || X position |
||
|- |
|- |
||
| $02 || 2 || int16 || Y position |
| $02 || 2 || int16 || y || Y position |
||
|- |
|- |
||
| $04 || 2 || uint16 || Extra data (unused) |
| $04 || 2 || uint16 || extra || Extra data (unused) |
||
|- |
|- |
||
| $06 || 2 || uint16 || Victim/one-shot monster index |
| $06 || 2 || uint16 || index || Victim/one-shot monster index |
||
|} |
|} |
||
Line 30: | Line 30: | ||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
! Address !! Length !! [[Data types|Type]] !! Description |
! Address !! Length !! [[Data types|Type]] !! Name !! Description |
||
|- |
|- |
||
| $08 || 2 || pointer16 || Pointer to sprite |
| $08 || 2 || pointer16 || sprite || Pointer to sprite |
||
|- |
|- |
||
| $0A || 2 || uint16 || Current animation frame |
| $0A || 2 || uint16 || animationFrame || Current animation frame |
||
|- |
|- |
||
| $0C || 2 || int16 0-based || Number of 2 frame cycles until next animation frame |
| $0C || 2 || int16 0-based || cyclesUntilAnimUpdate || Number of 2 frame cycles until next animation frame |
||
|- |
|- |
||
| $0E || 2 || unused || Unused |
| $0E || 2 || unused || || Unused |
||
|- |
|- |
||
| $10 || 2 || int16 0-based || Health |
| $10 || 2 || int16 0-based || health || Health |
||
|- |
|- |
||
| $12 || 2 || int16 || X position |
| $12 || 2 || int16 || x || X position |
||
|- |
|- |
||
| $14 || 2 || int16 || Y position |
| $14 || 2 || int16 || y || Y position |
||
|- |
|- |
||
| $16 || 2 || sprite type || Type of sprite collided with |
| $16 || 2 || sprite type || collidedSpriteType || Type of sprite collided with |
||
|} |
|} |
||
== Psuedocode == |
|||
main() { |
|||
{{RAM name|$7E:00DE}} += 8 |
|||
this.init() |
|||
this.health = 5 |
|||
{{ROM name|$80:8475}}(this.collisionHandler) |
|||
while (this.collidedSpriteType == 0 or (this.collidedSpriteType != OFF_SCREEN and this.health >= 0)) { |
|||
this.collidedSpriteType = 0 |
|||
{{ROM name|$80:8353}}(2) |
|||
this.cyclesUntilAnimUpdate -= 1 |
|||
if (this.cyclesUntilAnimUpdate < 0) { |
|||
this.cyclesUntilAnimUpdate = 2 |
|||
this.animationFrame = (animationFrame + 1) % 4 |
|||
this.sprite.tileData.lowBytes = this.animation[this.animationFrame] |
|||
this.sprite.tileData.bank = 0x8F |
|||
this.sprite.type = spriteTypes[this.animationFrame & 3] |
|||
} |
|||
} |
|||
if (this.collidedSpriteType != OFF_SCREEN && args.index != 0) { |
|||
{{ROM name|$81:8191}}(args.index) |
|||
} |
|||
{{RAM name|$7E:00DE}} -= 8 |
|||
while ({{RAM name|$7E:00DE}} < 0) { } |
|||
{{ROM name|$80:BE41}}(this.sprite) |
|||
} |
|||
animation = { 0xD526, 0xD537, 0xD548, 0xD559 } |
|||
spriteTypes = { 2, 3, 3, 3 } |
|||
init() { |
|||
this.sprite = {{ROM name|$80:BE0C}}() |
|||
this.sprite.x = args.x |
|||
this.x = args.x |
|||
this.sprite.z = 0 |
|||
this.sprite.y = args.y |
|||
this.y = args.y |
|||
this.sprite.tileData = $8F:D526 |
|||
this.sprite.entity = {{RAM name|$7E:0008}} |
|||
this.sprite.type = 3 |
|||
this.sprite.visible = true |
|||
this.animationFrame = 0 |
|||
this.collidedSpriteType = 0 |
|||
this.cyclesUntilAnimUpdate = 2 |
|||
} |
|||
collisionHandler(spriteType) { |
|||
this.collidedSpriteType = spriteType |
|||
weaponType = spriteType & 0x7FFF |
|||
if (weaponType == FIRE_EXTINGUISHER or |
|||
weaponType == SODA_POP_CANS or |
|||
weaponType == SQUIRT_GUN or |
|||
weaponType == 0x65) { |
|||
this.health -= 1 |
|||
return true |
|||
} |
|||
if (weaponType == OFF_SCREEN) { |
|||
return true |
|||
} |
|||
return false |
|||
} |
|||
[[Category:One-shot monster]] |
[[Category:One-shot monster]] |