Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (781)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
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 2076 times)
0 Members and 1 Guest are viewing this topic.
Offline ferens

Junior Newbie

« Posted 2007-12-17 18: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?

Offline Jackal von ÖRF

Junior Devvie

« Reply #1 - Posted 2007-12-18 14: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 15: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 Spiffy Duke »

Medals: 35
Projects: 11

Age of Conquest makes your day!

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

There are lots, here is one:

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 19: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 Devvie

Medals: 1


« Reply #5 - Posted 2007-12-19 00: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  

hadezbladez (1177 views)
2018-11-16 13:46:03

hadezbladez (531 views)
2018-11-16 13:41:33

hadezbladez (1188 views)
2018-11-16 13:35:35

hadezbladez (274 views)
2018-11-16 13:32:03

EgonOlsen (2571 views)
2018-06-10 19:43:48

EgonOlsen (2790 views)
2018-06-10 19:43:44

EgonOlsen (1566 views)
2018-06-10 19:43:20

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

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

nelsongames (2817 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 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!