Class: Reight::R8

Inherits:
Object
  • Object
show all
Defined in:
lib/reight/reight.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, edit: false) ⇒ R8

Returns a new instance of R8.



6
7
8
9
10
11
12
# File 'lib/reight/reight.rb', line 6

def initialize(path, edit: false)
  raise if $r8__
  $r8__ = self

  @path, @edit = path, edit
  self.current = apps.first
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



14
15
16
# File 'lib/reight/reight.rb', line 14

def current
  @current
end

Instance Method Details

#appsObject



22
23
24
25
26
27
28
29
# File 'lib/reight/reight.rb', line 22

def apps()
  @apps ||= [].tap {|a|
    a << Reight::Runner      .new(project)
    a << Reight::SpriteEditor.new(project) if edit?
    a << Reight::MapEditor   .new(project) if edit?
    a << Reight::SoundEditor .new(project) if edit?
  }
end

#control_changeObject



78
# File 'lib/reight/reight.rb', line 78

def control_change() = current.control_change

#double_clickedObject



71
# File 'lib/reight/reight.rb', line 71

def double_clicked() = current.double_clicked

#drawObject



62
# File 'lib/reight/reight.rb', line 62

def draw()           = current.draw

#edit?Boolean

Returns:

  • (Boolean)


16
# File 'lib/reight/reight.rb', line 16

def edit? = @edit

#flashObject



31
# File 'lib/reight/reight.rb', line 31

def flash(...) = current.flash(...)

#iconsObject



33
34
35
36
37
38
39
40
# File 'lib/reight/reight.rb', line 33

def icons()
  @icons ||= loadImage(File.expand_path('../../res/icons.png', __dir__)).tap do |img|
    transp = color '#FF77A8'
    img.load_pixels
    img.pixels.map! {|c| c == transp ? color(0, 0, 0, 0) : c}
    img.update_pixels
  end
end

#key_pressedObject



63
# File 'lib/reight/reight.rb', line 63

def key_pressed()    = current.key_pressed

#key_releasedObject



64
# File 'lib/reight/reight.rb', line 64

def key_released()   = current.key_released

#key_typedObject



65
# File 'lib/reight/reight.rb', line 65

def key_typed()      = current.key_typed

#mouse_clickedObject



70
# File 'lib/reight/reight.rb', line 70

def mouse_clicked()  = current.mouse_clicked

#mouse_draggedObject



69
# File 'lib/reight/reight.rb', line 69

def mouse_dragged()  = current.mouse_dragged

#mouse_movedObject



68
# File 'lib/reight/reight.rb', line 68

def mouse_moved()    = current.mouse_moved

#mouse_pressedObject



66
# File 'lib/reight/reight.rb', line 66

def mouse_pressed()  = current.mouse_pressed

#mouse_releasedObject



67
# File 'lib/reight/reight.rb', line 67

def mouse_released() = current.mouse_released

#mouse_wheelObject



72
# File 'lib/reight/reight.rb', line 72

def mouse_wheel()    = current.mouse_wheel

#note_pressedObject



76
# File 'lib/reight/reight.rb', line 76

def note_pressed()   = current.note_pressed

#note_releasedObject



77
# File 'lib/reight/reight.rb', line 77

def note_released()  = current.note_released

#projectObject



18
19
20
# File 'lib/reight/reight.rb', line 18

def project()
  @project ||= Reight::Project.new @path
end

#setupObject



55
56
57
58
59
60
# File 'lib/reight/reight.rb', line 55

def setup()
  w, h = Reight::App::SCREEN_WIDTH, Reight::App::SCREEN_HEIGHT
  createCanvas w, h
  window_resize(*[w, h].map {_1 * 3})
  text_font r8.project.font, r8.project.font_size
end

#touch_endedObject



74
# File 'lib/reight/reight.rb', line 74

def touch_ended()    = current.touch_ended

#touch_movedObject



75
# File 'lib/reight/reight.rb', line 75

def touch_moved()    = current.touch_moved

#touch_startedObject



73
# File 'lib/reight/reight.rb', line 73

def touch_started()  = current.touch_started

#window_movedObject



79
# File 'lib/reight/reight.rb', line 79

def window_moved()   = apps.each {_1.window_moved}

#window_resizedObject



80
# File 'lib/reight/reight.rb', line 80

def window_resized() = apps.each {_1.window_resized}