Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

[new to java] Graphical board game question

Thread view: 
soop - 16 Mar 2004 01:51 GMT
Hi, I've searched Google for this before but found nothing really
satisfying.
I'm programming a Monopoly-like game in Java. So far, the game logic is okay
and I'm having fun with custom events ans so on. But it is only a console
game at this stage.

I'd like to make it graphical and display the board game so that I could get
the id of each square when clicking on it.
I thought I could just display the real board scanned picture as a
background and then track mouse clicks coordonates, in order to get the
square number. With that, I couls access my ArrayList of Squares. That is
not very elegant, though.
Is there another way to get the same result ?

Is there a way to get something like an clickable imagemap ? Or would it be
a bad idea ?

Or should I use transparent panels, above the board background ?

I don't kow which way to go, from here.

Thanks in advance :)
Alex Hunsley - 16 Mar 2004 11:02 GMT
> Hi, I've searched Google for this before but found nothing really
> satisfying.
[quoted text clipped - 9 lines]
> not very elegant, though.
> Is there another way to get the same result ?

This is pretty much how I would do it.
If you store your game square locations as Rectange objects in a
collection, you can then test for which square a certain Point2D object
is in by calling Rectange.contains(..the Point2D object...) for each
Rectangle, or until one call to contains(...) return true.

> Is there a way to get something like an clickable imagemap ? Or would it be
> a bad idea ?

Not that I know of in java. You write it yourself, it's not too hard....

> Or should I use transparent panels, above the board background ?

Ooh no, steer clear of farting about with transparent components, you'll
just make your life harder.

> I don't kow which way to go, from here.
>
> Thanks in advance :)

HTH,
alex


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.