diff --git a/explain/amasagi_ex.png b/explain/amasagi_ex.png new file mode 100644 index 0000000..7c24778 Binary files /dev/null and b/explain/amasagi_ex.png differ diff --git a/explain/koi_ex.png b/explain/koi_ex.png new file mode 100644 index 0000000..270f882 Binary files /dev/null and b/explain/koi_ex.png differ diff --git a/explain/morogeebi_ex.png b/explain/morogeebi_ex.png new file mode 100644 index 0000000..26e182f Binary files /dev/null and b/explain/morogeebi_ex.png differ diff --git a/explain/shizimi_ex.png b/explain/shizimi_ex.png new file mode 100644 index 0000000..6281ae6 Binary files /dev/null and b/explain/shizimi_ex.png differ diff --git a/explain/sirauo_ex.png b/explain/sirauo_ex.png new file mode 100644 index 0000000..c8cba89 Binary files /dev/null and b/explain/sirauo_ex.png differ diff --git a/explain/suzuki_ex.png b/explain/suzuki_ex.png new file mode 100644 index 0000000..5c2c273 Binary files /dev/null and b/explain/suzuki_ex.png differ diff --git a/explain/unagi_ex.png b/explain/unagi_ex.png new file mode 100644 index 0000000..2a21ea4 Binary files /dev/null and b/explain/unagi_ex.png differ diff --git a/images/title.png b/images/title.png new file mode 100644 index 0000000..0ee9642 Binary files /dev/null and b/images/title.png differ diff --git a/main.rb b/main.rb new file mode 100644 index 0000000..9d72cc8 --- /dev/null +++ b/main.rb @@ -0,0 +1,21 @@ +require 'dxruby' + +require_relative 'scene' +require_relative 'scenes/load_scene' + + + +Window.caption = "RubyCamp Example" +Window.width = 900 +Window.height = 563 + +bgm = Sound.new("sounds/bgm.mid") + +Scene.move_to(:travel) +# bgm.play + +Window.loop do + Scene.play + + break if Input.key_push?(K_ESCAPE) +end diff --git a/scene.rb b/scene.rb new file mode 100644 index 0000000..8a3a762 --- /dev/null +++ b/scene.rb @@ -0,0 +1,19 @@ +class Scene + @@scenes = {} + + @@current_scene_name = nil + + def self.add(scene_obj, scene_name) + @@scenes[scene_name.to_sym] = scene_obj + end + + + def self.move_to(scene_name) + @@current_scene_name = scene_name.to_sym + end + + + def self.play + @@scenes[@@current_scene_name].play + end +end diff --git a/scenes/credit/director.rb b/scenes/credit/director.rb new file mode 100644 index 0000000..e2222cd --- /dev/null +++ b/scenes/credit/director.rb @@ -0,0 +1,57 @@ +module Credit + class Director + FONT_SIZE = 30 + def initialize + @words = %w( + player nanami0408さんによる写真ACからの写真 https://www.ac-illust.com/ + うなぎ 三浦さくさんによるイラストACからのイラスト 〃 + わかさぎ HiCさんによる写真ACからの写真 〃 + しらうお Hinamaluさんによる写真ACからの写真 〃 + こい わーい!たむたむさんによる写真ACからの写真  〃 + すずき photolibrary https://www.photolibrary.jp + しじみ ねこ画伯コハクちゃん https://kohacu.com/20170513post-9047 + えび パブリックドメインQ:著作権フリー画像素材集  + https://publicdomainq.net/boiled-shrimp-food-0015019/ + 背景 〃 〃 + タイトル背景 ばんない堂 https://098free.com/rule/ +   +   + 製作者 +   + 松田陸斗 + 青砥朋紀 + 平池竜大 + 吉見昂大 + 福間陽菜 +   +   +   +   +   +   +   +   +   +   +   +   + Thank you + ) + @font = Font.new(FONT_SIZE, 'MS 明朝', weight: true) + @scroll_y = 0 + end + + def play + @scroll_y += 1 unless Input.key_down?(K_SPACE) + @scroll_y += 5 if Input.key_down?(K_RETURN) + frame_out = [] + + @words.each_with_index do |word, i| + draw_x = Window.width / 30 + draw_y = (Window.height + i * FONT_SIZE) - @scroll_y + # 文字にマウスオーバーしていたら赤色を指定する + Window.draw_font(draw_x, draw_y, word, @font) + end + end +end +end diff --git a/scenes/ending/director.rb b/scenes/ending/director.rb new file mode 100644 index 0000000..563f78f --- /dev/null +++ b/scenes/ending/director.rb @@ -0,0 +1,15 @@ +module Ending + class Director + def initialize + @edImg = Image.load("scenes/ending/image/ending.png") + end + + def play + Scene.move_to(:credit) if Input.key_push?(K_SPACE) + + Scene.move_to(:opening) if Input.key_push?(K_Q) + + Window.draw(0, 0,@edImg) + end + end +end diff --git a/scenes/ending/image/ending.png b/scenes/ending/image/ending.png new file mode 100644 index 0000000..1d99896 Binary files /dev/null and b/scenes/ending/image/ending.png differ diff --git a/README.md b/scenes/game/README.md similarity index 100% rename from README.md rename to scenes/game/README.md diff --git a/scenes/game/attack.rb b/scenes/game/attack.rb new file mode 100644 index 0000000..aa0a508 --- /dev/null +++ b/scenes/game/attack.rb @@ -0,0 +1,25 @@ +class Attack (Window.width - self.image.width) + + end + + def shot(obj) + self.vanish if obj.is_a?(Enemy) + end + + # def hit(obj) + # puts "b" + # obj.vanish + # end +end diff --git a/scenes/game/background.rb b/scenes/game/background.rb new file mode 100644 index 0000000..6e41506 --- /dev/null +++ b/scenes/game/background.rb @@ -0,0 +1,50 @@ + class Background < Sprite + attr_accessor :dx + attr_accessor :dy + + def move_right + self.x += dx + dx > 0? left_scroll_check : right_scroll_check + end + + def left_scroll_check + self.x = -Window.width if self.x >= Window.width + end + + def right_scroll_check + self.x = Window.width - 1 if self.x + Window.width < 0 + end + + + + def move_left + self.x += 1 + left_scroll_check + end + + + + + def move_down + self.y+=dy + dy > 0? down_scroll_check : up_scroll_check + end + + def up_scroll_check + self.y= -Window.height if self.y>= Window.height + end + + def down_scroll_check + self.y = Window.heigt - 1 if self.y + Window.heigt< 0 + end + + + + + def move_up + self.y+= 1 + up_scroll_check + end + + +end \ No newline at end of file diff --git a/scenes/game/chase_enemy.rb b/scenes/game/chase_enemy.rb new file mode 100644 index 0000000..58bc4d5 --- /dev/null +++ b/scenes/game/chase_enemy.rb @@ -0,0 +1,7 @@ +class ChaseEnemy < Enemy + def move(player) + super + self.x += 2 * @dx * ((player.x - self.x) > 0?1:-1) + self.y += 2 * @dy * ((player.y - self.y) > 0?1:-1) + end +end diff --git a/scenes/game/director.rb b/scenes/game/director.rb new file mode 100644 index 0000000..493a444 --- /dev/null +++ b/scenes/game/director.rb @@ -0,0 +1,170 @@ +require_relative 'enemy' +require_relative 'normal_enemy' +require_relative 'speed_enemy' +require_relative 'chase_enemy' +require_relative 'player' +require_relative 'shittin' +require_relative 'display' +require_relative 'background' +require_relative 'attack' + +module Game + class Director + NOMAL_ENEMY_NUMBER = 5 + SPEED_ENEMY_NUMBER = 5 + CHASE_ENEMY_NUMBER = 5 + TIMER_SPEED = 0.4 + + def initialize + @bg_img = Image.load("scenes/game/image/backscreen_loop.png") + @backgrounds = [ + Background.new(Window.width, 0, @bg_img), + Background.new(0, 0, @bg_img), + Background.new(Window.width, Window.height, @bg_img), + Background.new(0, Window.height, @bg_img), + ] + @backgrounds.map{|obj| obj.dx = -1 } + @backgrounds.map{|obj| obj.dy = -1 } + + suzuki_img = Image.load("scenes/game/image/suzuki.png") + @suzuki = Shittin.new(300, 300, suzuki_img) + morogeebi_img = Image.load("scenes/game/image/ebi.png") + @morogeebi = Shittin.new(200, 450, morogeebi_img) + unagi_img = Image.load("scenes/game/image/unagi.png") + @unagi = Shittin.new(300, 400, unagi_img) + amasagi_img = Image.load("scenes/game/image/wakasagi.png") + @amasagi = Shittin.new(500, 300, amasagi_img) + shizimi_img = Image.load("scenes/game/image/shizimi.png") + @shizimi = Shittin.new(300, 500, shizimi_img) + koi_img = Image.load("scenes/game/image/koi.png") + @koi = Shittin.new(100, 300, koi_img) + sirauo_img = Image.load("scenes/game/image/shirauo.png") + @sirauo = Shittin.new(300, 100, sirauo_img) + @shittin = [@suzuki, @morogeebi, @unagi, @amasagi, @shizimi, @koi, @sirauo] + @shittin.each_with_index do |shittin, i| + shittin.collision_enable = false + end + @hit_count = 0 + + # enemy_img = Image.load('scenes/game/image/kuribo1.png') + normal_enemy_img = Image.load("scenes/game/image/teki_harisenbon.png") + speed_enemy_img = Image.new(20, 20, [0, 255, 0]) + chase_enemy_img = Image.new(20, 20, [0, 0, 255]) + @enemys = [] + NOMAL_ENEMY_NUMBER.times do + @enemys << NomalEnemy.new(rand(300)+150, rand(300)+150, normal_enemy_img) + end + SPEED_ENEMY_NUMBER.times do + @enemys << SpeedEnemy.new(rand(300)+150, rand(300)+150, speed_enemy_img) + end + CHASE_ENEMY_NUMBER.times do + @enemys << ChaseEnemy.new(rand(300)+150, rand(300)+150, chase_enemy_img) + end + + player_img = Image.load('scenes/game/image/player.png') + @player = Player.new(100, 100, player_img) + + @attack_image = Image.new(10, 10, [255, 0, 0])#("scenes/game/image/kuribo1.png") + @attacks = [] + + @player.collision = [20,20,20] + @enemys.each{|enemy| enemy.collision = [10,10,10]} + + @font_push_space = Font.new(80) + @font_timer = Font.new(22, 'MS 明朝', weight: true, auto_fitting: true) + + + @sound = Sound.new("scenes/game/sound/sound.wav") + + @timer_img = Image.new(600, 22, [0, 0, 255]) + @time = 300 + + @fps_counter = 0 + end + + def play + Scene.move_to(:gameover) if @time >= 900 + Scene.move_to(:gameover) if !(@player.check(@enemys).empty?) + + # if Input.key_down?(K_RIGHT) + # @backgrounds.map(&:move_right) + # end + # if Input.key_down?(K_LEFT) + # @backgrounds.map(&:move_left) + # end + # if Input.key_down?(K_DOWN) + # @backgrounds.map(&:move_down) + # end + # if Input.key_down?(K_UP) + # @backgrounds.map(&:move_up) + # end + + @backgrounds.map(&:draw) + + + if @hit_count <= 6 + @shittin[@hit_count<=6 ? @hit_count : 6].move(@player) + @shittin[@hit_count<=6 ? @hit_count : 6].draw + @shittin[@hit_count<=6 ? @hit_count : 6].collision_enable = true + @shittin[@hit_count<=6 ? @hit_count-1 : 6].collision_enable = false + else + @shittin[6].collision_enable = false + end + if !(@shittin[@hit_count<=6 ? @hit_count : 6].check(@player).empty?) + Window.loop do + Window.draw(0,0,@bg_img) + break if Input.key_push?(K_SPACE) + end + @hit_count += 1 + end + + display(@hit_count) + Scene.move_to(:ending) if (@hit_count >= 7 && Input.key_push?(K_SPACE)) + + @enemys.each{|enemy| enemy.move(@player)} + @enemys.each{|enemy| enemy.draw} + @player.down if Input.key_down?(K_DOWN) + @player.up if Input.key_down?(K_UP) + @player.right if Input.key_down?(K_RIGHT) + @player.left if Input.key_down?(K_LEFT) + @player.draw + + if Input.key_down?(K_LSHIFT) && @fps_counter % 30 == 0 + @attacks << Attack.new(@player.x+40,@player.y+20,@attack_image) + end + + Sprite.check(@attacks, @enemys) + + @attacks.each_with_index do |attack, i| + + attack.move + attack.draw + + + + # if attack.window_out + # attack.vanish + # @attacks.delete(i) + # end + # if !(attack.check(@enemys).empty?) + # attack.check(@emenys).each_with_index do |enemy, i| + # enemy.vanish + # end + # end + end + + if @fps_counter % 60 >= 30 + Window.draw_font(230, 220, "PUSH SPACE", @font_push_space) if @hit_count >= 7 + end + + Window.draw(@time, 0, @timer_img) + @time += TIMER_SPEED + + Window.draw_font(800, 0, 'タイマー', @font_timer) + + @sound.play if !(@player.check(@shittin).empty?) + + @fps_counter += 1 + end + end +end diff --git a/scenes/game/display.rb b/scenes/game/display.rb new file mode 100644 index 0000000..53b8f79 --- /dev/null +++ b/scenes/game/display.rb @@ -0,0 +1,9 @@ +def display(hit_count) + chars = ["ス","モ","ウ","ア","シ","コ","シ"] + + font = Font.new(50) + + chars.first(hit_count).each_with_index do |char, i| + Window.draw_font((10+(i*50)),500,char,font) + end +end diff --git a/scenes/game/enemy.rb b/scenes/game/enemy.rb new file mode 100644 index 0000000..ca828ff --- /dev/null +++ b/scenes/game/enemy.rb @@ -0,0 +1,22 @@ +class Enemy < Sprite + def initialize(x, y, img) + # @x, @y = x, y + # @image = Image.load(image_file) + # @image.set_color_key([0, 0, 0]) + super + @dx = 1 + @dy = 1 + end + # def draw + # Window.draw(@x, @y, @image) + # end + + def move(player) + @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + end + + def hit(obj) + self.vanish if obj.is_a?(Attack) + end +end diff --git a/scenes/game/ghost.png b/scenes/game/ghost.png new file mode 100644 index 0000000..28edb3d Binary files /dev/null and b/scenes/game/ghost.png differ diff --git a/scenes/game/image/Mario1.png b/scenes/game/image/Mario1.png new file mode 100644 index 0000000..64d065c Binary files /dev/null and b/scenes/game/image/Mario1.png differ diff --git a/scenes/game/image/background.png b/scenes/game/image/background.png new file mode 100644 index 0000000..1768dfc Binary files /dev/null and b/scenes/game/image/background.png differ diff --git a/scenes/game/image/backscreen_loop.png b/scenes/game/image/backscreen_loop.png new file mode 100644 index 0000000..f4e67e0 Binary files /dev/null and b/scenes/game/image/backscreen_loop.png differ diff --git a/scenes/game/image/ebi.png b/scenes/game/image/ebi.png new file mode 100644 index 0000000..ec51052 Binary files /dev/null and b/scenes/game/image/ebi.png differ diff --git a/scenes/game/image/koi.png b/scenes/game/image/koi.png new file mode 100644 index 0000000..4559793 Binary files /dev/null and b/scenes/game/image/koi.png differ diff --git a/scenes/game/image/kuribo1.png b/scenes/game/image/kuribo1.png new file mode 100644 index 0000000..d69ebfe Binary files /dev/null and b/scenes/game/image/kuribo1.png differ diff --git a/scenes/game/image/ocean_kaichu_post.png b/scenes/game/image/ocean_kaichu_post.png new file mode 100644 index 0000000..86eef76 Binary files /dev/null and b/scenes/game/image/ocean_kaichu_post.png differ diff --git a/scenes/game/image/player.jpg b/scenes/game/image/player.jpg new file mode 100644 index 0000000..7255b6e Binary files /dev/null and b/scenes/game/image/player.jpg differ diff --git a/scenes/game/image/player.png b/scenes/game/image/player.png new file mode 100644 index 0000000..55116cd Binary files /dev/null and b/scenes/game/image/player.png differ diff --git a/scenes/game/image/player_new.png b/scenes/game/image/player_new.png new file mode 100644 index 0000000..0977ae1 Binary files /dev/null and b/scenes/game/image/player_new.png differ diff --git a/scenes/game/image/shirauo.png b/scenes/game/image/shirauo.png new file mode 100644 index 0000000..c23b80a Binary files /dev/null and b/scenes/game/image/shirauo.png differ diff --git a/scenes/game/image/shizimi.png b/scenes/game/image/shizimi.png new file mode 100644 index 0000000..d93a3a4 Binary files /dev/null and b/scenes/game/image/shizimi.png differ diff --git a/scenes/game/image/speed_enemy.png b/scenes/game/image/speed_enemy.png new file mode 100644 index 0000000..f9c0c33 Binary files /dev/null and b/scenes/game/image/speed_enemy.png differ diff --git a/scenes/game/image/suzuki.png b/scenes/game/image/suzuki.png new file mode 100644 index 0000000..887c66f Binary files /dev/null and b/scenes/game/image/suzuki.png differ diff --git a/scenes/game/image/teki_harisenbon.png b/scenes/game/image/teki_harisenbon.png new file mode 100644 index 0000000..56376b8 Binary files /dev/null and b/scenes/game/image/teki_harisenbon.png differ diff --git a/scenes/game/image/unagi.png b/scenes/game/image/unagi.png new file mode 100644 index 0000000..f309443 Binary files /dev/null and b/scenes/game/image/unagi.png differ diff --git a/scenes/game/image/wakasagi.png b/scenes/game/image/wakasagi.png new file mode 100644 index 0000000..ffd8874 Binary files /dev/null and b/scenes/game/image/wakasagi.png differ diff --git a/scenes/game/normal_enemy.rb b/scenes/game/normal_enemy.rb new file mode 100644 index 0000000..47e344a --- /dev/null +++ b/scenes/game/normal_enemy.rb @@ -0,0 +1,7 @@ +class NomalEnemy < Enemy + def move(obj) + super + self.x += (rand(4)-2) * @dx + self.y += (rand(4)-2) * @dx + end +end diff --git a/scenes/game/player.rb b/scenes/game/player.rb new file mode 100644 index 0000000..2021323 --- /dev/null +++ b/scenes/game/player.rb @@ -0,0 +1,15 @@ +class Player < Sprite + + def up + self.y -= 5 unless self.y < 0 + end + def down + self.y += 5 unless self.y > (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end diff --git a/scenes/game/shittin.rb b/scenes/game/shittin.rb new file mode 100644 index 0000000..8435e7d --- /dev/null +++ b/scenes/game/shittin.rb @@ -0,0 +1,14 @@ +class Shittin < Sprite + def initialize(x, y, img) + super + @dx = 1 + @dy = 1 + end + def move(player) + # @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + # @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + + self.x > (Window.width - self.image.width) || self.x < 0 ? self.x = self.x : self.x += 0.5 * ((self.x - player.x) > 0?1:-1) + self.y > (Window.height - self.image.height) || self.y < 0 ? self.y = self.y : self.y += 0.5 * ((self.y - player.y) > 0?1:-1) + end +end diff --git a/scenes/game/sound/sound.wav b/scenes/game/sound/sound.wav new file mode 100644 index 0000000..4ac1709 Binary files /dev/null and b/scenes/game/sound/sound.wav differ diff --git a/scenes/game/speed_enemy.rb b/scenes/game/speed_enemy.rb new file mode 100644 index 0000000..8293d11 --- /dev/null +++ b/scenes/game/speed_enemy.rb @@ -0,0 +1,9 @@ +class SpeedEnemy < Enemy + def move(obj) + super + + self.x += (rand(10)-1) * @dx + self.y += (rand(10)-1) * @dy + + end +end diff --git a/scenes/game/test.rb b/scenes/game/test.rb new file mode 100644 index 0000000..5f4ca13 --- /dev/null +++ b/scenes/game/test.rb @@ -0,0 +1,7 @@ +def foo(a, b) + return a + b +end + +puts foo(3,4) + +a = 2 diff --git a/scenes/game_easy/README.md b/scenes/game_easy/README.md new file mode 100644 index 0000000..e01f1e6 --- /dev/null +++ b/scenes/game_easy/README.md @@ -0,0 +1,2 @@ +# rc2019su_g2 +RubyCamp2019Summer Group2 diff --git a/scenes/game_easy/attack.rb b/scenes/game_easy/attack.rb new file mode 100644 index 0000000..aa0a508 --- /dev/null +++ b/scenes/game_easy/attack.rb @@ -0,0 +1,25 @@ +class Attack (Window.width - self.image.width) + + end + + def shot(obj) + self.vanish if obj.is_a?(Enemy) + end + + # def hit(obj) + # puts "b" + # obj.vanish + # end +end diff --git a/scenes/game_easy/background.rb b/scenes/game_easy/background.rb new file mode 100644 index 0000000..6e41506 --- /dev/null +++ b/scenes/game_easy/background.rb @@ -0,0 +1,50 @@ + class Background < Sprite + attr_accessor :dx + attr_accessor :dy + + def move_right + self.x += dx + dx > 0? left_scroll_check : right_scroll_check + end + + def left_scroll_check + self.x = -Window.width if self.x >= Window.width + end + + def right_scroll_check + self.x = Window.width - 1 if self.x + Window.width < 0 + end + + + + def move_left + self.x += 1 + left_scroll_check + end + + + + + def move_down + self.y+=dy + dy > 0? down_scroll_check : up_scroll_check + end + + def up_scroll_check + self.y= -Window.height if self.y>= Window.height + end + + def down_scroll_check + self.y = Window.heigt - 1 if self.y + Window.heigt< 0 + end + + + + + def move_up + self.y+= 1 + up_scroll_check + end + + +end \ No newline at end of file diff --git a/scenes/game_easy/chase_enemy.rb b/scenes/game_easy/chase_enemy.rb new file mode 100644 index 0000000..58bc4d5 --- /dev/null +++ b/scenes/game_easy/chase_enemy.rb @@ -0,0 +1,7 @@ +class ChaseEnemy < Enemy + def move(player) + super + self.x += 2 * @dx * ((player.x - self.x) > 0?1:-1) + self.y += 2 * @dy * ((player.y - self.y) > 0?1:-1) + end +end diff --git a/scenes/game_easy/director.rb b/scenes/game_easy/director.rb new file mode 100644 index 0000000..70d4dbb --- /dev/null +++ b/scenes/game_easy/director.rb @@ -0,0 +1,181 @@ +require_relative 'enemy' +require_relative 'normal_enemy' +require_relative 'speed_enemy' +require_relative 'chase_enemy' +require_relative 'player' +require_relative 'shittin' +require_relative 'display' +require_relative 'background' +require_relative 'attack' + +module GameEasy + class Director + NOMAL_ENEMY_NUMBER = 10 + # SPEED_ENEMY_NUMBER = 5 + # CHASE_ENEMY_NUMBER = 5 + TIMER_SPEED = 0.3 + + def initialize + @bg_img = Image.load("scenes/game_easy/image/backscreen_loop.png") + @backgrounds = [ + Background.new(Window.width, 0, @bg_img), + Background.new(0, 0, @bg_img), + Background.new(Window.width, Window.height, @bg_img), + Background.new(0, Window.height, @bg_img), + ] + @backgrounds.map{|obj| obj.dx = -1 } + @backgrounds.map{|obj| obj.dy = -1 } + + @suzuki_ex = Image.load("explain/suzuki_ex.png") + @morogeebi_ex = Image.load("explain/morogeebi_ex.png") + @unagi_ex = Image.load("explain/unagi_ex.png") + @amasagi_ex = Image.load("explain/amasagi_ex.png") + @shizimi_ex = Image.load("explain/shizimi_ex.png") + @koi_ex = Image.load("explain/koi_ex.png") + @sirauo_ex = Image.load("explain/sirauo_ex.png") + @shittin_ex = [@suzuki_ex, @morogeebi_ex, @unagi_ex, @amasagi_ex, @shizimi_ex, @koi_ex, @sirauo_ex] + + + suzuki_img = Image.load("scenes/game_easy/image/suzuki.png") + @suzuki = Shittin.new(300, 300, suzuki_img) + morogeebi_img = Image.load("scenes/game_easy/image/ebi.png") + @morogeebi = Shittin.new(200, 450, morogeebi_img) + unagi_img = Image.load("scenes/game_easy/image/unagi.png") + @unagi = Shittin.new(300, 400, unagi_img) + amasagi_img = Image.load("scenes/game_easy/image/wakasagi.png") + @amasagi = Shittin.new(500, 300, amasagi_img) + shizimi_img = Image.load("scenes/game_easy/image/shizimi.png") + @shizimi = Shittin.new(300, 500, shizimi_img) + koi_img = Image.load("scenes/game_easy/image/koi.png") + @koi = Shittin.new(100, 300, koi_img) + sirauo_img = Image.load("scenes/game_easy/image/shirauo.png") + @sirauo = Shittin.new(300, 100, sirauo_img) + @shittin = [@suzuki, @morogeebi, @unagi, @amasagi, @shizimi, @koi, @sirauo] + @shittin.each_with_index do |shittin, i| + shittin.collision_enable = false + end + @hit_count = 0 + + # enemy_img = Image.load('scenes/game_easy/image/kuribo1.png') + normal_enemy_img = Image.load("scenes/game_easy/image/teki_harisenbon.png") + speed_enemy_img = Image.load("scenes/game_easy/image/speed_enemy.png") + chase_enemy_img = Image.load("scenes/game_easy/image/matz.png") + @enemys = [] + NOMAL_ENEMY_NUMBER.times do + @enemys << NomalEnemy.new(rand(300)+150, rand(300)+150, normal_enemy_img) + end + # SPEED_ENEMY_NUMBER.times do + # @enemys << SpeedEnemy.new(rand(300)+150, rand(300)+150, speed_enemy_img) + # end + # CHASE_ENEMY_NUMBER.times do + # @enemys << ChaseEnemy.new(rand(300)+150, rand(300)+150, chase_enemy_img) + # end + + player_img = Image.load("scenes/game_easy/image/ocean_kaichu_post.png") + @player = Player.new(100, 100, player_img) + + @attack_image = Image.new(10, 10, [255, 0, 0])#("scenes/game_easy/image/kuribo1.png") + @attacks = [] + + @player.collision = [20,20,20] + @enemys.each{|enemy| enemy.collision = [20,20,20]} + + @font_push_space = Font.new(40) + @font_timer = Font.new(22, 'MS 明朝', weight: true, auto_fitting: true) + + + @sound = Sound.new("scenes/game_easy/sound/sound.wav") + + @timer_img = Image.new(600, 22, [0, 0, 255]) + @time = 300 + + @fps_counter = 0 + end + + def play + Scene.move_to(:gameover) if @time >= 900 + Scene.move_to(:gameover) if !(@player.check(@enemys).empty?) + + # if Input.key_down?(K_RIGHT) + # @backgrounds.map(&:move_right) + # end + # if Input.key_down?(K_LEFT) + # @backgrounds.map(&:move_left) + # end + # if Input.key_down?(K_DOWN) + # @backgrounds.map(&:move_down) + # end + # if Input.key_down?(K_UP) + # @backgrounds.map(&:move_up) + # end + + @backgrounds.map(&:draw) + + + if @hit_count <= 6 + @shittin[@hit_count<=6 ? @hit_count : 6].move(@player) + @shittin[@hit_count<=6 ? @hit_count : 6].draw + @shittin[@hit_count<=6 ? @hit_count : 6].collision_enable = true + @shittin[@hit_count<=6 ? @hit_count-1 : 6].collision_enable = false + else + @shittin[6].collision_enable = false + end + if !(@shittin[@hit_count<=6 ? @hit_count : 6].check(@player).empty?) + Window.loop do + Window.draw(50,50,@shittin_ex[@hit_count<=6 ? @hit_count : 6]) + Window.draw_font(600, 520, "PUSH SPACE", @font_push_space) + break if Input.key_push?(K_SPACE) + end + @hit_count += 1 + end + + display(@hit_count) + Scene.move_to(:ending) if (@hit_count >= 7 && Input.key_push?(K_RETURN)) + + @enemys.each{|enemy| enemy.move(@player)} + @enemys.each{|enemy| enemy.draw} + @player.down if Input.key_down?(K_DOWN) + @player.up if Input.key_down?(K_UP) + @player.right if Input.key_down?(K_RIGHT) + @player.left if Input.key_down?(K_LEFT) + @player.draw + + if Input.key_down?(K_LSHIFT) && @fps_counter % 20 == 0 + @attacks << Attack.new(@player.x+40,@player.y+20,@attack_image) + end + + Sprite.check(@attacks, @enemys) + + @attacks.each_with_index do |attack, i| + + attack.move + attack.draw + + + + # if attack.window_out + # attack.vanish + # @attacks.delete(i) + # end + # if !(attack.check(@enemys).empty?) + # attack.check(@emenys).each_with_index do |enemy, i| + # enemy.vanish + # end + # end + end + + if @fps_counter % 60 >= 30 + Window.draw_font(230, 220, "ENTERキーを押してください", @font_push_space) if @hit_count >= 7 + end + + Window.draw(@time, 0, @timer_img) + @time += TIMER_SPEED + + Window.draw_font(800, 0, 'タイマー', @font_timer) + + @sound.play if !(@player.check(@shittin).empty?) + + @fps_counter += 1 + end + end +end diff --git a/scenes/game_easy/display.rb b/scenes/game_easy/display.rb new file mode 100644 index 0000000..53b8f79 --- /dev/null +++ b/scenes/game_easy/display.rb @@ -0,0 +1,9 @@ +def display(hit_count) + chars = ["ス","モ","ウ","ア","シ","コ","シ"] + + font = Font.new(50) + + chars.first(hit_count).each_with_index do |char, i| + Window.draw_font((10+(i*50)),500,char,font) + end +end diff --git a/scenes/game_easy/enemy.rb b/scenes/game_easy/enemy.rb new file mode 100644 index 0000000..ca828ff --- /dev/null +++ b/scenes/game_easy/enemy.rb @@ -0,0 +1,22 @@ +class Enemy < Sprite + def initialize(x, y, img) + # @x, @y = x, y + # @image = Image.load(image_file) + # @image.set_color_key([0, 0, 0]) + super + @dx = 1 + @dy = 1 + end + # def draw + # Window.draw(@x, @y, @image) + # end + + def move(player) + @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + end + + def hit(obj) + self.vanish if obj.is_a?(Attack) + end +end diff --git a/scenes/game_easy/ghost.png b/scenes/game_easy/ghost.png new file mode 100644 index 0000000..28edb3d Binary files /dev/null and b/scenes/game_easy/ghost.png differ diff --git a/scenes/game_easy/image/Mario1.png b/scenes/game_easy/image/Mario1.png new file mode 100644 index 0000000..64d065c Binary files /dev/null and b/scenes/game_easy/image/Mario1.png differ diff --git a/scenes/game_easy/image/background.png b/scenes/game_easy/image/background.png new file mode 100644 index 0000000..1768dfc Binary files /dev/null and b/scenes/game_easy/image/background.png differ diff --git a/scenes/game_easy/image/backscreen_loop.png b/scenes/game_easy/image/backscreen_loop.png new file mode 100644 index 0000000..f4e67e0 Binary files /dev/null and b/scenes/game_easy/image/backscreen_loop.png differ diff --git a/scenes/game_easy/image/ebi.png b/scenes/game_easy/image/ebi.png new file mode 100644 index 0000000..ec51052 Binary files /dev/null and b/scenes/game_easy/image/ebi.png differ diff --git a/scenes/game_easy/image/koi.png b/scenes/game_easy/image/koi.png new file mode 100644 index 0000000..4559793 Binary files /dev/null and b/scenes/game_easy/image/koi.png differ diff --git a/scenes/game_easy/image/kuribo1.png b/scenes/game_easy/image/kuribo1.png new file mode 100644 index 0000000..d69ebfe Binary files /dev/null and b/scenes/game_easy/image/kuribo1.png differ diff --git a/scenes/game_easy/image/matz.png b/scenes/game_easy/image/matz.png new file mode 100644 index 0000000..8b52cc7 Binary files /dev/null and b/scenes/game_easy/image/matz.png differ diff --git a/scenes/game_easy/image/ocean_kaichu_post.png b/scenes/game_easy/image/ocean_kaichu_post.png new file mode 100644 index 0000000..86eef76 Binary files /dev/null and b/scenes/game_easy/image/ocean_kaichu_post.png differ diff --git a/scenes/game_easy/image/player.jpg b/scenes/game_easy/image/player.jpg new file mode 100644 index 0000000..7255b6e Binary files /dev/null and b/scenes/game_easy/image/player.jpg differ diff --git a/scenes/game_easy/image/player.png b/scenes/game_easy/image/player.png new file mode 100644 index 0000000..55116cd Binary files /dev/null and b/scenes/game_easy/image/player.png differ diff --git a/scenes/game_easy/image/player_new.png b/scenes/game_easy/image/player_new.png new file mode 100644 index 0000000..0977ae1 Binary files /dev/null and b/scenes/game_easy/image/player_new.png differ diff --git a/scenes/game_easy/image/shirauo.png b/scenes/game_easy/image/shirauo.png new file mode 100644 index 0000000..c23b80a Binary files /dev/null and b/scenes/game_easy/image/shirauo.png differ diff --git a/scenes/game_easy/image/shizimi.png b/scenes/game_easy/image/shizimi.png new file mode 100644 index 0000000..d93a3a4 Binary files /dev/null and b/scenes/game_easy/image/shizimi.png differ diff --git a/scenes/game_easy/image/speed_enemy.png b/scenes/game_easy/image/speed_enemy.png new file mode 100644 index 0000000..f9c0c33 Binary files /dev/null and b/scenes/game_easy/image/speed_enemy.png differ diff --git a/scenes/game_easy/image/suzuki.png b/scenes/game_easy/image/suzuki.png new file mode 100644 index 0000000..887c66f Binary files /dev/null and b/scenes/game_easy/image/suzuki.png differ diff --git a/scenes/game_easy/image/teki_harisenbon.png b/scenes/game_easy/image/teki_harisenbon.png new file mode 100644 index 0000000..56376b8 Binary files /dev/null and b/scenes/game_easy/image/teki_harisenbon.png differ diff --git a/scenes/game_easy/image/unagi.png b/scenes/game_easy/image/unagi.png new file mode 100644 index 0000000..f309443 Binary files /dev/null and b/scenes/game_easy/image/unagi.png differ diff --git a/scenes/game_easy/image/wakasagi.png b/scenes/game_easy/image/wakasagi.png new file mode 100644 index 0000000..ffd8874 Binary files /dev/null and b/scenes/game_easy/image/wakasagi.png differ diff --git a/scenes/game_easy/normal_enemy.rb b/scenes/game_easy/normal_enemy.rb new file mode 100644 index 0000000..47e344a --- /dev/null +++ b/scenes/game_easy/normal_enemy.rb @@ -0,0 +1,7 @@ +class NomalEnemy < Enemy + def move(obj) + super + self.x += (rand(4)-2) * @dx + self.y += (rand(4)-2) * @dx + end +end diff --git a/scenes/game_easy/player.rb b/scenes/game_easy/player.rb new file mode 100644 index 0000000..2021323 --- /dev/null +++ b/scenes/game_easy/player.rb @@ -0,0 +1,15 @@ +class Player < Sprite + + def up + self.y -= 5 unless self.y < 0 + end + def down + self.y += 5 unless self.y > (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end diff --git a/scenes/game_easy/shittin.rb b/scenes/game_easy/shittin.rb new file mode 100644 index 0000000..8435e7d --- /dev/null +++ b/scenes/game_easy/shittin.rb @@ -0,0 +1,14 @@ +class Shittin < Sprite + def initialize(x, y, img) + super + @dx = 1 + @dy = 1 + end + def move(player) + # @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + # @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + + self.x > (Window.width - self.image.width) || self.x < 0 ? self.x = self.x : self.x += 0.5 * ((self.x - player.x) > 0?1:-1) + self.y > (Window.height - self.image.height) || self.y < 0 ? self.y = self.y : self.y += 0.5 * ((self.y - player.y) > 0?1:-1) + end +end diff --git a/scenes/game_easy/sound/sound.wav b/scenes/game_easy/sound/sound.wav new file mode 100644 index 0000000..4ac1709 Binary files /dev/null and b/scenes/game_easy/sound/sound.wav differ diff --git a/scenes/game_easy/speed_enemy.rb b/scenes/game_easy/speed_enemy.rb new file mode 100644 index 0000000..8293d11 --- /dev/null +++ b/scenes/game_easy/speed_enemy.rb @@ -0,0 +1,9 @@ +class SpeedEnemy < Enemy + def move(obj) + super + + self.x += (rand(10)-1) * @dx + self.y += (rand(10)-1) * @dy + + end +end diff --git a/scenes/game_easy/test.rb b/scenes/game_easy/test.rb new file mode 100644 index 0000000..5f4ca13 --- /dev/null +++ b/scenes/game_easy/test.rb @@ -0,0 +1,7 @@ +def foo(a, b) + return a + b +end + +puts foo(3,4) + +a = 2 diff --git a/scenes/game_hard/README.md b/scenes/game_hard/README.md new file mode 100644 index 0000000..e01f1e6 --- /dev/null +++ b/scenes/game_hard/README.md @@ -0,0 +1,2 @@ +# rc2019su_g2 +RubyCamp2019Summer Group2 diff --git a/scenes/game_hard/attack.rb b/scenes/game_hard/attack.rb new file mode 100644 index 0000000..aa0a508 --- /dev/null +++ b/scenes/game_hard/attack.rb @@ -0,0 +1,25 @@ +class Attack (Window.width - self.image.width) + + end + + def shot(obj) + self.vanish if obj.is_a?(Enemy) + end + + # def hit(obj) + # puts "b" + # obj.vanish + # end +end diff --git a/scenes/game_hard/background.rb b/scenes/game_hard/background.rb new file mode 100644 index 0000000..6e41506 --- /dev/null +++ b/scenes/game_hard/background.rb @@ -0,0 +1,50 @@ + class Background < Sprite + attr_accessor :dx + attr_accessor :dy + + def move_right + self.x += dx + dx > 0? left_scroll_check : right_scroll_check + end + + def left_scroll_check + self.x = -Window.width if self.x >= Window.width + end + + def right_scroll_check + self.x = Window.width - 1 if self.x + Window.width < 0 + end + + + + def move_left + self.x += 1 + left_scroll_check + end + + + + + def move_down + self.y+=dy + dy > 0? down_scroll_check : up_scroll_check + end + + def up_scroll_check + self.y= -Window.height if self.y>= Window.height + end + + def down_scroll_check + self.y = Window.heigt - 1 if self.y + Window.heigt< 0 + end + + + + + def move_up + self.y+= 1 + up_scroll_check + end + + +end \ No newline at end of file diff --git a/scenes/game_hard/chase_enemy.rb b/scenes/game_hard/chase_enemy.rb new file mode 100644 index 0000000..546bdeb --- /dev/null +++ b/scenes/game_hard/chase_enemy.rb @@ -0,0 +1,7 @@ +class ChaseEnemy < Enemy + def move(player) + super + self.x += 2 * ((player.x - self.x) > 0?1:-1) + self.y += 2 * ((player.y - self.y) > 0?1:-1) + end +end diff --git a/scenes/game_hard/director.rb b/scenes/game_hard/director.rb new file mode 100644 index 0000000..43f4c0f --- /dev/null +++ b/scenes/game_hard/director.rb @@ -0,0 +1,166 @@ +require_relative 'enemy' +require_relative 'normal_enemy' +require_relative 'speed_enemy' +require_relative 'chase_enemy' +require_relative 'player' +require_relative 'shittin' +require_relative 'display' +require_relative 'background' +require_relative 'attack' + +module GameHard + class Director + NOMAL_ENEMY_NUMBER = 5 + SPEED_ENEMY_NUMBER = 5 + CHASE_ENEMY_NUMBER = 1 + TIMER_SPEED = 0.15 + + def initialize + @bg_img = Image.load("scenes/game_hard/image/backscreen_loop.png") + @backgrounds = [ + Background.new(Window.width, 0, @bg_img), + Background.new(0, 0, @bg_img), + Background.new(Window.width, Window.height, @bg_img), + Background.new(0, Window.height, @bg_img), + ] + @backgrounds.map{|obj| obj.dx = -1 } + @backgrounds.map{|obj| obj.dy = -1 } + + suzuki_img = Image.load("scenes/game_hard/image/suzuki.png") + @suzuki = Shittin.new(300, 300, suzuki_img) + morogeebi_img = Image.load("scenes/game_hard/image/ebi.png") + @morogeebi = Shittin.new(200, 450, morogeebi_img) + unagi_img = Image.load("scenes/game_hard/image/unagi.png") + @unagi = Shittin.new(300, 400, unagi_img) + amasagi_img = Image.load("scenes/game_hard/image/wakasagi.png") + @amasagi = Shittin.new(500, 300, amasagi_img) + shizimi_img = Image.load("scenes/game_hard/image/shizimi.png") + @shizimi = Shittin.new(300, 500, shizimi_img) + koi_img = Image.load("scenes/game_hard/image/koi.png") + @koi = Shittin.new(100, 300, koi_img) + sirauo_img = Image.load("scenes/game_hard/image/shirauo.png") + @sirauo = Shittin.new(300, 100, sirauo_img) + @shittin = [@suzuki, @morogeebi, @unagi, @amasagi, @shizimi, @koi, @sirauo] + @shittin.each_with_index do |shittin, i| + shittin.collision_enable = false + end + @hit_count = 0 + + # enemy_img = Image.load('scenes/game_hard/image/kuribo1.png') + normal_enemy_img = Image.load("scenes/game_hard/image/teki_harisenbon.png") + speed_enemy_img = Image.load("scenes/game_hard/image/speed_enemy.png") + chase_enemy_img = Image.load("scenes/game_hard/image/matz.png") + @enemys = [] + NOMAL_ENEMY_NUMBER.times do + @enemys << NomalEnemy.new(rand(300)+150, rand(300)+150, normal_enemy_img) + end + SPEED_ENEMY_NUMBER.times do + @enemys << SpeedEnemy.new(rand(300)+150, rand(300)+150, speed_enemy_img) + end + CHASE_ENEMY_NUMBER.times do + @enemys << ChaseEnemy.new(rand(300)+150, rand(300)+150, chase_enemy_img) + end + + player_img = Image.load("scenes/game_hard/image/ocean_kaichu_post.png") + @player = Player.new(100, 100, player_img) + + @attack_image = Image.new(10, 10, [255, 0, 0])#("scenes/game_hard/image/kuribo1.png") + @attacks = [] + + @player.collision = [20,20,20] + @enemys.each{|enemy| enemy.collision = [20,20,20]} + + @font_push_space = Font.new(80) + @font_timer = Font.new(22, 'MS 明朝', weight: true, auto_fitting: true) + + + @sound = Sound.new("scenes/game_hard/sound/sound.wav") + + @timer_img = Image.new(600, 22, [0, 0, 255]) + @time = 300 + + @fps_counter = 0 + end + + def play + Scene.move_to(:gameover) if @time >= 900 + Scene.move_to(:gameover) if !(@player.check(@enemys).empty?) + + # if Input.key_down?(K_RIGHT) + # @backgrounds.map(&:move_right) + # end + # if Input.key_down?(K_LEFT) + # @backgrounds.map(&:move_left) + # end + # if Input.key_down?(K_DOWN) + # @backgrounds.map(&:move_down) + # end + # if Input.key_down?(K_UP) + # @backgrounds.map(&:move_up) + # end + + @backgrounds.map(&:draw) + + + if @hit_count <= 6 + @shittin[@hit_count<=6 ? @hit_count : 6].move(@player) + @shittin[@hit_count<=6 ? @hit_count : 6].draw + @shittin[@hit_count<=6 ? @hit_count : 6].collision_enable = true + @shittin[@hit_count<=6 ? @hit_count-1 : 6].collision_enable = false + else + @shittin[6].collision_enable = false + end + if !(@shittin[@hit_count<=6 ? @hit_count : 6].check(@player).empty?) + @hit_count += 1 + end + + display(@hit_count) + Scene.move_to(:ending) if (@hit_count >= 7 && Input.key_push?(K_RETURN)) + + @enemys.each{|enemy| enemy.move(@player)} + @enemys.each{|enemy| enemy.draw} + @player.down if Input.key_down?(K_DOWN) || Input.key_down?(K_S) + @player.up if Input.key_down?(K_UP) || Input.key_down?(K_W) + @player.right if Input.key_down?(K_RIGHT) || Input.key_down?(K_D) + @player.left if Input.key_down?(K_LEFT) || Input.key_down?(K_A) + @player.draw + + # if Input.key_down?(K_LSHIFT) && @fps_counter % 20 == 0 + # @attacks << Attack.new(@player.x+40,@player.y+20,@attack_image) + # end + # + # Sprite.check(@attacks, @enemys) + # + # @attacks.each_with_index do |attack, i| + # + # attack.move + # attack.draw + + + + # if attack.window_out + # attack.vanish + # @attacks.delete(i) + # end + # if !(attack.check(@enemys).empty?) + # attack.check(@emenys).each_with_index do |enemy, i| + # enemy.vanish + # end + # end + # end + + if @fps_counter % 60 >= 30 + Window.draw_font(230, 220, "ENTERキーを押してください", @font_push_space) if @hit_count >= 7 + end + + Window.draw(@time, 0, @timer_img) + @time += TIMER_SPEED + + Window.draw_font(800, 0, 'タイマー', @font_timer) + + @sound.play if !(@player.check(@shittin).empty?) + + @fps_counter += 1 + end + end +end diff --git a/scenes/game_hard/display.rb b/scenes/game_hard/display.rb new file mode 100644 index 0000000..53b8f79 --- /dev/null +++ b/scenes/game_hard/display.rb @@ -0,0 +1,9 @@ +def display(hit_count) + chars = ["ス","モ","ウ","ア","シ","コ","シ"] + + font = Font.new(50) + + chars.first(hit_count).each_with_index do |char, i| + Window.draw_font((10+(i*50)),500,char,font) + end +end diff --git a/scenes/game_hard/enemy.rb b/scenes/game_hard/enemy.rb new file mode 100644 index 0000000..ca828ff --- /dev/null +++ b/scenes/game_hard/enemy.rb @@ -0,0 +1,22 @@ +class Enemy < Sprite + def initialize(x, y, img) + # @x, @y = x, y + # @image = Image.load(image_file) + # @image.set_color_key([0, 0, 0]) + super + @dx = 1 + @dy = 1 + end + # def draw + # Window.draw(@x, @y, @image) + # end + + def move(player) + @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + end + + def hit(obj) + self.vanish if obj.is_a?(Attack) + end +end diff --git a/scenes/game_hard/ghost.png b/scenes/game_hard/ghost.png new file mode 100644 index 0000000..28edb3d Binary files /dev/null and b/scenes/game_hard/ghost.png differ diff --git a/scenes/game_hard/image/Mario1.png b/scenes/game_hard/image/Mario1.png new file mode 100644 index 0000000..64d065c Binary files /dev/null and b/scenes/game_hard/image/Mario1.png differ diff --git a/scenes/game_hard/image/background.png b/scenes/game_hard/image/background.png new file mode 100644 index 0000000..1768dfc Binary files /dev/null and b/scenes/game_hard/image/background.png differ diff --git a/scenes/game_hard/image/backscreen_loop.png b/scenes/game_hard/image/backscreen_loop.png new file mode 100644 index 0000000..f4e67e0 Binary files /dev/null and b/scenes/game_hard/image/backscreen_loop.png differ diff --git a/scenes/game_hard/image/ebi.png b/scenes/game_hard/image/ebi.png new file mode 100644 index 0000000..ec51052 Binary files /dev/null and b/scenes/game_hard/image/ebi.png differ diff --git a/scenes/game_hard/image/koi.png b/scenes/game_hard/image/koi.png new file mode 100644 index 0000000..4559793 Binary files /dev/null and b/scenes/game_hard/image/koi.png differ diff --git a/scenes/game_hard/image/kuribo1.png b/scenes/game_hard/image/kuribo1.png new file mode 100644 index 0000000..d69ebfe Binary files /dev/null and b/scenes/game_hard/image/kuribo1.png differ diff --git a/scenes/game_hard/image/matz.png b/scenes/game_hard/image/matz.png new file mode 100644 index 0000000..8b52cc7 Binary files /dev/null and b/scenes/game_hard/image/matz.png differ diff --git a/scenes/game_hard/image/matz_.png b/scenes/game_hard/image/matz_.png new file mode 100644 index 0000000..7251f6f Binary files /dev/null and b/scenes/game_hard/image/matz_.png differ diff --git a/scenes/game_hard/image/ocean_kaichu_post.png b/scenes/game_hard/image/ocean_kaichu_post.png new file mode 100644 index 0000000..86eef76 Binary files /dev/null and b/scenes/game_hard/image/ocean_kaichu_post.png differ diff --git a/scenes/game_hard/image/player.jpg b/scenes/game_hard/image/player.jpg new file mode 100644 index 0000000..7255b6e Binary files /dev/null and b/scenes/game_hard/image/player.jpg differ diff --git a/scenes/game_hard/image/player.png b/scenes/game_hard/image/player.png new file mode 100644 index 0000000..55116cd Binary files /dev/null and b/scenes/game_hard/image/player.png differ diff --git a/scenes/game_hard/image/player_new.png b/scenes/game_hard/image/player_new.png new file mode 100644 index 0000000..0977ae1 Binary files /dev/null and b/scenes/game_hard/image/player_new.png differ diff --git a/scenes/game_hard/image/shirauo.png b/scenes/game_hard/image/shirauo.png new file mode 100644 index 0000000..c23b80a Binary files /dev/null and b/scenes/game_hard/image/shirauo.png differ diff --git a/scenes/game_hard/image/shizimi.png b/scenes/game_hard/image/shizimi.png new file mode 100644 index 0000000..d93a3a4 Binary files /dev/null and b/scenes/game_hard/image/shizimi.png differ diff --git a/scenes/game_hard/image/speed_enemy.png b/scenes/game_hard/image/speed_enemy.png new file mode 100644 index 0000000..f9c0c33 Binary files /dev/null and b/scenes/game_hard/image/speed_enemy.png differ diff --git a/scenes/game_hard/image/suzuki.png b/scenes/game_hard/image/suzuki.png new file mode 100644 index 0000000..887c66f Binary files /dev/null and b/scenes/game_hard/image/suzuki.png differ diff --git a/scenes/game_hard/image/teki_harisenbon.png b/scenes/game_hard/image/teki_harisenbon.png new file mode 100644 index 0000000..56376b8 Binary files /dev/null and b/scenes/game_hard/image/teki_harisenbon.png differ diff --git a/scenes/game_hard/image/unagi.png b/scenes/game_hard/image/unagi.png new file mode 100644 index 0000000..f309443 Binary files /dev/null and b/scenes/game_hard/image/unagi.png differ diff --git a/scenes/game_hard/image/wakasagi.png b/scenes/game_hard/image/wakasagi.png new file mode 100644 index 0000000..ffd8874 Binary files /dev/null and b/scenes/game_hard/image/wakasagi.png differ diff --git a/scenes/game_hard/normal_enemy.rb b/scenes/game_hard/normal_enemy.rb new file mode 100644 index 0000000..47e344a --- /dev/null +++ b/scenes/game_hard/normal_enemy.rb @@ -0,0 +1,7 @@ +class NomalEnemy < Enemy + def move(obj) + super + self.x += (rand(4)-2) * @dx + self.y += (rand(4)-2) * @dx + end +end diff --git a/scenes/game_hard/player.rb b/scenes/game_hard/player.rb new file mode 100644 index 0000000..2021323 --- /dev/null +++ b/scenes/game_hard/player.rb @@ -0,0 +1,15 @@ +class Player < Sprite + + def up + self.y -= 5 unless self.y < 0 + end + def down + self.y += 5 unless self.y > (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end diff --git a/scenes/game_hard/shittin.rb b/scenes/game_hard/shittin.rb new file mode 100644 index 0000000..8435e7d --- /dev/null +++ b/scenes/game_hard/shittin.rb @@ -0,0 +1,14 @@ +class Shittin < Sprite + def initialize(x, y, img) + super + @dx = 1 + @dy = 1 + end + def move(player) + # @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + # @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + + self.x > (Window.width - self.image.width) || self.x < 0 ? self.x = self.x : self.x += 0.5 * ((self.x - player.x) > 0?1:-1) + self.y > (Window.height - self.image.height) || self.y < 0 ? self.y = self.y : self.y += 0.5 * ((self.y - player.y) > 0?1:-1) + end +end diff --git a/scenes/game_hard/sound/sound.wav b/scenes/game_hard/sound/sound.wav new file mode 100644 index 0000000..4ac1709 Binary files /dev/null and b/scenes/game_hard/sound/sound.wav differ diff --git a/scenes/game_hard/speed_enemy.rb b/scenes/game_hard/speed_enemy.rb new file mode 100644 index 0000000..8293d11 --- /dev/null +++ b/scenes/game_hard/speed_enemy.rb @@ -0,0 +1,9 @@ +class SpeedEnemy < Enemy + def move(obj) + super + + self.x += (rand(10)-1) * @dx + self.y += (rand(10)-1) * @dy + + end +end diff --git a/scenes/game_hard/test.rb b/scenes/game_hard/test.rb new file mode 100644 index 0000000..5f4ca13 --- /dev/null +++ b/scenes/game_hard/test.rb @@ -0,0 +1,7 @@ +def foo(a, b) + return a + b +end + +puts foo(3,4) + +a = 2 diff --git a/scenes/game_normal/README.md b/scenes/game_normal/README.md new file mode 100644 index 0000000..e01f1e6 --- /dev/null +++ b/scenes/game_normal/README.md @@ -0,0 +1,2 @@ +# rc2019su_g2 +RubyCamp2019Summer Group2 diff --git a/scenes/game_normal/attack.rb b/scenes/game_normal/attack.rb new file mode 100644 index 0000000..aa0a508 --- /dev/null +++ b/scenes/game_normal/attack.rb @@ -0,0 +1,25 @@ +class Attack (Window.width - self.image.width) + + end + + def shot(obj) + self.vanish if obj.is_a?(Enemy) + end + + # def hit(obj) + # puts "b" + # obj.vanish + # end +end diff --git a/scenes/game_normal/background.rb b/scenes/game_normal/background.rb new file mode 100644 index 0000000..6e41506 --- /dev/null +++ b/scenes/game_normal/background.rb @@ -0,0 +1,50 @@ + class Background < Sprite + attr_accessor :dx + attr_accessor :dy + + def move_right + self.x += dx + dx > 0? left_scroll_check : right_scroll_check + end + + def left_scroll_check + self.x = -Window.width if self.x >= Window.width + end + + def right_scroll_check + self.x = Window.width - 1 if self.x + Window.width < 0 + end + + + + def move_left + self.x += 1 + left_scroll_check + end + + + + + def move_down + self.y+=dy + dy > 0? down_scroll_check : up_scroll_check + end + + def up_scroll_check + self.y= -Window.height if self.y>= Window.height + end + + def down_scroll_check + self.y = Window.heigt - 1 if self.y + Window.heigt< 0 + end + + + + + def move_up + self.y+= 1 + up_scroll_check + end + + +end \ No newline at end of file diff --git a/scenes/game_normal/chase_enemy.rb b/scenes/game_normal/chase_enemy.rb new file mode 100644 index 0000000..58bc4d5 --- /dev/null +++ b/scenes/game_normal/chase_enemy.rb @@ -0,0 +1,7 @@ +class ChaseEnemy < Enemy + def move(player) + super + self.x += 2 * @dx * ((player.x - self.x) > 0?1:-1) + self.y += 2 * @dy * ((player.y - self.y) > 0?1:-1) + end +end diff --git a/scenes/game_normal/director.rb b/scenes/game_normal/director.rb new file mode 100644 index 0000000..a15ac00 --- /dev/null +++ b/scenes/game_normal/director.rb @@ -0,0 +1,182 @@ +require_relative 'enemy' +require_relative 'normal_enemy' +require_relative 'speed_enemy' +require_relative 'chase_enemy' +require_relative 'player' +require_relative 'shittin' +require_relative 'display' +require_relative 'background' +require_relative 'attack' + +module GameNormal + class Director + NOMAL_ENEMY_NUMBER = 5 + SPEED_ENEMY_NUMBER = 8 + # CHASE_ENEMY_NUMBER = 5 + TIMER_SPEED = 0.3 + + def initialize + @bg_img = Image.load("scenes/game_normal/image/backscreen_loop.png") + @backgrounds = [ + Background.new(Window.width, 0, @bg_img), + Background.new(0, 0, @bg_img), + Background.new(Window.width, Window.height, @bg_img), + Background.new(0, Window.height, @bg_img), + ] + @backgrounds.map{|obj| obj.dx = -1 } + @backgrounds.map{|obj| obj.dy = -1 } + + @suzuki_ex = Image.load("explain/suzuki_ex.png") + @morogeebi_ex = Image.load("explain/morogeebi_ex.png") + @unagi_ex = Image.load("explain/unagi_ex.png") + @amasagi_ex = Image.load("explain/amasagi_ex.png") + @shizimi_ex = Image.load("explain/shizimi_ex.png") + @koi_ex = Image.load("explain/koi_ex.png") + @sirauo_ex = Image.load("explain/sirauo_ex.png") + @shittin_ex = [@suzuki_ex, @morogeebi_ex, @unagi_ex, @amasagi_ex, @shizimi_ex, @koi_ex, @sirauo_ex] + + + suzuki_img = Image.load("scenes/game_normal/image/suzuki.png") + @suzuki = Shittin.new(300, 300, suzuki_img) + morogeebi_img = Image.load("scenes/game_normal/image/ebi.png") + @morogeebi = Shittin.new(200, 450, morogeebi_img) + unagi_img = Image.load("scenes/game_normal/image/unagi.png") + @unagi = Shittin.new(300, 400, unagi_img) + amasagi_img = Image.load("scenes/game_normal/image/wakasagi.png") + @amasagi = Shittin.new(500, 300, amasagi_img) + shizimi_img = Image.load("scenes/game_normal/image/shizimi.png") + @shizimi = Shittin.new(300, 500, shizimi_img) + koi_img = Image.load("scenes/game_normal/image/koi.png") + @koi = Shittin.new(100, 300, koi_img) + sirauo_img = Image.load("scenes/game_normal/image/shirauo.png") + @sirauo = Shittin.new(300, 100, sirauo_img) + @shittin = [@suzuki, @morogeebi, @unagi, @amasagi, @shizimi, @koi, @sirauo] + @shittin.each_with_index do |shittin, i| + shittin.collision_enable = false + end + @hit_count = 0 + + # enemy_img = Image.load('scenes/game_normal/image/kuribo1.png') + normal_enemy_img = Image.load("scenes/game_normal/image/teki_harisenbon.png") + speed_enemy_img = Image.load("scenes/game_normal/image/speed_enemy.png") + chase_enemy_img = Image.load("scenes/game_normal/image/matz.png") + @enemys = [] + NOMAL_ENEMY_NUMBER.times do + @enemys << NomalEnemy.new(rand(300)+150, rand(300)+150, normal_enemy_img) + end + SPEED_ENEMY_NUMBER.times do + @enemys << SpeedEnemy.new(rand(300)+150, rand(300)+150, speed_enemy_img) + end + # CHASE_ENEMY_NUMBER.times do + # @enemys << ChaseEnemy.new(rand(300)+150, rand(300)+150, chase_enemy_img) + # end + + player_img = Image.load("scenes/game_normal/image/ocean_kaichu_post.png") + @player = Player.new(100, 100, player_img) + + @attack_image = Image.new(10, 10, [255, 0, 0])#("scenes/game_normal/image/kuribo1.png") + @attacks = [] + + @player.collision = [20,20,20] + @enemys.each{|enemy| enemy.collision = [20,20,20]} + + @font_push_space = Font.new(40) + @font_timer = Font.new(22, 'MS 明朝', weight: true, auto_fitting: true) + + + @sound = Sound.new("scenes/game_normal/sound/sound.wav") + + @timer_img = Image.new(600, 22, [0, 0, 255]) + @time = 300 + + @fps_counter = 0 + end + + def play + Scene.move_to(:gameover) if @time >= 900 + Scene.move_to(:gameover) if !(@player.check(@enemys).empty?) + + # if Input.key_down?(K_RIGHT) + # @backgrounds.map(&:move_right) + # end + # if Input.key_down?(K_LEFT) + # @backgrounds.map(&:move_left) + # end + # if Input.key_down?(K_DOWN) + # @backgrounds.map(&:move_down) + # end + # if Input.key_down?(K_UP) + # @backgrounds.map(&:move_up) + # end + + # @backgrounds.map(&:draw) + Window.draw(0, 0, @bg_img) + + + if @hit_count <= 6 + @shittin[@hit_count<=6 ? @hit_count : 6].move(@player) + @shittin[@hit_count<=6 ? @hit_count : 6].draw + @shittin[@hit_count<=6 ? @hit_count : 6].collision_enable = true + @shittin[@hit_count<=6 ? @hit_count-1 : 6].collision_enable = false + else + @shittin[6].collision_enable = false + end + if !(@shittin[@hit_count<=6 ? @hit_count : 6].check(@player).empty?) + Window.loop do + Window.draw(50,50,@shittin_ex[@hit_count<=6 ? @hit_count : 6]) + Window.draw_font(600, 520, "PUSH SPACE", @font_push_space) + break if Input.key_push?(K_SPACE) + end + @hit_count += 1 + end + + display(@hit_count) + Scene.move_to(:ending) if (@hit_count >= 7 && Input.key_push?(K_RETURN)) + + @enemys.each{|enemy| enemy.move(@player)} + @enemys.each{|enemy| enemy.draw} + @player.down if Input.key_down?(K_DOWN) + @player.up if Input.key_down?(K_UP) + @player.right if Input.key_down?(K_RIGHT) + @player.left if Input.key_down?(K_LEFT) + @player.draw + + if Input.key_down?(K_LSHIFT) && @fps_counter % 20 == 0 + @attacks << Attack.new(@player.x+40,@player.y+20,@attack_image) + end + + Sprite.check(@attacks, @enemys) + + @attacks.each_with_index do |attack, i| + + attack.move + attack.draw + + + + # if attack.window_out + # attack.vanish + # @attacks.delete(i) + # end + # if !(attack.check(@enemys).empty?) + # attack.check(@emenys).each_with_index do |enemy, i| + # enemy.vanish + # end + # end + end + + if @fps_counter % 60 >= 30 + Window.draw_font(230, 220, "ENTERキーを押してください", @font_push_space) if @hit_count >= 7 + end + + Window.draw(@time, 0, @timer_img) + @time += TIMER_SPEED + + Window.draw_font(800, 0, 'タイマー', @font_timer) + + @sound.play if !(@player.check(@shittin).empty?) + + @fps_counter += 1 + end + end +end diff --git a/scenes/game_normal/display.rb b/scenes/game_normal/display.rb new file mode 100644 index 0000000..53b8f79 --- /dev/null +++ b/scenes/game_normal/display.rb @@ -0,0 +1,9 @@ +def display(hit_count) + chars = ["ス","モ","ウ","ア","シ","コ","シ"] + + font = Font.new(50) + + chars.first(hit_count).each_with_index do |char, i| + Window.draw_font((10+(i*50)),500,char,font) + end +end diff --git a/scenes/game_normal/enemy.rb b/scenes/game_normal/enemy.rb new file mode 100644 index 0000000..ca828ff --- /dev/null +++ b/scenes/game_normal/enemy.rb @@ -0,0 +1,22 @@ +class Enemy < Sprite + def initialize(x, y, img) + # @x, @y = x, y + # @image = Image.load(image_file) + # @image.set_color_key([0, 0, 0]) + super + @dx = 1 + @dy = 1 + end + # def draw + # Window.draw(@x, @y, @image) + # end + + def move(player) + @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + end + + def hit(obj) + self.vanish if obj.is_a?(Attack) + end +end diff --git a/scenes/game_normal/ghost.png b/scenes/game_normal/ghost.png new file mode 100644 index 0000000..28edb3d Binary files /dev/null and b/scenes/game_normal/ghost.png differ diff --git a/scenes/game_normal/image/Mario1.png b/scenes/game_normal/image/Mario1.png new file mode 100644 index 0000000..64d065c Binary files /dev/null and b/scenes/game_normal/image/Mario1.png differ diff --git a/scenes/game_normal/image/background.png b/scenes/game_normal/image/background.png new file mode 100644 index 0000000..1768dfc Binary files /dev/null and b/scenes/game_normal/image/background.png differ diff --git a/scenes/game_normal/image/backscreen_loop.png b/scenes/game_normal/image/backscreen_loop.png new file mode 100644 index 0000000..f4e67e0 Binary files /dev/null and b/scenes/game_normal/image/backscreen_loop.png differ diff --git a/scenes/game_normal/image/ebi.png b/scenes/game_normal/image/ebi.png new file mode 100644 index 0000000..ec51052 Binary files /dev/null and b/scenes/game_normal/image/ebi.png differ diff --git a/scenes/game_normal/image/koi.png b/scenes/game_normal/image/koi.png new file mode 100644 index 0000000..4559793 Binary files /dev/null and b/scenes/game_normal/image/koi.png differ diff --git a/scenes/game_normal/image/kuribo1.png b/scenes/game_normal/image/kuribo1.png new file mode 100644 index 0000000..d69ebfe Binary files /dev/null and b/scenes/game_normal/image/kuribo1.png differ diff --git a/scenes/game_normal/image/matz.png b/scenes/game_normal/image/matz.png new file mode 100644 index 0000000..8b52cc7 Binary files /dev/null and b/scenes/game_normal/image/matz.png differ diff --git a/scenes/game_normal/image/ocean_kaichu_post.png b/scenes/game_normal/image/ocean_kaichu_post.png new file mode 100644 index 0000000..86eef76 Binary files /dev/null and b/scenes/game_normal/image/ocean_kaichu_post.png differ diff --git a/scenes/game_normal/image/player.jpg b/scenes/game_normal/image/player.jpg new file mode 100644 index 0000000..7255b6e Binary files /dev/null and b/scenes/game_normal/image/player.jpg differ diff --git a/scenes/game_normal/image/player.png b/scenes/game_normal/image/player.png new file mode 100644 index 0000000..55116cd Binary files /dev/null and b/scenes/game_normal/image/player.png differ diff --git a/scenes/game_normal/image/player_new.png b/scenes/game_normal/image/player_new.png new file mode 100644 index 0000000..0977ae1 Binary files /dev/null and b/scenes/game_normal/image/player_new.png differ diff --git a/scenes/game_normal/image/shirauo.png b/scenes/game_normal/image/shirauo.png new file mode 100644 index 0000000..c23b80a Binary files /dev/null and b/scenes/game_normal/image/shirauo.png differ diff --git a/scenes/game_normal/image/shizimi.png b/scenes/game_normal/image/shizimi.png new file mode 100644 index 0000000..d93a3a4 Binary files /dev/null and b/scenes/game_normal/image/shizimi.png differ diff --git a/scenes/game_normal/image/speed_enemy.png b/scenes/game_normal/image/speed_enemy.png new file mode 100644 index 0000000..f9c0c33 Binary files /dev/null and b/scenes/game_normal/image/speed_enemy.png differ diff --git a/scenes/game_normal/image/suzuki.png b/scenes/game_normal/image/suzuki.png new file mode 100644 index 0000000..887c66f Binary files /dev/null and b/scenes/game_normal/image/suzuki.png differ diff --git a/scenes/game_normal/image/teki_harisenbon.png b/scenes/game_normal/image/teki_harisenbon.png new file mode 100644 index 0000000..56376b8 Binary files /dev/null and b/scenes/game_normal/image/teki_harisenbon.png differ diff --git a/scenes/game_normal/image/unagi.png b/scenes/game_normal/image/unagi.png new file mode 100644 index 0000000..f309443 Binary files /dev/null and b/scenes/game_normal/image/unagi.png differ diff --git a/scenes/game_normal/image/wakasagi.png b/scenes/game_normal/image/wakasagi.png new file mode 100644 index 0000000..ffd8874 Binary files /dev/null and b/scenes/game_normal/image/wakasagi.png differ diff --git a/scenes/game_normal/normal_enemy.rb b/scenes/game_normal/normal_enemy.rb new file mode 100644 index 0000000..47e344a --- /dev/null +++ b/scenes/game_normal/normal_enemy.rb @@ -0,0 +1,7 @@ +class NomalEnemy < Enemy + def move(obj) + super + self.x += (rand(4)-2) * @dx + self.y += (rand(4)-2) * @dx + end +end diff --git a/scenes/game_normal/player.rb b/scenes/game_normal/player.rb new file mode 100644 index 0000000..2021323 --- /dev/null +++ b/scenes/game_normal/player.rb @@ -0,0 +1,15 @@ +class Player < Sprite + + def up + self.y -= 5 unless self.y < 0 + end + def down + self.y += 5 unless self.y > (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end diff --git a/scenes/game_normal/shittin.rb b/scenes/game_normal/shittin.rb new file mode 100644 index 0000000..8435e7d --- /dev/null +++ b/scenes/game_normal/shittin.rb @@ -0,0 +1,14 @@ +class Shittin < Sprite + def initialize(x, y, img) + super + @dx = 1 + @dy = 1 + end + def move(player) + # @dx = -@dx if self.x > (Window.width - self.image.width) || self.x < 0 + # @dy = -@dy if self.y > (Window.height - self.image.height) || self.y < 0 + + self.x > (Window.width - self.image.width) || self.x < 0 ? self.x = self.x : self.x += 0.5 * ((self.x - player.x) > 0?1:-1) + self.y > (Window.height - self.image.height) || self.y < 0 ? self.y = self.y : self.y += 0.5 * ((self.y - player.y) > 0?1:-1) + end +end diff --git a/scenes/game_normal/sound/sound.wav b/scenes/game_normal/sound/sound.wav new file mode 100644 index 0000000..4ac1709 Binary files /dev/null and b/scenes/game_normal/sound/sound.wav differ diff --git a/scenes/game_normal/speed_enemy.rb b/scenes/game_normal/speed_enemy.rb new file mode 100644 index 0000000..8293d11 --- /dev/null +++ b/scenes/game_normal/speed_enemy.rb @@ -0,0 +1,9 @@ +class SpeedEnemy < Enemy + def move(obj) + super + + self.x += (rand(10)-1) * @dx + self.y += (rand(10)-1) * @dy + + end +end diff --git a/scenes/game_normal/test.rb b/scenes/game_normal/test.rb new file mode 100644 index 0000000..5f4ca13 --- /dev/null +++ b/scenes/game_normal/test.rb @@ -0,0 +1,7 @@ +def foo(a, b) + return a + b +end + +puts foo(3,4) + +a = 2 diff --git a/scenes/gameover/director.rb b/scenes/gameover/director.rb new file mode 100644 index 0000000..33569e1 --- /dev/null +++ b/scenes/gameover/director.rb @@ -0,0 +1,22 @@ +module Gameover + class Director + def initialize + @font_gameover = Font.new(102) + @font_retry = Font.new(60) + end + + def play + Window.draw_font(230, 100, "Gameover", @font_gameover) + Window.draw_font(370, 300, "Retry", @font_retry) + + # Input.mouse_pos_x >= 370 && Input.mouse_pos_x <= 570 && Input.mouse_pos_y >= 300 && Input.mouse_pos_y <= 400 + + if (Input.mouse_pos_x >= 370 && Input.mouse_pos_x <= 570 && Input.mouse_pos_y >= 300 && Input.mouse_pos_y <= 400 && Input.mouse_push?(M_LBUTTON)) || Input.key_push?(K_SPACE) + Scene.add(GameEasy::Director.new, :game_easy) + Scene.add(GameNormal::Director.new, :game_normal) + Scene.add(GameHard::Director.new, :game_hard) + Scene.move_to(:opening) + end + end + end +end diff --git a/scenes/load_scene.rb b/scenes/load_scene.rb new file mode 100644 index 0000000..24a9c40 --- /dev/null +++ b/scenes/load_scene.rb @@ -0,0 +1,22 @@ +require_relative 'opening/director' +require_relative 'operation/director' +require_relative 'game/director' +require_relative 'game_easy/director' +require_relative 'game_normal/director' +require_relative 'game_hard/director' +require_relative 'ending/director' +require_relative 'gameover/director' +require_relative 'operation/director' +require_relative 'credit/director' +require_relative 'travel/director' + +Scene.add(Opening::Director.new, :opening) +Scene.add(Game::Director.new, :game) +Scene.add(GameEasy::Director.new, :game_easy) +Scene.add(GameNormal::Director.new, :game_normal) +Scene.add(GameHard::Director.new, :game_hard) +Scene.add(Ending::Director.new, :ending) +Scene.add(Gameover::Director.new, :gameover) +Scene.add(Operation::Director.new, :operation) +Scene.add(Credit::Director.new, :credit) +Scene.add(Travel::Director.new, :travel) diff --git a/scenes/opening/director.rb b/scenes/opening/director.rb new file mode 100644 index 0000000..eadb986 --- /dev/null +++ b/scenes/opening/director.rb @@ -0,0 +1,35 @@ +module Opening + class Director + def initialize + @image = Image.load("scenes/opening/title.png") + @image_easy = Image.new(200, 70,[255, 0, 0] ) + @image_normal = Image.new(200, 70,[255, 0, 0] ) + @image_hard = Image.new(200, 70,[255, 0, 0] ) + @font_Level = Font.new(50, 'MS 明朝', weight: true, ) + @font_explain = Font.new(30) + + end + + def play + Scene.move_to(:operation) if Input.key_push?(K_SPACE) + + (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 210 && Input.mouse_pos_y <= 280) ? @image_easy = Image.new(200, 70, [200, 20, 0]) : @image_easy = Image.new(200, 70,[255, 0, 0] ) + (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 310 && Input.mouse_pos_y <= 380) ? @image_normal = Image.new(200, 70, [200, 20, 0]) : @image_normal = Image.new(200, 70, [255, 0, 0]) + (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 410 && Input.mouse_pos_y <= 480) ? @image_hard = Image.new(200, 70, [200, 20, 0]) : @image_hard = Image.new(200, 70, [255, 0, 0]) + + Scene.move_to(:game_easy) if (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 210 && Input.mouse_pos_y <= 280 && Input.mouse_push?(M_LBUTTON)) || Input.key_push?(K_C) + Scene.move_to(:game_normal) if (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 310 && Input.mouse_pos_y <= 380 && Input.mouse_push?(M_LBUTTON)) || Input.key_push?(K_V) + Scene.move_to(:game_hard) if (Input.mouse_pos_x >= 350 && Input.mouse_pos_x <= 550 && Input.mouse_pos_y >= 410 && Input.mouse_pos_y <= 480 && Input.mouse_push?(M_LBUTTON)) || Input.key_push?(K_B) + + Window.draw(0,0,@image) + Window.draw(350, 210 ,@image_easy) + Window.draw(350, 310,@image_normal) + Window.draw(350, 410 ,@image_hard) + Window.draw_font(385, 220 ,"イージー", @font_Level) + Window.draw_font(385, 320 ,"ノーマル", @font_Level) + Window.draw_font(400, 420 ,"ハード", @font_Level) + Window.draw_font(600, 500, "SPACE : 操作説明", @font_explain) + + end + end +end diff --git a/scenes/opening/title.png b/scenes/opening/title.png new file mode 100644 index 0000000..af28e93 Binary files /dev/null and b/scenes/opening/title.png differ diff --git a/scenes/operation/director.rb b/scenes/operation/director.rb new file mode 100644 index 0000000..29e8b40 --- /dev/null +++ b/scenes/operation/director.rb @@ -0,0 +1,13 @@ +module Operation + class Director + def initialize + @text = Image.load("scenes/operation/text.png") + end + + def play + Scene.move_to(:opening) if Input.key_push?(K_SPACE) + + Window.draw(0,0,@text) + end + end +end diff --git a/scenes/operation/text.png b/scenes/operation/text.png new file mode 100644 index 0000000..3189106 Binary files /dev/null and b/scenes/operation/text.png differ diff --git a/scenes/travel/character.rb b/scenes/travel/character.rb new file mode 100644 index 0000000..2d164e8 --- /dev/null +++ b/scenes/travel/character.rb @@ -0,0 +1,17 @@ +class Character (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end + + diff --git a/scenes/travel/director.rb b/scenes/travel/director.rb new file mode 100644 index 0000000..f4dd0b7 --- /dev/null +++ b/scenes/travel/director.rb @@ -0,0 +1,58 @@ +require_relative 'character' + +module Travel + class Director + def initialize + + + @counter = 0 + @char = Character.new(700, 500, Image.load("scenes/travel/images/char.png")) + @bg_img = Image.load("scenes/travel/images/background.png") + @shimane=Sprite.new(260,340,Image.load("scenes/travel/images/shimane.png")) + @matsue=Sprite.new(580,245,Image.load("scenes/travel/images/shimane2.png")) + @is_vanish_shimane = false + @is_vanish_matsue = false + end + + def change_image_shimane(point,haikei) + unless @is_vanish_shimane + if (@char === @shimane) + @bg_img=Image.load(haikei) + @shimane.vanish + @is_vanish_shimane = true + @counter += 1 + end + end + end + + def change_image_matsue(point,haikei) + if @is_vanish_shimane + unless @is_vanish_matsue + @matsue.draw + if (@char === @matsue) + #@bg_img=Image.load(haikei) + Scene.move_to(:opening) + #point.vanish + #if(point===@matsue) + @counter += 1 + end + end + end + + end + + def play + Window.draw(0, 0, @bg_img) + + @char.down if Input.key_down?(K_DOWN) + @char.up if Input.key_down?(K_UP) + @char.right if Input.key_down?(K_RIGHT) + @char.left if Input.key_down?(K_LEFT) + @char.draw + @shimane.draw + + change_image_shimane(@shimane,"scenes/travel/images/background2.png") + change_image_matsue(@matsue,"scenes/travel/images/background2.png") + end +end +end diff --git a/scenes/travel/images/background.png b/scenes/travel/images/background.png new file mode 100644 index 0000000..3381e94 Binary files /dev/null and b/scenes/travel/images/background.png differ diff --git a/scenes/travel/images/background2.png b/scenes/travel/images/background2.png new file mode 100644 index 0000000..7b6288b Binary files /dev/null and b/scenes/travel/images/background2.png differ diff --git a/scenes/travel/images/char.png b/scenes/travel/images/char.png new file mode 100644 index 0000000..27d07f4 Binary files /dev/null and b/scenes/travel/images/char.png differ diff --git a/scenes/travel/images/shimane.png b/scenes/travel/images/shimane.png new file mode 100644 index 0000000..a8777e3 Binary files /dev/null and b/scenes/travel/images/shimane.png differ diff --git a/scenes/travel/images/shimane2.png b/scenes/travel/images/shimane2.png new file mode 100644 index 0000000..a9f7e43 Binary files /dev/null and b/scenes/travel/images/shimane2.png differ diff --git a/scenes/travel/main.rb b/scenes/travel/main.rb new file mode 100644 index 0000000..693e665 --- /dev/null +++ b/scenes/travel/main.rb @@ -0,0 +1,17 @@ +require 'dxruby' + +require_relative 'director' +require_relative 'character' + +Window.caption = "RubyCamp Example" +Window.width = 800 +Window.height = 600 + +director = Director.new + + +Window.loop do + break if Input.keyPush?(K_ESCAPE) + + director.play +end diff --git a/sounds/bgm.mid b/sounds/bgm.mid new file mode 100644 index 0000000..21579d1 Binary files /dev/null and b/sounds/bgm.mid differ diff --git a/strat/character.rb b/strat/character.rb new file mode 100644 index 0000000..2d164e8 --- /dev/null +++ b/strat/character.rb @@ -0,0 +1,17 @@ +class Character (Window.height - self.image.height) + end + def right + self.x += 5 unless self.x > (Window.width - self.image.width) + end + def left + self.x -= 5 unless self.x < 0 + end +end + + diff --git a/strat/director.rb b/strat/director.rb new file mode 100644 index 0000000..d800111 --- /dev/null +++ b/strat/director.rb @@ -0,0 +1,55 @@ + + class Director + def initialize + + + @counter = 0 + @char = Character.new(700, 500, Image.load("images/char.png")) + @bg_img = Image.load("images/background.png") + @shimane=Sprite.new(260,340,Image.load("images/shimane.png")) + @matsue=Sprite.new(580,245,Image.load("images/shimane2.png")) + @is_vanish_shimane = false + @is_vanish_matsue = false + end + + def change_image_shimane(point,haikei) + unless @is_vanish_shimane + if (@char === @shimane) + @bg_img=Image.load(haikei) + @shimane.vanish + @is_vanish_shimane = true + @counter += 1 + end + end + end + + def change_image_matsue(point,haikei) + if @is_vanish_shimane + unless @is_vanish_matsue + @matsue.draw + if (@char === @matsue) + #@bg_img=Image.load(haikei) + @matsue.draw + #point.vanish + #if(point===@matsue) + @counter += 1 + end + end + end + + end + + def play + Window.draw(0, 0, @bg_img) + + @char.down if Input.key_down?(K_DOWN) + @char.up if Input.key_down?(K_UP) + @char.right if Input.key_down?(K_RIGHT) + @char.left if Input.key_down?(K_LEFT) + @char.draw + @shimane.draw + + change_image_shimane(@shimane,"images/background2.png") + change_image_matsue(@matsue,"images/background2.png") + end +end \ No newline at end of file diff --git a/strat/images/background.png b/strat/images/background.png new file mode 100644 index 0000000..3381e94 Binary files /dev/null and b/strat/images/background.png differ diff --git a/strat/images/background2.png b/strat/images/background2.png new file mode 100644 index 0000000..7b6288b Binary files /dev/null and b/strat/images/background2.png differ diff --git a/strat/images/char.png b/strat/images/char.png new file mode 100644 index 0000000..27d07f4 Binary files /dev/null and b/strat/images/char.png differ diff --git a/strat/images/shimane.png b/strat/images/shimane.png new file mode 100644 index 0000000..a8777e3 Binary files /dev/null and b/strat/images/shimane.png differ diff --git a/strat/images/shimane2.png b/strat/images/shimane2.png new file mode 100644 index 0000000..a9f7e43 Binary files /dev/null and b/strat/images/shimane2.png differ diff --git a/strat/main.rb b/strat/main.rb new file mode 100644 index 0000000..693e665 --- /dev/null +++ b/strat/main.rb @@ -0,0 +1,17 @@ +require 'dxruby' + +require_relative 'director' +require_relative 'character' + +Window.caption = "RubyCamp Example" +Window.width = 800 +Window.height = 600 + +director = Director.new + + +Window.loop do + break if Input.keyPush?(K_ESCAPE) + + director.play +end