Language…
18 users online: Alex No, ben15420, DanMario24YT, gcrackaaa, GiraffeKiller, Gmario37, Gorry, Green, Hidincuzimsmokin, JudithPrietht, Metal-Yoshi94, MorrieTheMagpie, rafaelfutbal, Ray Hamilton, ShoopDaWhoop, Sniwott, VoidCrypt, wayht - Guests: 289 - Bots: 457
Users: 64,795 (2,371 active)
Latest user: mathew

Spawn the number of projectiles

(I CAN'T BUMP)

Everyone knows that to spawn a sprite, the hint is:

Code
;Routine that spawns a normal or custom sprite with initial speed at the position (+offset)
;of the calling sprite and returns the sprite index in Y

;Input:  A   = number of sprite to spawn
;        C   = Carry/Custom (CLC = CLear Custom, SEC = SEt Custom :P)
;        $00 = x offset  \
;        $01 = y offset  | you could also just ignore these and set them later
;        $02 = x speed   | using the returned Y.
;        $03 = y speed   /


or perhaps:

Code
STZ $00
STZ $01
STZ $02
STZ $03
LDA #$01
SEC
%SpawnSprite()


Now i need to do how to spawn a number of projectiles.
I bet that must be the this:

Code
LDY #$01


The code above must be the number of sprites. Am i correct?
If not, how must be the code?


I assume you were referring to the "LDA #$01" line, not "LDY #$01". In which case it is referring to the ID of the sprite to spawn, not the count. If you want to spawn multiple sprites, just enclose that code in a loop and call it multiple times.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Originally posted by Thomas
I assume you were referring to the "LDA #$01" line, not "LDY #$01". In which case it is referring to the ID of the sprite to spawn, not the count. If you want to spawn multiple sprites, just enclose that code in a loop and call it multiple times.


I'll tell you two examples:





I'm talking about the LDY, not LDA.
I hope you understand this.

Tell me what i must do to spawn multiple sprites.
There are two ways to spawn sprites: Inlined or within a loop. The latter is where you confusion stems: LDY #$01 in Mega Goomba has got two purposes: It functions both, as a loop counter and as an index to tables (in this case, the offsets and speed). This is independent to %SpawnSprite() as it doesn't use Y as an input (it does output Y, though, so you might want to preserve it the values it has loaded). Heck, Mega Goomba doesn't use %SpawnSprite() and still uses LDY #$01!
Originally posted by MarioFanGamer
There are two ways to spawn sprites: Inlined or within a loop.


Can you explain the Inlined and within a loop?
Inlined is something like this:

Code
;Routine that spawns a normal or custom sprite with initial speed at the position (+offset)
;of the calling sprite and returns the sprite index in Y

;Input:  A   = number of sprite to spawn
;        C   = Carry/Custom (CLC = CLear Custom, SEC = SEt Custom :P)
;        $00 = x offset  \
;        $01 = y offset  | you could also just ignore these and set them later
;        $02 = x speed   | using the returned Y.
;        $03 = y speed   /


Can you explain the "within a loop" logic?


Those terms have no relation to the %SpawnSprite() call. Inlined just means that you basically rewrite the code multiple times to spawn each sprite, while in a loop means you write a code to spawn a single sprite and then run that multiple times. Typically, spawning sprites in a loop is better due to being more space-efficient, but if the sprites you are spawning need to be handled in significantly different ways then inlining can be easier.

Both those codes you posted are using the loop method, and the value in the LDY lines you highlighted do indeed define the number of sprites to spawn. Some sprites may handle things differently though, it is largely up to the coder to decide the best way to handle things as there is no standard method.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer