Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (537)
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  
  simple mvc starter  (Read 964 times)
0 Members and 1 Guest are viewing this topic.
Offline ferens

Junior Newbie





« Posted 2007-12-17 19:13:28 »

I've spent the evening creating a small boardgame for my little kid to play around with.
(used to do that using pygame back in the days when there was something called sparetime)

Anyway, I got stuck totally when it came to moving around the litlle pieces on the board. I couldn't figure out how to design it correctly. Sure my mouseclicks fetched the little piece i was clicking at, but that piece could not report to its parent JPanels parent JFrame who had a textfield for  in game messages. (for example)

So - the design was of course terrible. Are there any nice small, functional starters to dive into and get it right from the beginning?

Regards
Offline Jackal von ÖRF

Junior Member





« Reply #1 - Posted 2007-12-18 15:11:59 »

It would be easier to help if you would show your code or at least explain in more detail how your program architecture is now.

Offline ferens

Junior Newbie





« Reply #2 - Posted 2007-12-18 16:32:43 »

I realize that, sorry. My code is a mess right now so the plan is to start over and try to get it right.

First I must look around the web and try to get a very basic example so I can get it right though. I'm confused how to handle the events in a nice way,I always want a textfield to catch the events when developing so I can see that it will work the way I wont it to.

In my terrible design, there were no way to accomplish that, I guess I better learn more about catching the events Wink


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #3 - Posted 2007-12-18 19:22:42 »

There are lots, here is one: http://www.csis.pace.edu/~bergin/mvc/mvcgui.html

Basically, divide your code into model + view classes. The model classes hold your actual data. The view classes reference the models and manipulate them control functionality. For simplicity sake, just place your controller (e.g. action listeners) into your view classes...

Offline ferens

Junior Newbie





« Reply #4 - Posted 2007-12-18 20:01:21 »

Thank you, but having the view as the controller was exactly what i did. It didn't work to well, but I guess it's cause I made it a lot more complicated then it had to be.

I'll take a look that example, thank you
Offline Mr_Light

Senior Member




shiny.


« Reply #5 - Posted 2007-12-19 01:35:08 »

I think the problem is having differend perspectives you have the component state (if a piece is picked up) and the game state The component (model+view+controller) can be the view of your 'Model view controller'-bit of your game.

I think reading about the composite pattern might open up the way to some solutions.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
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.

CogWheelz (16 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (18 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

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

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

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

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

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

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

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

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

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
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!