#1✎ 11ninja12Night PersonI like the quiet night and sleep late.Express YourselfDrawingI like to draw!HobbiesVideo GamesI like to play video games!HobbiesHi I need help adding an multiple spawned enemies to have there sprite hitbox when attacking player. The hitbox would only last a second clearing itself. Thanks
Posted
Edited
by ninja12
#2✎ 1560randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteI’m not sure exactly what you’re asking for.
Posted
#3✎ 11ninja12Night PersonI like the quiet night and sleep late.Express YourselfDrawingI like to draw!HobbiesVideo GamesI like to play video games!HobbiesHi, well I have multiple enemies on screen lets say 3 enemies. I chose a spdef to spawn to indicate an attack hitbox sprite. It works with sprite id I give, but if 2 characters are attacking at the same time it doesn't spawn their own copy of the hitbox sprite even with "spset id out" is set.
Right now I have all the characters spawning that same sprite id.
Another example is have multiple enemies shoot the same projectile sprite at the same time.
The enemies are being ran by spfunc. Thanks
Posted
Edited
by ninja12
#4✎ 1560randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteWhat it seems like you’re saying is that whenever a new sprite is created, it uses the same sprite id. But you can only have one sprite with a specific id. So you have SPSET ID,IMG. You have to change ID for every sprite. IMG can stay the same but if ID is reused it will delete the previous sprite that had that id.
But SPSET has multiple ways it can be used. The one I think you’d need is SPSET R1,R2,IMG OUT ID. R1 is the lowest ID can be, and R2 is the highest. IMG is what the sprite should look like and ID is a variable that gets set to whatever ID the function chooses for you.
This allows you to select a range of different IDs, say 0-31 for example, and it’ll pick one for you. That way you can set sprites with the same “settings” but a different ID so it doesn’t remove other sprites. Example:
WHILE 1
VSYNC
CALL SPRITE
SPAWN
WEND
DEF SPAWN'Spawns a sprite
VAR ID
SPSET 0,31,0 OUT ID
IF ID==-1 THEN RETURN'This function returns -1 if every sprite in the range is already being used
SPOFS ID,200,120'Set initial stuff for the sprite, in this case the position
'Store position with SPVAR
SPVAR ID,0,200
SPVAR ID,1,120
SPFUNC ID,MOVE'Don’t forget SPFUNC
END
DEF MOVE'Doesn't actually move things lol
'Do your logic here
X=SPVAR(CALLIDX,0)
Y=SPVAR(CALLIDX,1)
'Changing the sprite’s position
SPOFS CALLIDX,X,Y
END
Hope I didn’t just confuse you. If you have questions, let me know.
Posted
Edited
by rando
#5✎ 11ninja12Night PersonI like the quiet night and sleep late.Express YourselfDrawingI like to draw!HobbiesVideo GamesI like to play video games!HobbiesThanks rando, I was heading in this direction.
I'm not sure if this makes a difference..
I have a DEF that spawns the enemies and another "DEF Move" that does all of the enemies movements and attack. Can I call a DEF to spawn more sprites within the "DEF Move" function? In other words can spawned objects also spawn objects.
Thanks again
Posted
Edited
by ninja12
#6✎ 1560randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteYou mean like if a monster wanted to shoot a bullet? You can do that for sure. You might have to figure out how to do that, like timing and stuff, but you can definitely call a spawn function inside a movement function.
Posted
#7✎ 11ninja12Night PersonI like the quiet night and sleep late.Express YourselfDrawingI like to draw!HobbiesVideo GamesI like to play video games!HobbiesOh ok thanks
Posted