Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  console-text-based games  (Read 2058 times)
0 Members and 1 Guest are viewing this topic.
Offline Javec

Senior Newbie

« Posted 2007-11-27 00:12:48 »

I am working on a text-based poker game.

I managed to get a working game so far.

Card, Deck, Player etc and Game classes

Basically, inside Game class, I create all objects and simulate the game play.

Now the problem is that all input/output is embeded in the code. This is a problem, as I d like to have a Model independend of view.

Whats the proper way to implement MVC with console based games? or the Game class is considered just a controller, and not part of the Model?

Offline stef569

Junior Devvie

« Reply #1 - Posted 2007-11-27 13:13:21 »

Make 3 packages

view will print messages(System.out.println) or build an entire gui. It doesn't do anything else then drawing or showing your game on the screen/console.

model does the calculation and controller sits between the two and has alot of get and setters. Like an example collection of get/setters in the controller:

Public Controller() {
fView = new view(this)
fModel = new model(this)
fView.setInsertPress(boolean press)
Offline Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #2 - Posted 2007-11-27 13:52:00 »

I find strict MVC is impractical for games, as theres a lot more overlap between model and view than there is in your typical buissiness app. Things like sprites and model geometry are both view (used for display) and model (used for collision etc.). Also, I've never heard the controller described as "has alot of get and setters".

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Markus_Persson

JGO Wizard

Medals: 19
Projects: 19

Mojang Specifications

« Reply #3 - Posted 2007-11-27 15:04:15 »

I once implemented a fairly successful MVC for a game. It took a lot of work, but it was really nice in the end.

1 GameModel, keeps track of all game state and how to save/load that state.
2 AbstractView, abstract with two subclasses
2.1 EditorView, a simplified rendering showing different layers and so
2.2 GameView, no helper stuff rendered, and full particles and so
3 AbstractController, abstract controller class
3.1 EditorController, allowed for editing the model, and added new buttons to the swing panel containing the View
3.2 GameController, reads user input from the keyboard and runs the game rules on the game model

I had a lot of trouble separating EditorController from EditorView (you could edit most of the game with the GameView, and you could play in the EditorView), but it was possible. Figuring out that both the view and the controller could add stuff to the gui was a big help.

That said, it's not really worth it.

Play Minecraft!
Pages: [1]
  ignore  |  Print  

DesertCoockie (52 views)
2018-05-13 18:23:11

nelsongames (83 views)
2018-04-24 18:15:36

nelsongames (74 views)
2018-04-24 18:14:32

ivj94 (759 views)
2018-03-24 14:47:39

ivj94 (87 views)
2018-03-24 14:46:31

ivj94 (643 views)
2018-03-24 14:43:53

Solater (102 views)
2018-03-17 05:04:08

nelsongames (184 views)
2018-03-05 17:56:34

Gornova (426 views)
2018-03-02 22:15:33

buddyBro (1086 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!