Turn Order

Hello there!!

I am working on a tactical turn based rpg, a big part of turn based games are the the turns themselves and I am slightly struggling with figuring out how to write the code for it. A simple back and forth between player and singular enemy wont work here because my game has multiple characters and enemies playing at the same time.

Any help would be appreciated

It sounds like you're trying to write a scheduler that will give each sprite a turn. But Snap! already has such a scheduler! Just give each sprite each own script
untitled script pic (1)
where the cyan and blue blocks are things you write for the particular situation in your game.

If you have more than one human being playing at once, use different sets of keyboard characters for each. One gets the arrow keys, one gets WASD, or whatever.

this doesnt work at all for the style of game im making as turn order manipulation is also a mechanic based on the character or enemies speed stat, and its a single player game, just you have a team of characters you play as

Brian isn't actually wrong though, the only step you need to add to his general example is where you do the math to calculate that order and then set it to a list that then gets executed as a turn. (I'm making it sound far simpler than it is mind you)

Is it old-school Final Fantasy or is it X-Com style? Technically the distinction doesn't matter, but it might get you thinking when to implement the math (Maybe)

xcom style, and yeh as ive been looking into it technically its right. I just need to figure out how to reshape the list dictating turn order by their speed values xd

ok I actually just got it figured out, through trial and error

Maybe something like
[scratchblocks] Wait Until (Math) is Done
Set {execute turn} to < Order List> [/scratchblocks]

[scratchblocks] Wait Until (Math) is Done [/scratchblocks ] Is how I did that, just drop the space in the last scratchblocks, there's no real code embedded in it. I'm good at the ideas, bad at the doing lol

Nice. Well done. (Edited as you solved it while I was writing that)

Fine, so the "take one turn" has to deal with speed. Say the fastest character class moves once per display cycle and you're working on a character class whose speed is 1/3 of that. So its one-turn script says

untitled script pic

and for a character whose speed is 2/3 that of the fastest character it's

untitled script pic (1)

If the ordering is more complicated than that, then yeah, as @callietastrophic says, you have to keep a list of sprites and reorder it as appropriate, and instead of a REPEAT UNTIL script you have a WHEN I RECEIVE [YOUR TURN] script.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.