루아(LUA)/마이크로스튜디오_예제
점프게임 2022.1.4.
JK77
2022. 1. 9. 07:19
게임링크: http://lotusjk77.com/wp-content/game/tutorialcreateagame/index.html

프로그래밍언어: 마이크로스크립트
init = function()
blades = [400,500,600]
passed = [0,0,0]
gameover = 0
running = 0
score = 0
position = 0
speed = 2
end
update = function()
if gameover>0 then
gameover = gameover+1
if gameover>120 then init() end
elsif running then
position = position+speed
speed = speed + 0.001
if touch.touching and hero_y == 0 then
hero_vy = 7
audio.beep("square tempo 20000 volume 10 span 100 C4 to C6")
end
hero_y = max(0, hero_y + hero_vy)
hero_vy = hero_vy - 0.3
//print(position)
for i=0 to blades.length-1
if blades[i]<position-screen.width/2 then
blades[i] = position+screen.width/2+random.next()*200
passed[i] = 0
//print("blades"+[i]+":"+(blades[i]-position))
//print(random.next())
//print("position:"+position)
end
if abs(position-blades[i])<10 then
if hero_y<10 then
//print("abs")
running = 0
gameover = 1
audio.beep("saw tempo 10000 volume 50 span 50 C2 to C4 to C2 to C4")
elsif not passed[i] then
passed[i] = 1
score += 1
audio.beep("saw tempo 960 volume 50 span 20 C6")
end
end
end
else
if touch.touching then running = 1 end
end
end //update function end
draw = function()
screen.fillRect(0,0,screen.width,screen.height,"rgb(57,0,57)")
for i=-30 to 30 by 1
screen.drawSprite("wall",i*40-position%40,-80,40)
end
screen.drawSprite("hero",0-screen.width/4,-53+hero_y,40)
for i=0 to blades.length-1
//if blades[i]-position<screen.width/2 then
//end
screen.drawSprite("blade",blades[i]-position-screen.width/4,-59,20)
end
screen.drawText(score,120,80,20,"#FFF")
if gameover then
screen.fillRect(0,0,screen.width,screen.height,"rgba(255,0,0,.5)")
screen.drawText("GAME OVER",0,0,50,"#FFF")
end
end