I have been trying to implement a basic game. However, i'm relatively new to java and not sure the best way to go about it.
I am going to have a background image as the board and then draw the counters on top of this image to represent their position. When moves occur I will make the movements animated rather than jumping from position 1 --> postion 2.
What is the best way to do this? I initially had a JFrame with the background image handled by a JFrame. However, I couldn't then get the counters to draw on the frame.
Thankyou in advance for any support/ help you might be able to supply.
> What is the best way to do this? I initially had a JFrame with the background image handled by a JFrame.
using a JFrame is the wrong approach - it is a top-level window
if you use a JPanel, you can then add it to just about anything - frame, applet etc
Joined: Apr 27, 2009
Thankyou. Is it good practice to have more than one frame? For example i'l have a game window and one or two control panels. If i creates these within JPanels and add these to different JFrames.... is this considered good practice?
first of all i recommend to move this topic to the gaming forum for a better response.
usually its not good to use more than 1 frame in such applications, i would recommend a modal dialog for such purposes
The best way to do that i guess is to make a layout model that supports a grid like positioning
it may contain a move method which will move component from one cell location to another
you can later do the work of animating the movement.
I have myself made a similar game in java at my site, its called snakes and ladders.
though i have not used animations for the cell to cell movement as you require,
i think it may give you an idea.