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 anyways thank you in Advance.
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. :point:
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.
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?
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.
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
Ty you for help i appreciate more than you think 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 also if you can give me your opinion about the whole concept
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.
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
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/.
Try making just a game first, then adapt it.