The moose likes Game Development and the fly likes Basic Java Game & Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Basic Java Game & "MVC"" Watch "Basic Java Game & "MVC"" New topic

Basic Java Game & "MVC"

Gaz Johnson

Joined: Apr 27, 2009
Posts: 22
I have been assigned a task for a university course. I would ask the tutor such questions normally but in the UK we are suffering a bit of bad weather and I can't get in. It's also a new course so i'm unsure who to email. However, my problem.....

We have been asked to code a game, which I have done. I don't know what it's called but you have a grid of symbols (in this case coins four tall, four wide). When you click one coin, it is flipped along with those to the top, bottom, left and right. If anyone of familiar with the electronic toy "Lights out" from a few years back, its like that. The game ends when all the coins have been reversed

I am now required to code an undo function, detection of completion, the ability to chose "challenges" via a web service and keep record of all the previous moves. I can figure all this out. However it says to follow "MVC" closely? I searched for this and the only thing which fits in this case is "Model-View-Controller" which I have no experience with

Has anyone got any hints how to follow such guidelines with such a small project?

Many thanks in advance.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 1112

In brief,

This is an architecture to follow while programming,

In an MVC app, the following 3 sections of app are kept seperate:

1. Model : Mainly data, how data is saved in the application. (eg: how you are saving the state of the coins true/false, etc.)
2. View: GUI/CUI how are you displaying it to the user. (eg: the drawing of your board, the coins, etc.)
3. Controller: Interaction with the user. (eg: Handling the user click over a coin, etc. )

you should ideally seperate these logics and not couple them together.

I agree. Here's the better link:

I agree. Here's the link:
subject: Basic Java Game & "MVC"
It's not a secret anymore!