require 'rubygems'
require 'gosu'
class Window < Gosu::Window
def draw_rect x, y, w, h, c
draw_quad x, y, c,
x + w, y, c,
x, y + h, c,
x +w, y + h, c, 0
end
def draw
draw_rect 100, 100, 200, 200, Gosu::Color::RED
draw_rect 100+1, 100+1, 200-2, 200-2, Gosu::Color::GREEN
end
end
Window.new(400, 400, false).show
class GameControlView
def initialize(options)
@area = options[:area]
@window = options[:window]
@outline_color = Gosu::Color.from_rgba_quad(229, 229, 229)
@background_color = Gosu::Color.from_rgba_quad(241, 241, 241)
end
def draw_rect_g x, y, w, h, c
@window.draw_quad x, y, c,
x + w, y, c,
x, y + h, c,
x +w, y + h, c, 0
end
def draw
# Draw the panel
@window.fill_rect(@area, @background_color)
@window.draw_line(
@area.left, @area.top, @outline_color,
@area.right, @area.top, @outline_color)
draw_rect_g @area.left + 10, @area.top + 10, 50, 50, Gosu::Color::RED
draw_rect_g @area.left + 10 + 1, @area.top + 10 + 1, 50-2, 50-2, Gosu::Color::GREEN
end
end
@area
is a Chingu::Rect
and the values for left and top are 0 and 700. The background color is RGBA (241, 241, 241, 255). This is sitting in a 1280x800 window that fits easily onto my MacBook's screen.glEnable(GL_TEXTURE_0)
:)
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill