当前位置:网站首页>游戏六边形地图的实现
游戏六边形地图的实现
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
边栏推荐
- jupyter notebook文件目录
- 语音信号处理-概念(一):时谱图(横轴:时间;纵轴:幅值)、频谱图(横轴:频率;纵轴:幅值)--傅里叶变换-->时频谱图【横轴:时间;纵轴:频率;颜色深浅:幅值】
- How to bind SQL statements to web buttons
- JS performance reward and punishment examples
- 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%
- js中判断奇偶的函数,求圆面积的函数
- Speech signal processing - concept (4): Fourier transform, short-time Fourier transform, wavelet transform
- Remote connection raspberry pie in VNC Viewer Mode
- Speech signal feature extraction process: input speech signal - framing, pre emphasis, windowing, fft- > STFT spectrum (including amplitude and phase) - square the complex number - > amplitude spectru
- Memory barrier store buffer, invalid queue
猜你喜欢

(已解决) MINet 进行测试时报错如下 raise NotImplementedError
![[openairinterface5g] rrcsetupcomplete for RRC NR resolution](/img/61/2136dc37b98260e09f3be9979492b1.jpg)
[openairinterface5g] rrcsetupcomplete for RRC NR resolution

Cookie encryption 7 fidder analysis phase

【Kevin三连弹之三】Rust真的比C慢吗?进一步分析queen微测评

Error in idea connection database

JS to determine whether the result is qualified, the range is 0-100, otherwise re-enter

2、项目使用的QT组件
![[compilation principles] review outline of compilation principles of Shandong University](/img/a6/b522a728ff21085411e7452f95872a.png)
[compilation principles] review outline of compilation principles of Shandong University

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

What is the difference between volatile and synchronized?
随机推荐
The song of cactus -- throwing stones to ask the way (1)
Window right click management
The interviewer of a large front-line factory asked: do you really understand e-commerce order development?
window右键管理
(已解决) MINet 进行测试时报错如下 raise NotImplementedError
Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch
R 语言并行计算 spearman 相关系数,加快共现网络(co- occurrence network)构建速度
Memory barrier store buffer, invalid queue
语音信号特征提取流程:输入语音信号-分帧、预加重、加窗、FFT->STFT谱(包括幅度、相位)-对复数取平方值->幅度谱-Mel滤波->梅尔谱-取对数->对数梅尔谱-DCT->FBank->MFCC
JDBC parameterized query example
How to add data to the back-end database in the form of Excel file on the web page
Coal crusher
移动安全工具-jad
How torch. gather works
R language analyzing wine data
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
JS to determine whether the result is qualified, the range is 0-100, otherwise re-enter
Common operation and Principle Exploration of stream
Interviewer: how to never migrate data and avoid hot issues by using sub database and sub table?
mysql关于自增和不能为空