| | 183 | def demo_nario_fly |
| | 184 | |
| | 185 | SDL.init(SDL::INIT_EVERYTHING) |
| | 186 | screen = SDL.set_video_mode(SCREEN_W, SCREEN_H, 16, SDL::SWSURFACE) |
| | 187 | |
| | 188 | chara = SDL::Surface.load("nario/image/left_nario.bmp") |
| | 189 | x = 240 |
| | 190 | y = HOLIZON |
| | 191 | |
| | 192 | input = Input.new |
| | 193 | timer = FPSTimerLight.new |
| | 194 | timer.reset |
| | 195 | loop do |
| | 196 | input.poll |
| | 197 | break if input.exit |
| | 198 | |
| | 199 | x -= 8 if input.left |
| | 200 | x += 8 if input.right |
| | 201 | x = 0 if x < 0 |
| | 202 | x = SCREEN_W-chara.w if x >= SCREEN_W-chara.w |
| | 203 | |
| | 204 | # Up, Donwボタンの導入 |
| | 205 | y -= 8 if input.up |
| | 206 | y += 8 if input.down |
| | 207 | y = 0 if y < 0 |
| | 208 | y = HOLIZON-chara.h if y >= HOLIZON-chara.h |
| | 209 | |
| | 210 | screen.fill_rect(0, 0, SCREEN_W, HOLIZON, [255, 255, 255]) |
| | 211 | screen.fill_rect(0, HOLIZON, SCREEN_W, SCREEN_H-HOLIZON, [0, 128, 0]) |
| | 212 | screen.put(chara, x, y) |
| | 213 | timer.wait_frame do |
| | 214 | screen.update_rect(0, 0, 0, 0) |
| | 215 | end |
| | 216 | end |
| | 217 | end |
| | 218 | |
| 229 | | opt.on("-1", "--demo-init-display"){ demo_init_display() } |
| 230 | | opt.on("-2", "--demo_make_ground"){ demo_make_ground() } |
| 231 | | opt.on("-3", "--demo-make_nario"){ demo_make_nario() } |
| 232 | | opt.on("-4", "--demo-nario-walk"){ demo_nario_walk() } |
| 233 | | opt.on("-5", "--demo-nario-walk-fps"){ demo_nario_walk_fps() } |
| 234 | | opt.on("-6", "--demo-nario-controll"){ demo_nario_controll() } |
| 235 | | opt.on("-7", "--demo-nario-input"){ demo_nario_input() } |
| 236 | | opt.on("-8", "--demo-nario-fly"){ demo_nario_fly() } |
| 237 | | opt.on("-9", "--demo-nario-jump"){ demo_nario_jump() } |
| | 265 | opt.on("-1", "--init-display"){ demo_init_display() } |
| | 266 | opt.on("-2", "--make_ground"){ demo_make_ground() } |
| | 267 | opt.on("-3", "--make_nario"){ demo_make_nario() } |
| | 268 | opt.on("-4", "--nario-walk"){ demo_nario_walk() } |
| | 269 | opt.on("-5", "--nario-walk-fps"){ demo_nario_walk_fps() } |
| | 270 | opt.on("-6", "--nario-controll"){ demo_nario_controll() } |
| | 271 | opt.on("-7", "--nario-input"){ demo_nario_input() } |
| | 272 | opt.on("-8", "--nario-fly"){ demo_nario_fly() } |
| | 273 | opt.on("-9", "--nario-jump"){ demo_nario_jump() } |