Class: GamesAndRpgParadise::MovingTriangle

Inherits:
Gosu::Window show all
Includes:
Gosu
Defined in:
lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb

Constant Summary collapse

WIDTH =
#

WIDTH

#
800
HEIGHT =
#

HEIGHT

#
600
TITLE =
#

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

Methods included from Gosu

#gosu_tilable_image

Methods inherited from Gosu::Window

#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

#

initialize

#


34
35
36
37
38
39
40
41
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 34

def initialize(
    run_already = true
  )
  super(WIDTH, HEIGHT)
  set_title(TITLE)
  reset
  run if run_already
end

Instance Method Details

#drawObject

#

draw

#


70
71
72
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 70

def draw
  draw_the_triangle
end

#draw_the_triangleObject

#

draw_the_triangle

#


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 77

def draw_the_triangle
  draw_triangle(
    2+@x_modifier, # x1 (Float) — the X coordinate of the first vertex.
    2, # y1 (Float) — the Y coordinate of the first vertex.
    @use_this_colour,
    62+@x_modifier,
    62,
    @use_this_colour,
    2+@x_modifier,
    125,
    @use_this_colour,
    0, # z
    :default # the mode in use
  )
end

#resetObject

#

reset

#


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 46

def reset
  # ======================================================================= #
  # === @use_this_colour
  # ======================================================================= #
  @use_this_colour = COLOUR_RED
  # ======================================================================= #
  # === @x_modifier
  # ======================================================================= #
  @x_modifier = 0
  # ======================================================================= #
  # === @current_time
  # ======================================================================= #
  @current_time = ::Gosu.milliseconds / 1000.0
end

#runObject

#

run

#


64
65
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 64

def run
end

#updateObject

#

update

#


96
97
98
99
100
101
102
103
# File 'lib/games_and_rpg_paradise/games/examples/gosu/moving_triangle.rb', line 96

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