Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Turn based strategy game  (Read 1323 times)
0 Members and 1 Guest are viewing this topic.
Offline Popov

Junior Newbie





« Posted 2007-09-18 15:59:29 »

Hello,
To begin, excuse my not so perfect english.
I'm planning to create a turn based stategy game, and I'd like to know the structure you could advise me to use.
I know the Model-View-Controller structure, but I don't know haw to implement the turn mecanism. Have I got to put a loop in the Main ? Have I just got to put a global variable Current_Player that alternate between 0 and 1 ?

The other question is to the action menu. Basically, when a player clicks on a character's tile, the action menu appears for this character, with the different choices that can be made. How do I model this action ? Do I need to create a class for each action ? Or are they just cases in a "switch" structure ?

Thanks for the help.
Offline fletchergames

Senior Member





« Reply #1 - Posted 2007-09-18 20:50:38 »

I think you're making this a bit harder than it has to be.

For the turn mechanism, I would just use the global variable, though I would probably try to make it so it's used in as few classes as possible.  Global variables are dangerous.

For the action menu, I would make each choice a different ActionListener, but you could use a switch statement in one ActionListener.  I'm assuming you're using Awt or Swing to make the menu itself.
Offline Popov

Junior Newbie





« Reply #2 - Posted 2007-09-18 21:50:51 »

Yes, I will use Swing, since it's the one I know the best.

So, if I understand the trick, I just put a global variable that is put to Player_One or Player_Two when the player hits the "End of Turn" Button ? Then, when a player clicks on a character, according to the global variable, the effect is either to call ViewStats actio listener, or to call ActionMenu action listener ? Am I in the good way ?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JAW

Senior Member


Medals: 2



« Reply #3 - Posted 2007-09-19 15:18:38 »

I think there can be a great difference when talking about "turn based".

A usual turn based game will be similar to a realtime game having a game loop than runs over and over. You will have a state machine or something like that where you know what to do right now. A realtime game also needs states like "pause", "show options menu" or "ingame story sequence".

The other thing is event driven gameplay. Only on certain events, the display changes. This might work for card games and easy stuff. When you press a button, something changes, end. Then wait for the next input. But after all, you will pretty soon end up using a state machine here as well to keep track of what to do in which state with which input.

My first idea here is to keep a list of players and just set the next player in list to be active. The player type will then decide whether this is a human player and the game will wait for input or if this is an AI player and call some algorithm to make decisions.

-JAW
Offline fletchergames

Senior Member





« Reply #4 - Posted 2007-09-19 18:49:24 »

Yes, I will use Swing, since it's the one I know the best.

So, if I understand the trick, I just put a global variable that is put to Player_One or Player_Two when the player hits the "End of Turn" Button ? Then, when a player clicks on a character, according to the global variable, the effect is either to call ViewStats actio listener, or to call ActionMenu action listener ? Am I in the good way ?
That should work.

It seems like you already decided what to do and just asked someone to verify it.
Offline Popov

Junior Newbie





« Reply #5 - Posted 2007-09-19 20:23:07 »

Oh non, I'm far from a genius programmer, and this is the first game I write. So all advice is welcome, and if someone tells me my plans are wrong, I'll just change my mind, if he has enough explanations.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (6 views)
2014-07-29 18:09:19

Riven (4 views)
2014-07-29 18:08:52

Dwinin (7 views)
2014-07-29 10:59:34

E.R. Fleming (23 views)
2014-07-29 03:07:13

E.R. Fleming (9 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!