Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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 972 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?

Thanks.
Offline stef569

Junior Devvie





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

http://en.wikipedia.org/wiki/Model-view-controller

Make 3 packages
model
view
controller

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)
}
// INPUT FROM THE MODEL
fModel.getFPS()
// INPUT FROM THE VIEW
fView.setInsertPress(boolean press)
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


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


http://c2.com/cgi/wiki?MvcIsNotImplementable

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".

[ TriangularPixels.com - 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: 16
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  
 
 
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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!