ピコピココード
g=ppgraph
sc=ppscreen
T=true
F=false
rand=math.random
se=ppsemml[1]
sebang="o2l16crcrdrc"
B=pprect(0,0,320,480)
sc.setview=function(s,b)
s:viewport(s:layout(b))
local t
t=s:arrayto(pptouch())
s.touch=t
end
map=ppmap.new()
map:mapSize(21,36)
map:area({0,0,21,36})
map:texture(
ppfont:texture())
map:tileSize(8,8)
map:clear(0)
map:scale(2)
map:pos(-8,0)
s=sc:size()
ppvkey:center(
s.width/2,s.height*4/5)
ppvkey:fixed(true)
function start()
p=pppoint(10,20)
p.dx=0
m=pppoint(16,16)
ct=0
map:clear(0)
score=0
while true do
if not mainloop()
then
break
end
g:update()
end
local step=0
while true do
sc:setview(B)
map:draw()
if step>=0 then
step=step+1
if step>30 then
if #sc.touch==0
then
step=-10
end
end
else
if #sc.touch>0
then
break
end
end
g:pos(
(320-9*16)/2,200)
g:print(
"GAME OVER",g.red)
g:pos(0,0)
g:print(
"SCORE "..score)
g:update()
end
end
function mainloop()
local ret=true
sc:setview(B)
local d=ppvkey:dir(4)
map:draw()
if d==0 then
p.dx=1
end
if d==2 then
p.dx=-1
end
ct=ct+1
if ct>6 then
score=score+1
map:fill(
p.x,p.y,1,1,0)
p.x=p.x+p.dx
if p.x>20 then
p.x=20
end
if p.x<0 then
p.x=0
end
se:play("o5l16c")
ct=0
map:scroll(0,1)
map:locate(
rand(1,19),0)
map:attribute(
{color=g.yellow}
)
map:print("人")
map:attribute(
{color=g.gray}
)
map:locate(0,0)
map:print("#")
map:locate(20,0)
map:print("#")
map:attribute(
{color=g.white}
)
map:fill(
1,35,19,1,0)
if map:tile(p)~=0
then
ret=false
end
map:locate(p)
if ret then
map:print("車")
else
map:attribute(
{color=g.red}
)
se:play(sebang)
map:print("*")
end
end
local c
c=ppvkey:center()-m
g:scale(2)
g:pos(c/2)
g:move(1,-16+1)
g:move(16,16)
g:print("→")
g:move(-16,16)
g:move(-16,-16)
g:print("←")
g:scale(1)
g:pos(0,0)
g:print(score)
return ret
end