Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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  
  I need aid making board game in Swing/AWT !!!!  (Read 4036 times)
0 Members and 1 Guest are viewing this topic.
Offline Fancypants94

Junior Newbie

Exp: 2 years

« Posted 2014-04-24 14:47:51 »

So a week ago was my first introduction to GUI in university i was given two lectures about Swing & AWT and then i was told to make a board game and that Google is my best friend, so i started searching google but i feel lost :/ i don't know what to do. If someone has links for some tutorials also if  someone  would add me on skype or something and explain things to me that would be great Smiley anyways thank you in Advance.
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 449
Exp: 6 years

« Reply #1 - Posted 2014-04-24 15:03:55 »

There are, as with any problem, multiple ways to approach it. The first stage in software development is (should be) the design stage.
What game are you making? is the first question you should be asking yourself. Without a design you don't need to worry about implementation as there is nothing to implement.

I don't know your level of experience, what you learned in the lectures, what you know about board games, or your Google-fu skills, but to help with your direct question I will direct you to the Official Java Tutorials trails on Java2D and Swing.

And here is a basic google search that will help get you started as well: make a board game java

I will also give you a bit of personal advise: Don't use AWT.  Pointing
Offline Fancypants94

Junior Newbie

Exp: 2 years

« Reply #2 - Posted 2014-04-24 16:16:28 »

Well i think my level in Java is sufficient & I already made the engine for the game specifying game rules and now all is left to be done is GUI for the game. The two lectures only talked about the history of AWT & Swing and then all it talked about was making a JFrame and adding JComponents to it + Listeners and that's it.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2014-04-24 23:10:13 »

For a board game, I'm thinking Checkers or Parcheesi or Chess or Go. That sort of thing?

I'm also assuming you only have to get the graphics working so two players (on the same computer, taking turns) can move the pieces. No AI needed, no computations to determine if the move made is legal or not.

I'm just trying to get some more information on your question before jumping in. A 'Board Game' usually won't need to have a game loop or any animation other than the clicking and dragging of pieces, if you want to show that action (may not be part of the requirement for the assignment). Most of the tutorials on this site assume animation game loops.

If my guess is true, most helpful will be looking at MouseListener and MouseMotionListener, and JComponents or JPanels for the pieces. The JPanel or JFrame that functions as the board will either be some sort of grid layout or null layout where you manage the pieces' positions by computing their locations via x,y pixel coordinates rather than grid coordinates. If using a grid layout, the pieces should all be the same size, probably.

Does that help you get started?

music and music apps:
Offline Fancypants94

Junior Newbie

Exp: 2 years

« Reply #4 - Posted 2014-04-25 00:12:54 »

Yes what you said does help but what if i want to do animation in my game ? i am really interested in Graphics2d class i've read a good amount of tutorials on various topics like BufferStrategy & Tile maps but it's still a blur for me because every tutorial jumps in directly without thorough explanation of what he's doing. if you can help with that i would be grateful as i am interested in game making in general my motive to learn isn't just my project.
Offline philfrei
« Reply #5 - Posted 2014-04-25 20:14:00 »

I think it is useful to make a distinction between two types of animation.

First, it is also possible to animate on an "as-needed" basis. In this case, as the mouse moves (assuming click-and-dragging a playing piece), the location of the mouse is sent to the class that controls the piece. Then a command is issued to render the screen. (This could also be done by listening to the keys, instead of the mouse, and using arrow key presses or AWSD or whatever to update the piece's location data, and again immediately followed by a render command.)

A second type is most often used in games, especially where animation needs to continue even when the User is not doing anything. With this type, there is a piece of code responsible for executing a "game loop". This is code that goes through a cycle of two things (a) calculation of new positions [aka "game state"] (b) rendering the graphics. A usual goal it to have the loop take a fixed amount of time. This can be done by triggering the cycle via a Timer (util.Timer is best, imho), or by putting in a Thread.sleep() command with an amount of time between cycles (this is more commonly done than Timer methods). Most of the animators at JGO aim for 60 fps (animation draws or frames per second), but in my experience, 30 fps is more than adequate when all you are doing is dragging playing pieces around the screen.

In this scenario, the MouseMotionListener or KeyListener again triggers the sending of location data to the class that controls the piece, but in this case it does not trigger a render. It is the game loop code that takes whatever location is stored in the piece at the time, and uses that for the rendering. In other words, the updating of the location (via the mouse drag) and the drawing are on two separate threads. There might be a bit of "synchronization" needed to make sure the x & y get updated as a unit. [Send the location data as a Point object?]

In any case, I would suggest you first just try to write a program where you click on an empty screen and it draws a box, and if you drag from within the box, the location of the box moves, using the first method of animation. You will find the .contains() method of the Rectangle helpful. If you are able to get this to work, then the more usual method of animation will be all the easier to understand and code.

Horstmann has published sample code that does just this, as part of his "Core Java" series. Chapter 8 (in my 8th edition, has a program called "" which you should be able to find online at the sample code download for this book.

music and music apps:
Offline Fancypants94

Junior Newbie

Exp: 2 years

« Reply #6 - Posted 2014-04-26 04:20:18 »

Ty you for help i appreciate more than you think Smiley i've read what you wrote but i am still somewhat confused about the implementation but i've made up my mind about what to do about the game. it's a 5x5 Board game so i was thinking of make a tile map using the program tiled and using isometric tiles but unfortunately i can't find any. also i wanted to make the Tile map 6x6 so i have a border to the board so if you can point me to the right direction to finding isometric tiles or making them i would be grateful Smiley also if you can give me your opinion about the whole concept 
Offline philfrei
« Reply #7 - Posted 2014-04-26 07:54:42 »

I don't have much experience with tiles. I would imagine you can draw them with any art program. Java is set up to import gif & jpeg & some other formats.

Sorry if my explanation of animation was confusing. I'm thinking, if you are doing this for a class, the lectures should have provided the basic conceptual building blocks for your project. If some of the stuff I was talking about didn't make sense, I'm wondering if it was beyond the scope of the assignment.

music and music apps:
Offline Fancypants94

Junior Newbie

Exp: 2 years

« Reply #8 - Posted 2014-04-26 15:14:27 »

In my class i was just given an introduction about swing/awt because of that all my knowledge is internet based so i try to find any related information anywhere i can :/
Offline CodeHead

JGO Knight

Medals: 52

From rags to rags.

« Reply #9 - Posted 2014-04-26 15:54:24 »

Give this thread a read for information about isometric projections and tile placement. This thread should give you a good idea about how to construct a game loop. The Java trail on active rendering will get you started on efficiently rendering your game world to the screen. Using the forum's search capabilities will also turn up plenty of information on these subjects. Finally, if you're looking for art, you can try browsing

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline AirTime

Senior Newbie

Exp: 4-6 months

Not a glitch, just a misplaced curly brace.

« Reply #10 - Posted 2014-04-26 18:17:34 »

Try making just a game first, then adapt it.

Nothing's gonna change my world.. well, at least until the next syntax error appears Tongue
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

BurntPizza (22 views)
2015-10-07 02:11:23

KaiHH (23 views)
2015-10-06 20:22:20

KaiHH (11 views)
2015-10-06 19:41:59

BurntPizza (24 views)
2015-10-06 19:04:48

basil_ (44 views)
2015-09-30 17:04:40

shadowstryker (22 views)
2015-09-29 15:55:06

TheSpaceHedgehog (28 views)
2015-09-29 01:58:48

GamerC4 (54 views)
2015-09-24 21:10:38

GamerC4 (71 views)
2015-09-24 21:09:48

htuy (28 views)
2015-09-24 04:57:24
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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‑
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!