0

Hi,

I'm trying to make my own sokoban game in java.

Sokoban is a top down 2D puzzle game where you move around a level trying to push boxes to the goal area in the least possible moves.

I'm already pretty stuck at an early stage. My first objective it to load an image and be able to move it around with the arrow buttons on my keyboard.

Does anyone know how to do this.

I have a .bnp image that I want to use for the character.

Next i want to load in images for walls and boxes and the goal area and create conditions so that my character can't walk through the wall and so he'll be able to push the boxes around the map.

I'd really appreciate any help I could get. An example of using the arrow keys to move a small .bnp image around an large JFrame would be greatly appreciated.

Thanks

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by adams161
0

Sounds like you will need a keyboard listener and your frame ( which should have a panel) will need a paintComponents method to draw to the screen images or shapes. I think things work best when you do all your work in the panel, so attach the keyboard listener to the panel and have the paint components in the panel. You can google these concepts. Getting started with writing to screen and making it intelligent by detecting it should write differently based on key press events shouldn't be so hard.

Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.