Class: GamesParadise::Mages
- Inherits:
-
Object
- Object
- GamesParadise::Mages
- Defined in:
- lib/games_paradise/gui/gosu/final_fantasy/mages.rb
Instance Method Summary collapse
- #collision_checker(player_x, player_y) ⇒ Object
- #draw ⇒ Object
-
#initialize(colliders_name) ⇒ Mages
constructor
A new instance of Mages.
Constructor Details
#initialize(colliders_name) ⇒ Mages
Returns a new instance of Mages.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/games_paradise/gui/gosu/final_fantasy/mages.rb', line 8 def initialize(colliders_name) @colliders_name = colliders_name file = File.read("map.json") data_hash = JSON.parse(file) data_hash["layers"].each do |x| if x["name"] == "#{@colliders_name}" @mages_data_from_tiled = x["objects"] end end @mage_head_image = Gosu::Image.new("images/mage_head.png", :tileable => true) end |
Instance Method Details
#collision_checker(player_x, player_y) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/games_paradise/gui/gosu/final_fantasy/mages.rb', line 19 def collision_checker(player_x, player_y) @player_x = player_x @player_y = player_y @mage_collision = false @mages_data_from_tiled.each do |data| centre_x = data["x"] + (data["width"]/2) centre_y = data["y"] + (data["height"]/2) if Gosu.distance(@player_x,@player_y,centre_x,centre_y) < 10 @mage_collision = true if data["name"] == "mage_1" @mage_text = Gosu::Image.from_text("The shrooms here taste great." + "\n" + "They also contain anti-venom.", 16, {}) elsif data["name"] == "mage_2" @mage_text = Gosu::Image.from_text("Blue shrooms only grow" + "\n" + "behind trees.", 16, {}) elsif data["name"] == "mage_3" @mage_text = Gosu::Image.from_text("The prophecy tells of king who can" + "\n" + "complete levels by opening chests.", 16, {}) end end end end |
#draw ⇒ Object
38 39 40 41 42 43 |
# File 'lib/games_paradise/gui/gosu/final_fantasy/mages.rb', line 38 def draw if @mage_collision @mage_head_image.draw(16,176,10) @mage_text.draw(96, 176, 10) end end |