Java游戏区域难度 [英] Java Game Playing Area Difficulty

查看:146
本文介绍了Java游戏区域难度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多第一人称2D游戏中,会有一个巨大的竞争场地,但是计算机上有一个小显示区域:

  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ b +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ b +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ b +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ b ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ b $ b 

其中+是整个比赛场地,a是屏幕上的可显示区域。



我想制作一个像这样的游戏按箭头键会让你在整个比赛场地上移动。



问题:我是否需要创建一个巨大的JPanel才能完成此任务? (比屏幕大)

解决方案

如果您开始常规游戏,您是否希望在整个级别找到滚动条屏幕的底部和侧面?或者你希望你可以在整个关卡中导航(使用你的鼠标/箭头/ ...)。



如果是第一个,请成为我的客人并创建一个巨大的 JPanel 并将其放入 JScrollPane 但我强烈建议选择2。



对于选项2,我在另一个相关的SO问题。这可能值得一看


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)

解决方案

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

这篇关于Java游戏区域难度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆