所以我是编程新手,目前正在尝试使用 pico-8 进行编码。
我开始了一个游戏,其中精灵应该从顶部掉下来,当与我的 pset(点)碰撞时,我希望我的分数增加 1。截至目前我遇到了 2不同的结果。第一个分数不断快速上升,每次我的点超过精灵左上角像素 y 和 x 时分数都会上升。我不知道如何解决它,我真的很想知道它有什么问题。
(Tab 1)
col=11
sx=40
sy=20
x=64
y=64
score=0
function _init()
cls()
end
function _update()
cls()
movement()
border()
point()
sprite1()
if (x == sx) then score +=1 end
if (y == sy) then score +=1 end
end
(Tab 2)
function _draw()
print("score:",0,0)
print(score,25,0)
end
(Tab 3)
-- movement
function point()
pset(x,y,col)
end
function movement()
if btn(⬅️) then x -= 1 end
if btn(➡️) then x += 1 end
if btn(⬆️) then y -= 1 end
if btn(⬇️) then y += 1 end
end
-- sprite1
s1=1
function sprite1()
spr(s1,sx,sy)
end
(Tab 4)
-- border
function border()
if x>=127 then y=60 end
if x<=0 then y=60 end
if y>=127 then x=60 end
if y<=0 then x=60 end
if x>=127 then x=60 end
if x<=0 then x=60 end
if y>=127 then y=60 end
if y<=0 then y=60 end
end