当前位置:网站首页>游戏六边形地图的实现
游戏六边形地图的实现
2022-06-27 07:22:00 【friendan】
难点主要是如果获取一个六边形格子相邻的六个格子,在实际开发中有个简单取巧的方法,
思路:把正四边形变成平行四边形,然后把六边形格子放入平行四边形的直角坐标系中就成了六边形地图。即产生地图时可以按正四边形的方式产生,UI显示地图时按平行四边形的方式显示,这样玩家看到的地图就是六边形地图了。
根据以上思路 ,一个取相邻6个格子的关键函数,可以这样简单的实现:
--参数(x,y)为六边形格子中心点坐标
getAdjacenGrids = function(x,y)
local xyList = {
{x, y + 1},--左上角格子
{x, y - 1},--右下角格子
{x + 1, y},--左边格子
{x - 1, y},--右边格子
{x - 1, y - 1},--左下角格子
{x + 1, y + 1},--右上角格子
}
return xyList
end
边栏推荐
- MySQL
- 多表联查--07--- Hash join
- Installation and functions of uview
- From 5 seconds to 1 second, the system flies
- Guava tutorial collect some cases and write Google tool classes slowly
- The first part of the construction of the defense system of attack and defense exercise is the introduction and the four stages of Defense
- Visual studio vs shortcut key usage
- 1-4 进制表示与转换
- Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand
- 2. QT components used in the project
猜你喜欢

一個人管理1000臺服務器?這款自動化運維工具一定要掌握

js输出1-100之间所有的质数并求总个数

语音信号处理-概念(二):幅度谱(短时傅里叶变换谱/STFT spectrum)、梅尔谱(Mel spectrum)【语音的深度学习主要用幅度谱、梅尔谱】【用librosa或torchaudio提取】

一个人管理1000台服务器?这款自动化运维工具一定要掌握

基础知识 | js基础

使用 Blackbox Exporter 测试网络连通性

js例题打印1-100之间所有7的倍数的个数及总和

Rust Async: smol源码分析-Executor篇

Cookie encryption 6

Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
随机推荐
Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
使用 Blackbox Exporter 测试网络连通性
用XGBoost迭代读取数据集
Window right click management
How to add data to the back-end database in the form of Excel file on the web page
The first part of the construction of the defense system of attack and defense exercise is the introduction and the four stages of Defense
Cookie encryption 6
Cookie加密6
[openairinterface5g] rrcsetupcomplete for RRC NR resolution
apifox学习
Remote connection raspberry pie in VNC Viewer Mode
JS uses the while cycle to calculate how many years it will take to grow from 1000 yuan to 5000 yuan if the interest rate for many years of investment is 5%
语音合成:Tacotron详解【端到端语音合成模型】【与传统语音合成相比,它没有复杂的语音学和声学特征模块,而是仅用<文本序列,语音声谱>配对数据集对神经网络进行训练,因此简化了很多流程】
请问网页按钮怎么绑定sql语句呀
延时队列`DelayQueue`
Memory barrier store buffer, invalid queue
JDBC操作Mysql示例
log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.
[compilation principles] review outline of compilation principles of Shandong University
oracle的similarity方法实现原理