[Help]Battleship game

For questions about using Classic.

Post » Wed Dec 16, 2009 12:53 pm

Hey, Ive read both tutorials of construct but i still have one question: How do i create a turn based game? for example as simple as battleship? i have this very good game idea that was created long time ago, but was played on quadrille paper. Im now thinking of making it on construct and i intend to start as a battleship style game and work it from there.
Thanks in advance
B
1
G
3
Posts: 3
Reputation: 831

Post » Wed Dec 16, 2009 3:51 pm

What's the problem for you exactly ? :)

Turn-based game isn't much harder (or easier) to create than real-time :)
Just specify your question, please, ok? :roll:

-edit-
But I guess anyway you should try Grid Movement Behavior, maybe RTS Behavior. It can clear something.
B
3
G
3
Posts: 29
Reputation: 933

Post » Wed Dec 16, 2009 5:36 pm

well what i dont know how to do, is to make player 1 make a move, and then player 2 make a move.
can anyone add me to msn and give me some help?
cheers
B
1
G
3
Posts: 3
Reputation: 831

Post » Wed Dec 16, 2009 6:03 pm

You can do this by setting the state of the game with a variable, whether it's global or private. Restrict the movements and actions based on what the variable says.

[code:1bittg34]
+ Global('currentPlayer') = 1
-> Activate player one movements

+ Global('currentPlayer') = 2
-> Activate player two movements
[/code:1bittg34]

At the end of a turn, you switch the global variable to the next player.

If you're clever you can even control both sets of players with the same code, by marking the player pieces with variables as well. That way if global('player') is currently set to 1, for example, then clicking on player two's pieces will do nothing. And vice versa. Or whatever.

You would just need to have PV's for every player piece that can hold a 1 or 2 to distinguish which player it belongs to. You can even use the same sprites! Just have different animations in the sprite for player 1 and 2... say, one set of ships colored red in one animation, and another set of ships colored blue in another animation. Set the animation to the proper color by checking what the player PV is.

Go ahead and try it out, if you need help with it then post a .cap file showing what you've tried so far.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 16, 2009 7:03 pm

[quote="deadeye":31ighzeg]You can do this by setting the state of the game with a variable, whether it's global or private. Restrict the movements and actions based on what the variable says.

[code:31ighzeg]
+ Global('currentPlayer') = 1
-> Activate player one movements

+ Global('currentPlayer') = 2
-> Activate player two movements
[/code:31ighzeg]

At the end of a turn, you switch the global variable to the next player.

If you're clever you can even control both sets of players with the same code, by marking the player pieces with variables as well. That way if global('player') is currently set to 1, for example, then clicking on player two's pieces will do nothing. And vice versa. Or whatever.

You would just need to have PV's for every player piece that can hold a 1 or 2 to distinguish which player it belongs to. You can even use the same sprites! Just have different animations in the sprite for player 1 and 2... say, one set of ships colored red in one animation, and another set of ships colored blue in another animation. Set the animation to the proper color by checking what the player PV is.

Go ahead and try it out, if you need help with it then post a .cap file showing what you've tried so far.[/quote:31ighzeg]

Okay,thanks alot!
Im going to try that, tho after reading some, i dont think construct is the most indicated software to build this game since multiplayer would become difficult on the long run i.e. lan/online game. But still im going to see what i can do.
B
1
G
3
Posts: 3
Reputation: 831

Post » Wed Dec 16, 2009 7:25 pm

[quote="fplacido":207ncjhg]Okay,thanks alot!
Im going to try that, tho after reading some, i dont think construct is the most indicated software to build this game since multiplayer would become difficult on the long run i.e. lan/online game. But still im going to see what i can do.[/quote:207ncjhg]

Yeah, it would be kind of hard to make a networked game right now, seeing as how there is no network plugin. But just be patient... it will come eventually.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 16, 2009 8:58 pm

If it's turn-based, you can probably get away using the HTTP object and an external server as a mediator, and you could hide the lag using "lengthy" (as in: a few hundred milliseconds at least) animations.

Also, for turns you'd probably want to use the "Trigger once while true" condition. Read about it, you'll use it a lot in this scenario.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests