如何在java中程序生成类似make的Zelda [英] How to procedurlly generate a Zelda like make in java

查看:124
本文介绍了如何在java中程序生成类似make的Zelda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在java中制作程序生成的地图?
游戏本身就像是Zelda是程序生成的......帮助?

How would I go about making a procedurally generated map in java? The game itself is like if Zelda was procedurally generated... Help?

推荐答案

塞尔达传说中的地图从前不久使用等距瓷砖视图。您需要做的第一件事是将等距瓷砖集加载到您的程序中,我相信您可以找到Zelda瓷砖集。然后,您需要决定如何在程序上生成地图。是否会有海洋,不同的生物群落,建设?在制作用于生成地图的等式时,需要考虑所有这些因素。每个磁贴需要存储在某个地方,所以我会创建一个二维数组来打包所有的tile值。然后使用嵌套for循环来渲染切片。代码看起来像这样

The legend of Zelda maps from a while ago use a isometric tile view. The first thing you would need to do is load a isometric tile set into your program which I'm sure you can find Zelda tile sets. You then would need to decide how you want your map to procedurally generate. Will there be oceans, different biomes, building? All of theses need to be taken into consideration when making your equation for generating your map. Each tile needs to be stored somewhere so i would make a 2d array to pack all of your tile values in. Then use a nested for loop to render the tiles. The code would look something like this

int[][] world = new int[50][50];

for( int i = 0; i < 50; i++ ){
    for( int b = 0; b < 50; b++ ){
        int tile = world[i][b];
        render(tile, i, b);
        //use i and b to position the tile on your world

生成哪些瓷砖哪里有点棘手,然后在创建瓷砖后渲染它们。上面只有一个空矩阵。我会再次使用for循环来填充您喜欢的世界,使用不同的int id值表示tile。然而,这将是完全随机的,所以你需要一些方法来解决你的疯狂问题。我会在生成时测试周围的瓷砖,并为周围的瓷砖生成更高的概率,以便更加平滑地形。如果你想为你玩的每个游戏都想要相同的世界,你可以为你的矩阵提供恒定的值而不是生成它们。我不打算编写整个等轴测视图引擎,但我希望其中一些概念可以帮助你。

generating which tiles go where is a bit more tricky then rendering the tiles once they are created. Above only a empty matrix has been made. I would use a for loop again to fill the world to your liking with different int id values that represent tiles. This however would be at complete random so you need some method to your madness. I would test the surrounding tiles when generating and give the surrounding tiles a higher probability to generate so the terrain would be more smoothed out. If you want the same world for every game you play you can just supply your matrix with constant values instead of generating them. I don't intent on writing a entire isometric view engine, but i hope some of these concepts can help you out.

这篇关于如何在java中程序生成类似make的Zelda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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