Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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  
  Need design help for a boardgame port please  (Read 727 times)
0 Members and 1 Guest are viewing this topic.
Offline JDave

Innocent Bystander





« Posted 2007-04-27 06:28:46 »

Hi,

I am currently working on a port of a boardgame into Java.

My problem is now how to really program the game.

It is not a typical boardgame with fields I could store in an array but a tabletop game where the models could be everywhere on the board.

I thought about doing it like the following but maybe you can give me a better/easier solution.

- create a class for a model storing the coordinates and the values (e.g. lifepoints,movement range and so on)
- create a class for the graphics of the models extending JPanel so that i can use a mouselistener to check if someone clicked on the model and returning some info to an infofield.
-create a class for the board extending JComponent loading the background image
-create a modellist class storing all the graphical models in a list to keep track of them (a vector as a linear list)

And in the board class i would change the paintComponent to something like that:

//only pseudo code, i know that a vector is not accessable like an array
public void paintComponent(Graphics g)
{
   this.drawBoard(g);
   for (i=0;i<modelList.getCount();++i)
   {
       modelList.drawModel(g);
   }
}



Is that the right approach to that?

It is not real time so i would repaint the battlefield everytime the active player interacted with a model.

Are my thoughts ok like that?

There will no be drag and drop but if a model was clicked and it belongs to the active player he should get a popup dialog offering him choices depending on the phase he is in (movement, shooting, closecombat).

Can I also implement something like that only the units having a boolean value as true to be enabled to click on?

And how can I implement a collision detection? I thought about using sprites is that the correct way or is there a better one?

Thanks in advance
Offline ddyer
« Reply #1 - Posted 2007-04-28 20:55:57 »

your plan looks plausible.    You should be drawing to an offscreen bitmap, then draw the
completed bitmap to the real screen in one swell foop. 

Depending on the number of models, update rate, and the overall complexity, you might need to
segregate the models into a background layer for relatively static elements, so your draw loop
would become  { draw_background(); draw_foreground(); draw_on_real_screen(); }
Offline JAW

Senior Devvie


Medals: 2



« Reply #2 - Posted 2007-05-04 12:58:47 »

Most tabletop games have a manageable number of entities. Say 50 units each side, making it 100 for 2 players. You can store this in a list or maybe optimised data structure.

You can still use tiles, but make them greater. Its rather using sectors. Each sector has a size of 200 x 200 pixels or anything that fits good. Store all things within that sector there. You then have an array of sectors, each sector having a list of a few entites.

I would say, give it a try. Developers sometimes tend to worry about performance, where there is no problem. Processing a list of 100 entries can be pretty fast. Other parts of the game like AI or graphics might impact performance far more. I once read "write first, optimise then". You can only spot performance bottlenecks, when you made it. I always wonder about A*. Pathinfind can take quite a lot of iterations, and it runs fast on most games I know.

And when its not realtime, it really reduces the permament computation. You dont need to compute AI, collisions or damage or such permanently. It saves a lot of processing power.

-JAW
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.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!