I did something similar to this for my silly UAG Drumpf game. In the main loop, I have a subroutine that checks the level data. In the level data, I have Boolean variables for each enemy. The main loop has subroutines that are called when an enemy's Boolean variable equals true (in my game 1=true, 0=false). This subroutine contains the data that controls the enemy's behavior (or the lack thereof).
Some people may not like it, but I use GOTO and GOSUB in my stuff. :/
Spawn multiple actors with the same base code
Root / Programming Questions / [.]
Autz64Created:
I have a vague idea of how to have multiple actors with the same code as base. But i'm looking for better ideas to accomplish this.
Here's an vague example i think of:
ACLS LOAD "ENEMY" 'Base program file' GOAL=20 PLAYERID=1 FOR i=0 TO GOAL SPSET 0,0,32,32,1 OUT ENEMYID 'SPSET (4). See Instruction List' CALL "ENEMY_CHASE" PLAYERID, ENEMYID NEXT
I did something similar to this for my silly UAG Drumpf game. In the main loop, I have a subroutine that checks the level data. In the level data, I have Boolean variables for each enemy. The main loop has subroutines that are called when an enemy's Boolean variable equals true (in my game 1=true, 0=false). This subroutine contains the data that controls the enemy's behavior (or the lack thereof). Some people may not like it, but I use GOTO and GOSUB in my stuff. :/Nice example. And BTW, some people don't like GOTO statements because it tends to create "Spaghetti Code" and make it undebuggable for foreign people. But that's just down to personal preferences.
It sounds like you may want SPFUNC
Assigns a process to a sprite - An instruction for advanced users that is used when callback processing is required - All sprite processes are executed with CALL sprite - Instead of @Label, a user process defined using DEF can also be specified - At the processing target, the management number can be obtained using the CALLIDX system variable - If used before SPSET, an error will occur SPFUNC Management number, @Label
- Management number: Management number of the target sprite: 0-511
- @Label: Label of the processing target (or a user-defined process) to be called
SPFUNC 24, UPDATEWEEABOO DEF UPDATEWEEABOO SPOFS CALLIDX,WEEBX,WEEBY END CALL SPRITE 'then calls all functions attached to sprites with SPFUNC for all IDsIf I'm to understand it correctly, anyhow.
It sounds like you may want SPFUNCVery convenient indeed. I'm starting to think about printing the Instruction List so i wouldn't have to check the PC over and over and over, and more when the 3DS battery won't last long.SPFUNC 24, UPDATEWEEABOO DEF UPDATEWEEABOO SPOFS CALLIDX,WEEBX,WEEBY END CALL SPRITE 'then calls all functions attached to sprites with SPFUNC for all IDsIf I'm to understand it correctly, anyhow.
You can write a command and press the (?) button for checking snytax, overview and examplesIt sounds like you may want SPFUNCVery convenient indeed. I'm starting to think about printing the Instruction List so i wouldn't have to check the PC over and over and over, and more when the 3DS battery won't last long.SPFUNC 24, UPDATEWEEABOO DEF UPDATEWEEABOO SPOFS CALLIDX,WEEBX,WEEBY END CALL SPRITE 'then calls all functions attached to sprites with SPFUNC for all IDsIf I'm to understand it correctly, anyhow.