LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Need helping making multiple Enemies on screen at a time.

Root / Programming Questions / [.]

Z_E_R_OCreated:
They each need an HP and attack and somehow make them different types sometimes... Any help is appreciated. I'm using smilebasic for the switch

I suppose you also posted this topic in the new SBS as well. You can assign variables and functions specific to a sprite using SPVAR and SPFUNC.
SPSET 0,0: SPOFS 0,200,125
SPVAR 0,”HEALTH”,10
SPVAR 0,”NAME”,”Strawberry”
SPFUNC 0,”TEST”

LOOP
 CALL SPRITE
 VSYNC
ENDLOOP

DEF TEST
 VAR I=CALLIDX()
 VAR HP=SPVAR(I,”HEALTH”)
 VAR NAME$=SPVAR(I,”NAME”)
 LOCATE 0,0:?NAME$+” HP:”;HP;”  “
 IF BUTTON(1,#B_RRIGHT,2) THEN BEEP 0:DEC HP
 SPVAR I,”HEALTH”,HP
END
If this works (I have not tested this), text should appear at the top of the screen with a number that decreases every time you tap the A button. The function TEST is assigned to sprite 0. The CALL SPRITE function runs through every sprite function (in this case, “TEST” is constantly called because it is assigned to the strawberry sprite). This isn’t a direct answer to your problem but I hope it can point you in the right direction.

Thank you, Instead I Used DIM/Var to make enemies have custom Vitality/Speite numbers

No problem. I’ve recently started using sprite variables myself and it makes managing many sprites so much easier

Honestly once you get the hang out it its rinse and repeat. The thing o had most trouble one was Wall Collision with enemies. It wasn't fun lol. https://www.reddit.com/r/SmileBASIC/comments/j0putt/until_then_update_demo_release_october_5th/?utm_medium=android_app&utm_source=share

Oh for sure. I’m working on a project that has background movement and attempting to move the enemy sprites with their own movement function while keeping up with the background movement all the while checking collision for all sprites was difficult to grasp. I’ve got it now though!

If you use DIM/VAR to allocate variables, remember that you need one for each sprite. You would need to either have unique variables or variables in an array. That is part of what makes using sprite variables a lot more attractive.