-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexemplo.rb
51 lines (36 loc) · 958 Bytes
/
exemplo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'rubygems'
require 'gosu'
class Exemplo < Gosu::Window
def initialize
super(640, 480, false)
self.caption = "Exemplo - Gosu"
@imagem_fundo = Gosu::Image.new(self,"bg.png",true)
@jogador = Gosu::Image.new(self,"barco_01.png",true)
@pos_x=0
@pos_y=400
@x_bg = 0
end
def draw
@imagem_fundo.draw(@x_bg,0,0)
@jogador.draw(@pos_x,@pos_y,1)
end
def update
if(button_down?(Gosu::Button::KbRight))then
@pos_x = @pos_x + 5
if(@pos_x > 360)then @pos_x = 400 end
end
if(button_down?(Gosu::Button::KbLeft))then
@pos_x = @pos_x - 5
if(@pos_x < 10) then @pos_x = 10 end
end
if(button_down?(Gosu::Button::KbRight))then
@x_bg = @x_bg - 5
if(@pos_x > 1433)then @pos_x = 1433 end
end
if(button_down?(Gosu::Button::KbLeft))then
@x_bg = @x_bg + 5
if(@pos_x < 10) then @pos_x = 10 end
end
end
end
Exemplo.new.show