Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 2002 times)
0 Members and 1 Guest are viewing this topic.
Offline Fancypants94

Junior Newbie


Exp: 2 years



« Posted 2014-04-24 16: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.
Online BurntPizza
« Reply #1 - Posted 2014-04-24 17: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.

http://docs.oracle.com/javase/tutorial/2d/
http://docs.oracle.com/javase/tutorial/uiswing/

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 18: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-25 01: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?

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Fancypants94

Junior Newbie


Exp: 2 years



« Reply #4 - Posted 2014-04-25 02: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 22: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 "MouseTest.java" which you should be able to find online at the sample code download for this book.
http://www.horstmann.com/corejava.html

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Fancypants94

Junior Newbie


Exp: 2 years



« Reply #6 - Posted 2014-04-26 06: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 09: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.

http://docs.oracle.com/javase/tutorial/2d/images/loadimage.html
http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html

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.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Fancypants94

Junior Newbie


Exp: 2 years



« Reply #8 - Posted 2014-04-26 17: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 Coder


Medals: 40


From rags to riches...to rags.


« Reply #9 - Posted 2014-04-26 17: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 http://opengameart.org/.

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 20: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  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!