Module: Hate::Core

Defined in:
lib/hate/core.rb

Defined Under Namespace

Modules: Callbacks

Class Method Summary collapse

Class Method Details

.haltObject



16
17
18
19
20
21
# File 'lib/hate/core.rb', line 16

def self.halt
  @window.quit
  Hate::Core::Callbacks.quit
  puts "Goodbye!"
  exit
end

.loadObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hate/core.rb', line 38

def self.load
  # Load main.rb
  begin
    require ARGV[0]
  rescue LoadError
    require "./" + ARGV[0]
  end

  # Call #load
  Hate::Core::Callbacks.load
end

.optionsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/hate/core.rb', line 23

def self.options
  opts = Trollop::options do
    version "Hate %s (c) 2011 Brian Jones" % Hate::VERSION
    banner <<-EOS
    Hate 3d - A Ruby 3d Game Engine

    Usage:
      hate [options] <game main.rb>

    Options:
    EOS
  end
  Trollop::die "No main.rb specified!" if ARGV[0].nil?
end

.quitObject



68
69
70
# File 'lib/hate/core.rb', line 68

def self.quit
  halt
end

.runObject



50
51
52
53
54
55
56
# File 'lib/hate/core.rb', line 50

def self.run
  trapcc  # Trap CTRL-C
  options # Load cli options
  @window = Hate::Graphics::Window.new
  load    # Load user game
  @window.start
end

.timeObject

Get the current time in seconds according to GLUT_ELAPSED_TIME.



64
65
66
# File 'lib/hate/core.rb', line 64

def self.time
  @window.time
end

.trapccObject



10
11
12
13
14
# File 'lib/hate/core.rb', line 10

def self.trapcc
  trap('INT') do
    self.halt
  end
end

.windowObject

Grab the default OpenGL window.



59
60
61
# File 'lib/hate/core.rb', line 59

def self.window
  @window
end