-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.rb
More file actions
98 lines (83 loc) · 2.36 KB
/
display.rb
File metadata and controls
98 lines (83 loc) · 2.36 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# coding: utf-8
require "dxopal"
require "dxruby"
include DXOpal
require_remote 'map.rb'
require_remote 'player.rb'
# ゲーム本体を表すクラス
class Game
GAME_INFO = {
scene: :home, # 現在のシーン(起動直後は:home)
}
def initialize
reset
end
# ゲームの状態をリセットする
def reset
$score = 0
$player.x = 270
$player.y = 761 - $player.h
$player.jflag = false
$player.vy = 0
$map.y = -1600
$ukis.each do |uki|
uki.init
end
GAME_INFO[:status]= 0
end
# ゲームを実行する
def run
Window.loop do
case GAME_INFO[:scene]
when :home
Window.draw(0, -1600,Image[:background])
Window.draw_scale(-80,200,Image[:title],0.7,0.7)
Window.draw_scale(-410,400,Image[:title_msg],0.4,0.4)
if Input.key_push?(K_ENTER)
GAME_INFO[:scene] = :playing
end
when :playing
$player.update
Sprite.check($player,$ukis)
$map.draw
$player.draw
$ukis.each do |uki|
uki.draw
end
Window.draw_font(600, 0, "SCORE: #{GAME_INFO[:score]}",Font.default)
#ゲームクリア
if($player.y == $ukis[16].y - $player.h)
GAME_INFO[:scene] = :resultclear
#ゲームオーバー
elsif($player.y > 800)
GAME_INFO[:scene] = :resultover
end
if Input.key_push?(K_G)
reset
GAME_INFO[:scene] = :resultclear
end
when :resultclear
Window.draw(0, -1600,Image[:background])
Window.draw_scale(-190,100,Image[:clear],0.6,0.6)
Window.draw_font(230,300,"SCORE: #{$score}",Font.default)
Window.draw_scale(-140,400,Image[:return],0.65,0.65)
if Input.key_push?(K_ENTER)
reset
GAME_INFO[:scene] = :home
end
when :resultover
Window.draw_scale(-160,100,Image[:over],0.6,0.6)
Window.draw_scale(-115,250,Image[:retry],0.7,0.7)
Window.draw_scale(160,550,Image[:ohh],2.3,2.3)
if Input.key_push?(K_ENTER)
reset
GAME_INFO[:scene] = :playing
end
if Input.key_push?(K_G)
reset
GAME_INFO[:scene] = :resultclear
end
end
end
end
end