File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Starting Point Assistance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Starting Point Assistance" Watch "Starting Point Assistance" New topic

Starting Point Assistance

Kyle Lykens

Joined: Jul 12, 2013
Posts: 14
Hi everyone,

I want to use java to make a board game, which in itself will be complicated. Anyway, I want to start by making a simple board, like a monopoly square, for instance, and have a simple character (a dot is fine) move around, creating events on every square. The problem is I don't know where to start. Do I make the window first? Do i make the events in a separate java file and call upon it when i need it?

If anyone could reference me a good starting point, I'd be very appreciative. For reference, I can do basic things in java - methods, arrays, conditions and loops. I've had little experience making a window, although I have done it, I don't know to make squares or designs inside of the window, or how to insert a picture or word into it.
Thank you!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11814

A common idiom is something called the "Model-View-Controller". The idea is that how you model your data is completely independent of how you view it (or show it to the user), as is the controller (how the user interacts).

The classic example is a device that keeps time.

The model could be any of:
a pendulum
a quartz crystal that vibrates
grains of sand falling through a tiny hole
the position of the sun in the sky

The view could be:
long pointers that pivot around a central point
LCD crystals that turn on/off to form specific digts
LED lights that represent binary values
a series of pictures illustrating how bright it would be outside

The controller could be:
two buttons - one increases the hours, the other increases the minutes each time it is pushed
a twisty stem you can pull out/push in to several positions, and turning it can increase/decrease the time
a keyboard where you type in a specific time value and hit enter


Each of these things can be written independently of the other three - then you 'wire' them together. Get one working first before you worry about the others. Personally, I start with the model, then the controller, but your mileage may vary.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Kyle Lykens

Joined: Jul 12, 2013
Posts: 14
That makes sense! I think I would start with, as you said, the model, which would be making a board for me. Then I would add in the dice, store the result from the dice in a variable and call the variable for the character, who will then move that amount of spaces. I'd assume I have to label each space and a path as well, correct?

Two more questions:

1) How would I go about having the character choose a random direction if they came to a three or four-way intersection?

2) Does anyone have a page that lists important commands, or all commands for that matter, for java game design?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11814

Don't start by thinking "i need a variable to hold this value". Start by writing out the kind of things that need to happen. The general rule of thumb is that nouns become classes and verbs become methods.

So, I may write:
the player rolls the dice.
The player will them move their token that many spaces around the board

So, From the first sentence, I may need a player class, a die/dice class, and a method to roll the dice. the roll method probably belongs on the dice class, and the players probably need to HAVE some dice.

The second sentence implies that I also need a move method, a space class, and a board class - the board class probably HAS spaces and HAS tokens. I would think the board class would have a move method that takes a token/player and an int value to that tells it who moves how far.

You should probably expect to spend a few hours writing this stuff out, and THINKING about things before you write a single line of code.

I agree. Here's the link:
subject: Starting Point Assistance
It's not a secret anymore!