1

In many first person 2d games, there will be a huge playing field, but a small display area on your computer:

++++++++++++++++++++++++++++++++++++
+++++aaaaaa+++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++
+++++aaaaaa+++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++
+++++aaaaaa+++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++
+++++aaaaaa+++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++

where "+" is the entire playing field and "a" is the displayable region on your screen.

I want to make a game like this where pressing the arrow keys will make you move across the entire playing field.

Question: Would I need to create a huge JPanel to accomplish this? (Bigger than the screen)

Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
Anonymous181
  • 1,863
  • 6
  • 24
  • 27
  • You use image tiles. Break up the huge area into tiles that are 25% bigger than the displayable region. When you detect the player crossing into another tile, you display both tiles until the player has moved into the next tile. – Gilbert Le Blanc May 08 '12 at 19:20
  • 1
    There is a good answer to this question here : http://gamedev.stackexchange.com/questions/16570/scrolling-tile-system Check that out. – cd6 May 08 '12 at 19:19

1 Answers1

4

If you start a regular game, do you expect to find scrollbars for the whole level at the bottom and the side of your screen ? Or do you expect you can navigate (using your mouse/arrows/...) through the whole level.

In case of the first, be my guest and create a gigantic JPanel and put it in a JScrollPane but I strongly suggest to go for option 2.

For option 2 I outlined a possible approach in another related SO question. That might be worth a look

Community
  • 1
  • 1
Robin
  • 36,233
  • 5
  • 47
  • 99