test/game.rb in minigl-1.2.5 vs test/game.rb in minigl-1.2.6
- old
+ new
@@ -9,12 +9,12 @@
@obj1 = GameObject.new 10, 10, 80, 80, :img1, Vector.new(-10, -10)
@obj2 = Sprite.new 400, 0, :img1
@font = Res.font :font1, 20
@writer = TextHelper.new @font, 5
- @btn = Button.new(10, 560, @font, "Test", :btn, 0x008000, false, 15, 5) {}
- @txt = TextField.new 10, 520, @font, :text, nil, 15, 5, 16, false, "", 0, 0x0000ff
+ @btn = Button.new(10, 560, @font, "Test", :btn, 0x008000) {}
+ @txt = TextField.new 10, 520, @font, :text, nil, 15, 5, 16, false, "", nil, 0, 0x0000ff
end
def needs_cursor?
true
end
@@ -23,9 +23,11 @@
KB.update
@obj1.y -= 1 if KB.key_held? Gosu::KbUp
@obj1.x += 1 if KB.key_down? Gosu::KbRight
@obj1.y += 1 if KB.key_held? Gosu::KbDown
@obj1.x -= 1 if KB.key_down? Gosu::KbLeft
+ @btn.set_position rand(700), rand(550) if KB.key_pressed? Gosu::KbSpace
+ @txt.set_position rand(700), rand(550) if KB.key_pressed? Gosu::KbReturn
Mouse.update
if Mouse.double_click? :left
@obj1.x = Mouse.x + 10
@obj1.y = Mouse.y + 10