• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Starting Point Assistance

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

etc...

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.
 
Kyle Lykens
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic