projectile patterns

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
projectile patterns
by on (#176675)
I can't believe I haven't thought about this before, but projectile patterns can be programmed using data tables. The data tables can have information like, how many projectiles to throw at once, the x/y offset from the enemy, the speed and angle, the amount of time between projectile throws, and the looping information. This is probably old news to some people, but I've been so caught up with graphical trickery, that I haven't thought much about this.
Re: projectile patterns
by on (#176683)
psycopathicteen wrote:
I can't believe I haven't thought about this before, but projectile patterns can be programmed using data tables. The data tables can have information like, how many projectiles to throw at once, the x/y offset from the enemy, the speed and angle, the amount of time between projectile throws, and the looping information. This is probably old news to some people, but I've been so caught up with graphical trickery, that I haven't thought much about this.

  • Angles should have option of being "absolute" or "relative to 'toward-player'".
  • Offsets should likewise be able to be able to be relative, as in "X pixels in direction-fired" with possible "Y pixels perpendicular to direction fired"
  • Projectile graphic/type
    • And hitbox, if separate.
Re: projectile patterns
by on (#177086)
Here is a code I just whipped up right now. It's for the 65816 though.

Code:
projectile_patterns:
ldy {projectile_data}
lda $0000,y
bpl +
sta {projectile_data}
tay
lda $0000,y
+;
inc {projectile_timer}
cmp {projectile_timer}
beq +
rts
+;
lda $0002,y
sta {temp}

iny #4

-;

jsr look_for_open_slot
cpx #{last_object_slot}
beq dont_spawn_projectile
lda $0000,y
sta.w {object_id},x

lda {direction}
sta.w {direction},x
bne +

lda {x_position}
clc
adc $00002,y
sta.w {x_position},x
bra ++
+;
lda {x_position}
sec
sbc $0002,y
sta.w {x_position},x
+;

lda {y_position}
clc
adc $0004,y
sta.w {y_position},x

lda $0006,y
sta.w {x_speed},x
lda $0008,y
sta.w {y_velocity},x

dont_spawn_projectile:

tya
clc
adc #$000a
tay

dec {temp}
bne -

sty {projectile_data}
stz {projectile_timer}
rts