所以,我一直對這個遊戲有點。但是,在過去的一天中,我一直無法弄清楚如何進行碰撞檢測。瓷磚碰撞檢測
規模在默認等於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基礎上,如果有球員和塊之間的碰撞。