# Help with turn-based strategy game

### » Tue May 03, 2011 1:43 pm

Hi, i am working on a simple turn-based grid strategy game. I would appreciate it very much if someone could show me a example on how to make a turn-based system in which the Player and the AI takes turns in movement of it's units. Also it would be nice if someone could show me a example on how to make a system for how many grids units can move individually during it's turn. For Example, a unit has the private variable 3 moves and therefore can move 3 grids or less during it's turn. All help is much appreciated thanks in advance!
B
1
G
1
Posts: 3
Reputation: 431

### » Wed May 04, 2011 7:56 am

For taking turns, can't you just have a variable which alternates between 0 and 1? When its 0 the player gets to move, and when 1 the AI moves?

For movement, each time the turn changes each unit gets their "move" variable set to a value (3 for moving 3 grids). If a unit has more than 0 in "move", then they can be selected to move (subtract from it when moving a grid).

When all units on your side have their "move" at 0. Then change the turn variable so the other player gets to go.

Just an idea.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

### » Wed May 04, 2011 5:34 pm

[quote="alspal":3hmwia5r]For taking turns, can't you just have a variable which alternates between 0 and 1? When its 0 the player gets to move, and when 1 the AI moves?

For movement, each time the turn changes each unit gets their "move" variable set to a value (3 for moving 3 grids). If a unit has more than 0 in "move", then they can be selected to move (subtract from it when moving a grid).

When all units on your side have their "move" at 0. Then change the turn variable so the other player gets to go.

Just an idea.[/quote:3hmwia5r]

Yeah that is very good ideas, thanks a lot! I basically did what you said but can't figure out how to get it to register my movements correctly. For example i set the events to remove 1 point from move each time a unit moved. However it did not work, the unit just got stuck between two grids. I suppose its because the "Is moving" event doesn't register each grid as 64x64. It just detects that the unit moved and therefore subtracts from the "move" value. Any idea how to work around this? Thanks in advance.
B
1
G
1
Posts: 3
Reputation: 431

### » Thu May 05, 2011 3:32 am

Are you doing it manually? like:

When Right Press -> move 1 horizontally, subtract 1 from move?.

Just using "is moving" won't be enough to tell how many grids the sprite has moved.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

### » Thu May 05, 2011 7:09 am

[quote="alspal":kpkd1l2r]Are you doing it manually? like:

When Right Press -> move 1 horizontally, subtract 1 from move?.

Just using "is moving" won't be enough to tell how many grids the sprite has moved.[/quote:kpkd1l2r]

hmmmm.. i was hoping for a solution that could tell that it just moved 64x64 no matter of direction. But i guess its a solution to make it register when i press the button. I'm just a fan of keeping events to a minimum. Thanks once again!
B
1
G
1
Posts: 3
Reputation: 431

### Who is online

Users browsing this forum: No registered users and 8 guests