Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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  
  Help pls: How to Draw a Board for Backgammon game  (Read 2048 times)
0 Members and 1 Guest are viewing this topic.
Offline HaDeS

Junior Newbie





« Posted 2007-07-29 18:16:37 »

Hello guys,

          I'm pretty new to Java Games programming and I honestly I am lost as to which route to take to draw the Board of my Backgammon game.  Huh
I need advice on the following matter:

        I was thinking initially that instead of actually Drawing the Board using Java shapes (like drawRect() etc), to take a real photo of my own real Backgammon Board and import it in the application. Now, the Question is: How am I going to do this? I mean, do I import the Image in my application and then I just "mark" the Positions of the pieces somehow and then add Actionlisteners to them, so that the application knows which are the positions that it needs to "listen" for the moves of the pieces?

Or alternatively, would it be possible to import the photo that I've taken, and then draw a Board using Java shapes (like drawRect() etc), but make it Transparent in color, and then "stick" it on top of the Photo (image) and then add ActionListeners on the positions of the drawn Board?

Please I need your guidance to this, as I am new to Game and Graphics programming in Java! Any suggestions and explanation would be greatly appreciated  Smiley

Thanks in Advance,

HaDeS
Offline keldon85

Senior Member


Medals: 1



« Reply #1 - Posted 2007-07-29 19:28:12 »

I would trace the image in gimp and export an SVG file, parse the SVG file and use it to create shapes to test for collision and draw highlights for mouse overs, etc. That, however, may be too much for yourself, so write a method that draws the shapes in alternate colours and check for collision with the mouse using shapes.

Offline HaDeS

Junior Newbie





« Reply #2 - Posted 2007-07-29 19:36:12 »

I would trace the image in gimp and export an SVG file, parse the SVG file and use it to create shapes to test for collision and draw highlights for mouse overs, etc. That, however, may be too much for yourself, so write a method that draws the shapes in alternate colours and check for collision with the mouse using shapes.

I'm sorry but I think I'll need a bit more detailed description of your suggestion, as I do not really understand what you are trying to say...  Embarrassed

I'm not so experienced u see...

Thanks again
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #3 - Posted 2007-07-29 22:37:54 »

Get Inkscape.

-go to Document Properties (top/right icon)
-set the canvas size to something sensible
-setup the grid
-draw
-save Wink
-export as png

Then do matching checker graphics.

This is by far the quickest way. Additionally you won't have to figure out the positions... simply setup the grid in such a way that its easy to handle.

弾幕 ☆ @mahonnaiseblog
Offline HaDeS

Junior Newbie





« Reply #4 - Posted 2007-07-29 23:03:08 »

Get Inkscape.

-go to Document Properties (top/right icon)
-set the canvas size to something sensible
-setup the grid
-draw
-save Wink
-export as png

Then do matching checker graphics.

This is by far the quickest way. Additionally you won't have to figure out the positions... simply setup the grid in such a way that its easy to handle.

Sounds cool, I'll try it soon, thanks.

But: are you implying that you would do it following the 2nd approach that I mentioned in my initial post? Like drawing the Grid with Inkscape, make it transparent so as not to be visible, and then "sticking" it ON my real Photo of Backgammon?
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2007-07-29 23:57:49 »

No, I meant that I would create all graphics in Inkscape (and some touch up in Photoshop perhaps).

弾幕 ☆ @mahonnaiseblog
Offline HaDeS

Junior Newbie





« Reply #6 - Posted 2007-07-30 00:07:57 »

I tried Incscape and what I found out was that it is just a paint Program, I can do the same with Photoshop by the way...

Am I missing something here that I should have understood by now?
Offline HaDeS

Junior Newbie





« Reply #7 - Posted 2007-07-30 00:11:56 »

Lol ok we were posting at the exact same moment! (does not happen often, does it?)

ok so in case I want to import my Real Photo of my own Backgammon, it is the same as if I would paint it in Photoshop or Inkscape.. right?

My question was: the Logic by which I should make the Graphics Backgammon Board, not the means by which I would draw it.

so which of my initial thoughts should I follow? no1? no2? or neither of them?
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #8 - Posted 2007-07-30 00:33:54 »

Yes, Inkscape is a drawing program, but unlike Photoshop it's vector based (like Illustrator). Using vectors for the rough shapes (or even everything with some Gaussian blur shadows and highlights etc) is a lot easier and more productive.

>My question was: the Logic by which I should make the Graphics Backgammon Board, not the means by which
>I would draw it.

Using the approach, I outlined above, you get coordinates, which are very easy to handle. Drawing the checkers at the right place and correctly interpreting the mouse coordinates is way easier then.

Let's unroll your previous questions...

>I mean, do I import the Image in my application and then I just "mark" the Positions of the pieces somehow
>and then add Actionlisteners to them, so that the application knows which are the positions that it needs to
>"listen" for the moves of the pieces?

You simply load the board and checker images and draw it in whatever component you like. To this single component you add a single MouseListener. All whats left to do is to translate the coordinates correctly to your data structure (say... a 2d array) and this is (as I explained earlier) a lot easier with an overly accurate board image.

>Or alternatively, would it be possible to import the photo that I've taken, and then draw a Board using Java
>shapes (like drawRect() etc), but make it Transparent in color, and then "stick" it on top of the Photo (image)
>and then add ActionListeners on the positions of the drawn Board?

This is of course also possible, but it requires a lot more work on your end. Especially if the board is distorted due to perspective.

弾幕 ☆ @mahonnaiseblog
Offline HaDeS

Junior Newbie





« Reply #9 - Posted 2007-07-30 00:43:36 »

Now I understand it much better  Cool

Another question: About the Coordinates that Incscape uses and those that Java uses for an Application (not an Applet - I still do not know if the coordinate system those 2 methods use is the same... is it?).

So, my question is: is the coordinate system of Incscape and that of Java Application, the same? (for the shapes etc?) IF it is, then Yes I can see why it would be much easier to do it this way  Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #10 - Posted 2007-07-30 00:54:23 »

Set the default units to px (pixels). If your canvas in Inkscape is say... 640x480px and if you export it at that very size... then yes, you'll get a nice 1:1 mapping.

And Applet vs Application... it's the same deal.

弾幕 ☆ @mahonnaiseblog
Offline HaDeS

Junior Newbie





« Reply #11 - Posted 2007-07-30 01:43:03 »

OnyX you ' ve been really helpful mate  Cheesy

I really appreciate it.

By the way, if anyone else has something to say or propose, please free to do so, as I am not going to starting implementing the Graphics for some time now...

Thank you all.
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.

xsi3rr4x (28 views)
2014-04-15 18:08:23

BurntPizza (25 views)
2014-04-15 03:46:01

UprightPath (40 views)
2014-04-14 17:39:50

UprightPath (22 views)
2014-04-14 17:35:47

Porlus (38 views)
2014-04-14 15:48:38

tom_mai78101 (62 views)
2014-04-10 04:04:31

BurntPizza (121 views)
2014-04-08 23:06:04

tom_mai78101 (221 views)
2014-04-05 13:34:39

trollwarrior1 (188 views)
2014-04-04 12:06:45

CJLetsGame (195 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!