寻路2D Java游戏? [英] Pathfinding 2D Java game?

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

问题描述

我目前正在编写一个非常基本的Java游戏,基于 主题医院<的理念/ a>

I'm currently writing a very basic Java game based on the idea of Theme Hospital.

我是Java的新手,我目前正在大学读书。我已经做了近两年的Java,但是我终于把时间花在了一个体面的项目上。

I'm quite new to Java and am currently studying at the university my first year. I have done Java for nearly two years now on and off, but I'm finally devoting my time to a decent project.

我正处于我需要的阶段创造一个人(病人)进入医院。他们需要去接待处,然后去GP的办公室,然后回到他们的起始位置。

I'm at the stage where I need to create a person (patient) to be admitted to the hospital. They need to go to the reception desk, then GP's office, and then back to their starting position.

我已经研究过A *路径查找,但对我来说这似乎很复杂。我知道它是如何工作的,但我不确定如何将它实现到我的游戏中。

I have looked into A* path finding, but it seems really complicated to me. I understand how it works I think, but am unsure how to implement it into my game.

到目前为止,用户可以放置一个接待台,并建立一个GP的办公室。这些中的每一个都具有使用点,这将是患者必须去的地方。网格方块只能是满的,不会有不同的地形。

So far, the user can place a reception desk, and build a GP's office. Each of these has a "point of usage" which will be the place the patient has to get to. The grid squares can only be full or not, there will be no different terrain.

我还在犹豫要粘贴任何代码,因为我学的很麻烦在过去的几个月里,有许多与GUI有关的新技术。我的计划是到达里程碑1,让病人去办公桌然后离开办公室。一旦我有了这个,我会更多地整理代码。

I'm hesitant to paste any code yet, as it's messy as I've learn a lot of new techniques to do with GUI in the past few months. My plan is to get to the milestone 1, making the patient go to the desk then the office and then leave. Once I have this, I will tidy up the code more.

我见过许多A *和许多不同类型的实现。有人可以给我一个我可以使用的起点吗?我应该尝试调整已编写的类,还是尝试从头开始编写自己的类?

I've seen many implementations of A* and many different types. Can someone give me a starting point I can work with? Should I try and adapt an already written set of classes, or try to write my own from the scratch?

推荐答案

你真的想要吗? A *,它是基于网格的寻路的最佳实现。

You do want A*, it is the optimal implementation for grid based pathfinding.

这可能会帮助你:

< a href =http://www.cokeandcode.com/main/tutorials/path-finding/ =nofollow noreferrer> http://www.cokeandcode.com/main/tutorials/path-finding/

编辑:前面的链接既适用于可实现的类集,也适用于自定义路径查找方法的指南满足您的需求。

The preceeding link is good for both as an implementable set of classes and as a guide for customizing the path finding methods to meet your satisfaction.

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

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