class RubyArena::RobotRenderer
Attributes
robot[R]
window[R]
Public Class Methods
new(args)
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 5 def initialize(args) @robot = args.fetch(:robot) @window = args.fetch(:window) end
Public Instance Methods
draw()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 10 def draw draw_tank_body draw_gun draw_radar end
Private Instance Methods
color()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 61 def color Gosu::Color::WHITE end
draw_gun()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 123 def draw_gun window.rotate(gun_heading, x, y) do window.draw_quad( gun_x1, gun_y1, gun_color, gun_x2, gun_y1, gun_color, gun_x2, gun_y2, gun_color, gun_x1, gun_y2, gun_color ) window.draw_quad( gun_base_x1, gun_base_y1, gun_color, gun_base_x2, gun_base_y1, gun_color, gun_base_x2, gun_base_y2, gun_color, gun_base_x1, gun_base_y2, gun_color ) end end
draw_radar()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 65 def draw_radar color = Gosu::Color.new(40, 0, 255, 0) window.draw_triangle( x, y, color, radar_x1, radar_y1, color, radar_x2, radar_y2, color ) window.rotate(radar_heading, x, y) do window.draw_triangle( radar_base_x1, y, color, radar_base_x2, y, color, x, radar_base_y3, color ) end end
draw_tank_body()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 18 def draw_tank_body window.rotate(heading, x, y) do window.draw_quad( x1, y1, color, x2, y1, color, x2, y2, color, x1, y2, color ) end end
gun_base_x1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 156 def gun_base_x1 x - size/4 end
gun_base_x2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 160 def gun_base_x2 x + size/4 end
gun_base_y1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 164 def gun_base_y1 y - size/4 end
gun_base_y2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 168 def gun_base_y2 y + size/4 end
gun_color()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 176 def gun_color Gosu::Color::GRAY end
gun_heading()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 172 def gun_heading robot.gun_heading end
gun_x1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 140 def gun_x1 x - 2 end
gun_x2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 144 def gun_x2 x + 2 end
gun_y1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 148 def gun_y1 y - size/1.5 end
gun_y2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 152 def gun_y2 y end
heading()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 57 def heading robot.heading end
radar_base_x1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 99 def radar_base_x1 x + 4 end
radar_base_x2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 103 def radar_base_x2 x - 4 end
radar_base_y3()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 107 def radar_base_y3 y + 6 end
radar_heading()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 111 def radar_heading robot.radar_heading end
radar_range()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 119 def radar_range robot.radar_range end
radar_view_angle()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 115 def radar_view_angle robot.radar_view_angle end
radar_x1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 83 def radar_x1 x + Gosu.offset_x(radar_heading - radar_view_angle / 2, radar_range) end
radar_x2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 87 def radar_x2 x + Gosu.offset_x(radar_heading + radar_view_angle / 2, radar_range) end
radar_y1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 91 def radar_y1 y + Gosu.offset_y(radar_heading - radar_view_angle / 2, radar_range) end
radar_y2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 95 def radar_y2 y + Gosu.offset_y(radar_heading + radar_view_angle / 2, radar_range) end
size()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 53 def size robot.size end
x()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 29 def x robot.x end
x1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 37 def x1 x - size/2 end
x2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 41 def x2 x + size/2 end
y()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 33 def y robot.y end
y1()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 45 def y1 y - size/2 end
y2()
click to toggle source
# File lib/ruby_arena/robot_renderer.rb, line 49 def y2 y + size/2 end