게임 링크: http://lotusjk77.com/wp-content/game/tutorialcreateagame/index.html
jump_game
lotusjk77.com
개발 튜토리얼: https://youtu.be/dmzb3OYbA8o
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
init = function()
position = 0
hero_y = 0
hero_vy = 0
blades={200,300,400}
passed={0,0,0}
gameover = 0
score = 0
running_a = 0
end
update = function()
if gameover > 0 then
gameover = gameover + 1
if gameover > 120 then init() end
elseif running_a == 1 then
position = position + 2
hero_y = math.max(0, hero_y+hero_vy)
hero_vy = hero_vy - 0.3
if touch.touching and hero_y == 0 then
hero_vy = 7
end
for i=1, #blades do
if blades[i]<position-screen.width/2 then
blades[i] = position+screen.width/2+math.random()*400
passed[i] = 0
end
if math.abs(position-blades[i])<10 then
if hero_y<10 then
gameover = 1
elseif passed[i]==0 then
passed[i]=1
--print(passed[i])
score = score + 1
end
end
end
else
if touch.touching then running_a = 1 end
end -- end if gameover
end -- end update function
draw = function()
screen:fillRect(0,0, screen.width, screen.height, "rgb(57,0,57)")
screen:drawSprite("hero", 0-screen.width/4,-40+hero_y,46)
for i=-12,12 do
screen:drawSprite("wall", i*50-position%50,-75, 50)
--print(position%50)
end
for i=1, #blades do
screen:drawSprite("blade",blades[i]-position-screen.width/4,-50,20)
end
screen:drawText(score, 120, 80, 20, "#fff")
end
|
cs |
'루아(LUA) > 마이크로스튜디오' 카테고리의 다른 글
마이크로 스튜디오 루아로 키보드 ID 찾아내기 코드 (0) | 2022.01.11 |
---|---|
마이크로 스튜디오 여러줄 주석(comments) (0) | 2022.01.06 |
마이크로 스튜디오에서 루아 사용해 보기 (0) | 2022.01.04 |
마이크로 스튜디오 튜토리얼로 개발한 첫 게임 (0) | 2022.01.04 |
screen.fillRect() (0) | 2022.01.02 |