Class: MovingTriangle
Constant Summary
collapse
- WIDTH =
800
- HEIGHT =
600
- TITLE =
'Moving triangle example'
Constants included
from Gosu
Gosu::COLOUR_AQUA, Gosu::COLOUR_BLACK, Gosu::COLOUR_BLUE, Gosu::COLOUR_CYAN, Gosu::COLOUR_FUCHSIA, Gosu::COLOUR_GOLD, Gosu::COLOUR_GRAY, Gosu::COLOUR_GREEN, Gosu::COLOUR_NONE, Gosu::COLOUR_RED, Gosu::COLOUR_STEELBLUE, Gosu::COLOUR_WHITE, Gosu::COLOUR_YELLOW
Instance Method Summary
collapse
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#draw_the_triangle ⇒ Object
# === draw_the_triangle ========================================================================= #.
-
#initialize(run_already = true) ⇒ MovingTriangle
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#update ⇒ Object
# === update ========================================================================= #.
Methods included from Gosu
#gosu_tilable_image
#gosu_button_down?, #image, #image10?, #image1?, #image2?, #image3?, #image4?, #image5?, #image6?, #image7?, #image8?, #image9?, #on_left_arrow_pressed?, #on_right_arrow_pressed?, #q_means_quit, #set_font, #set_title, #sqrt, #tab_key?, #write_this_text
Constructor Details
#initialize(run_already = true) ⇒ MovingTriangle
32
33
34
35
36
37
38
39
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 32
def initialize(
run_already = true
)
super(WIDTH, HEIGHT)
set_title(TITLE)
reset
run if run_already
end
|
Instance Method Details
#draw ⇒ Object
68
69
70
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 68
def draw
draw_the_triangle
end
|
#draw_the_triangle ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 75
def draw_the_triangle
draw_triangle(
2+@x_modifier, 2, @use_this_colour,
62+@x_modifier,
62,
@use_this_colour,
2+@x_modifier,
125,
@use_this_colour,
0, :default )
end
|
#reset ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 44
def reset
@use_this_colour = COLOUR_RED
@x_modifier = 0
@current_time = ::Gosu.milliseconds / 1000.0
end
|
#run ⇒ Object
62
63
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 62
def run
end
|
#update ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'lib/games_paradise/examples/gosu/moving_triangle.rb', line 94
def update
exit_on_q_button_press_event
@current_time += (Gosu.milliseconds / 1000.0)
if @current_time >= 1
@current_time -= 1
@x_modifier += 1
end
end
|