无缝滚动图块 [英] Seamless scrolling tilemaps

查看:62
本文介绍了无缝滚动图块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究自上而下的rpg,并希望实现无缝滚动地图。也就是说,随着玩家探索世界,地图之间没有加载屏幕,也没有通往下一个区域的门。

I'm working on a top-down rpg, and want to implement seamless scrolling maps. That is, as the player explores the world, there is no loading screen between maps and no "doors" to the next area.

我有两种打破世界的方式。在顶层,我有区域,它只是9个地图的集合(这些区域仅由目录表示)。在区域内,将9张地图组织成3x3网格。我还没有找到代表这些地图的最佳方法,无论是按索引还是相对于父区域的相对坐标。这些地图是实际显示在用户屏幕上的内容。考虑到每个地图的大小和视口的大小,我知道用户在地图的一角时最多只能看到四个地图。

I have two ways to break down the world. At the top level, I have "zones" which is simply a collection of 9 "maps"(These zones are only represented by directories). Within the zone, the 9 maps are organized into a 3x3 grid. I haven't figured out the best way to represent these maps yet, whether it's by index or by relative coordinate to it's parent zone. These maps are what actually get rendered to the user's screen. Given the size of each map, and the size of the viewport, I know that the user will only be able to see a max of four maps when they are on the corner of a map.

我的问题是,当玩家探索世界时,如何在代码中跟踪地图及其各自的偏移量?我正在考虑使用 map< Point,Map *> ,其中0,0是玩家当前所在的地图。如果玩家位于左下角,则向东的地图将被存储为1,0,向南的地图将被存储为0.1,向东南的地图将被存储为1,1。我预见到的问题是,我不确定这些点是否可变,并且如果每次玩家移动到另一张地图或地图的不同部分中时重新构建列表都会造成问题。

My problem is, how do I keep track of the maps and their respective offsets in code as the player explores the world? I was thinking about having a map<Point, Map*> with 0,0 being the map the player is current located in. If the player was on the bottom left corner of the map, then the map to the east would be stored in as 1,0, the map to the south would be 0,1 and the map southeast would be 1,1. The problem I foresee with this is, I'm not sure of the points are mutable, and if rebuilding the list every time the player moves into another map or a different section of the map would cause a problem.

推荐答案

这与我正在尝试使用FreeBASIC编写的游戏完全一样。我的操作略有不同,但可能会有所帮助。

This is exactly like what I'm trying to do with a game I'm writing in FreeBASIC. What I'm doing is slightly different, but maybe it can be of some help.

我有一张1024 ^ 2的世界地图(因此我可以分形地生成它)。世界地图上的每个土地广场都是REGION地图(具有过程历史的微型王国),但是我使区域地图的生成非常容易。区域图是128 ^ 2,我在256 ^ 2数组中有四个。当您靠近边缘时,它将移动地图并创建2-3个新区域(尽管仅创建一个历史记录,即玩家所在的区域)。

I have a 1024^2 world map (so I can generate it fractally). Each land square on the world map is a REGION map (a miniature kingdom with a procedural history), but I made region maps very easy to generate. The region maps are 128^2 and I have four of them in a 256^2 array. When you get near the edge it moves the maps and creates 2-3 new regions (though it only makes ONE history-- the region the player is in).

内部其中有256 ^ 2个ZONE映射,它们也以512 ^ 2阵列的形式平铺2x2。再次,当接近边缘时,它会移动并生成新的边缘。

Inside of these are 256^2 ZONE maps, which also tile 2x2 in a 512^2 array. Again, when approaching the edge it moves and generates new ones.

我前段时间尝试了3x3网格,但由于效率低而不得不拒绝。

I tried a 3x3 grid some time ago, but had to reject it as inefficient.

这篇关于无缝滚动图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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