所以,我一直对这个游戏有点。但是,在过去的一天中,我一直无法弄清楚如何进行碰撞检测。瓷砖碰撞检测
规模在默认等于2
球员41 *标度由64 *规模。
我的播放机在屏幕的在x和y轴两者的中间居中。
由于玩家为中心的世界是什么动作,这些变量是worldx和worldy。玩家总是停留在屏幕的中心。
我的瓷砖地图被存储在数组中,并且基于该图像的像素的颜色。如果像素在map [x] [y]处为白色,则将该值设置为0,否则将其设置为块。这意味着块不会被渲染。
for x = 0, w-1 do --scans the image and builds the map array
amap[x] = {}
for y = 0, h-1 do
local r, g, b, a = source:getPixel(x, y)
if r == 255 and g == 255 and b == 255 then
block = 0
end
if r == 255 and g == 100 and b == 0 then
block = 1
end
if r == 130 and g == 125 and b == 0 then
block = 2
end
if r == 76 and g == 76 and b == 76 then
block = 3
end
if r == 255 and g == 0 and b == 255 then
--this is the spawn pixel yet to build
end
amap[x][y] = block
end
end --end function
功能绘制地图
for x = 0, w-1 do --draws the map
for y = 0, h-1 do
if amap[x][y] ~= 0 then
love.graphics.drawq(ImgBlocks, Blocks[amap[x][y]], 32*x*(3/bscale) + worldx, 32*y*(3/bscale) + worldy + jy, 0 , 3/bscale, 3/bscale)
end
if amap[x][y] == 4 then
end
end
end --end function
的函数需要返回true或false基础上,如果有球员和块之间的碰撞。