5.3P button test.docx - require'rubygems require'gosu Instructions This code needs to be fixed and finished The\"Click Me text is not appearing on the

5.3P button test.docx - require'rubygems require'gosu...

This preview shows page 1 - 3 out of 3 pages.

require 'rubygems' require 'gosu' # Instructions: This code needs to be fixed and finished! # The "Click Me" text is not appearing on the button, also # the mouse_y co-ordinate should be shown along with the mouse_x one # finally, a user has noticed the sometimes the button action occurs # when you click out side the button area and vice-versa. # determines whether a graphical widget is placed over others or not module ZOrder BACKGROUND, MIDDLE, TOP = *0..2 end # Global constants WIN_WIDTH = 640 WIN_HEIGHT = 400 class DemoWindow < Gosu::Window # set up variables and attributes def initialize super(WIN_WIDTH, WIN_HEIGHT, false) @background = Gosu::Color::WHITE @button_font = Gosu::Font.new(20) @info_font = Gosu::Font.new(10) @locs = [60,60] end
# Draw the background, the button with 'click me' text and text # showing the mouse coordinates def draw # Draw background color Gosu.draw_rect(0, 0, WIN_WIDTH, WIN_HEIGHT, @background, ZOrder::BACKGROUND, mode=:default) # Draw the button Gosu.draw_rect(50, 50, 100, 50, Gosu::Color::GREEN, ZOrder::TOP, mode=:default) # Draw the button text @button_font.draw("Click me", 60, 60, ZOrder::TOP, 1.0, 1.0, Gosu::Color::BLACK)

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture