Class: Reight::App

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

Direct Known Subclasses

MapEditor, Runner, SoundEditor, SpriteEditor

Defined Under Namespace

Classes: Chips

Constant Summary collapse

SCREEN_WIDTH =
400
SCREEN_HEIGHT =
224
SPACE =
6
BUTTON_SIZE =
12
INDEX_SIZE =
36
BUTTON_SIZE + 2
CHIPS_WIDTH =
128
PALETTE_COLORS =
%w[
  #00000000 #742f29 #ab5236 #f18459 #f7cca9 #ee044e #b8023f #7e2553
  #452d32   #5f574f #a28879 #c2c3c7 #fdf1e8 #f6acc5 #f277a8 #e40dab
  #1d2c53   #3363b0 #42a5a1 #56adff #64dff6 #bd9adf #83759c #644788
  #1e5359   #2d8750 #3eb250 #4fe436 #95f041 #f8ec27 #f3a207 #e26b02
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ App

Returns a new instance of App.



22
23
24
25
# File 'lib/reight/app.rb', line 22

def initialize(project)
  @project = project
  @active  = false
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



27
28
29
# File 'lib/reight/app.rb', line 27

def project
  @project
end

Instance Method Details

#activatedObject



71
72
73
74
75
# File 'lib/reight/app.rb', line 71

def activated()
  add_world world if world
  @setup ||= true.tap {setup}
  @active  = true
end

#active?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/reight/app.rb', line 46

def active?()
  @active
end

#deactivatedObject



77
78
79
80
# File 'lib/reight/app.rb', line 77

def deactivated()
  @active = false
  remove_world world if world
end

#double_clickedObject



108
# File 'lib/reight/app.rb', line 108

def double_clicked() = nil

#drawObject



85
86
87
# File 'lib/reight/app.rb', line 85

def draw()
  navigator.draw
end

#flashObject



33
34
35
# File 'lib/reight/app.rb', line 33

def flash(...)
  navigator.flash(...) if history.enabled?
end

#group(*buttons) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/reight/app.rb', line 37

def group(*buttons)
  buttons.each.with_index do |button, index|
    button.clicked do
      buttons.each.with_index {|b, i| b.active = i == index}
    end
  end
  buttons
end

#historyObject



54
55
56
# File 'lib/reight/app.rb', line 54

def history()
  @history ||= Reight::History.new
end

#icon(xi, yi, size) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/reight/app.rb', line 62

def icon(xi, yi, size)
  (@icon ||= {})[[xi, yi, size]] ||= createGraphics(size, size).tap do |g|
    g.beginDraw do
      g.copy r8.icons, xi * size, yi * size, size, size, 0, 0, size, size
    end
  end
  # TODO: ||= r8.icons.sub_image xi * size, yi * size, size, size
end

#inspectObject

def cut( flash: true) = nil def copy( flash: true) = nil def paste(flash: true) = nil



122
123
124
# File 'lib/reight/app.rb', line 122

def inspect()
  "#<#{self.class.name}:0x#{object_id}>"
end

#key_pressedObject



89
90
91
92
# File 'lib/reight/app.rb', line 89

def key_pressed()
  navigator.key_pressed
  pressing_keys.add key_code
end

#key_releasedObject



94
95
96
# File 'lib/reight/app.rb', line 94

def key_released()
  pressing_keys.delete key_code
end

#key_typedObject



102
# File 'lib/reight/app.rb', line 102

def key_typed()      = nil

#labelObject



29
30
31
# File 'lib/reight/app.rb', line 29

def label()
  self.class.name.split('::').last.gsub(/([a-z])([A-Z])/) {"#{$1} #{$2}"}
end

#mouse_clickedObject



107
# File 'lib/reight/app.rb', line 107

def mouse_clicked()  = nil

#mouse_draggedObject



106
# File 'lib/reight/app.rb', line 106

def mouse_dragged()  = nil

#mouse_movedObject



105
# File 'lib/reight/app.rb', line 105

def mouse_moved()    = nil

#mouse_pressedObject



103
# File 'lib/reight/app.rb', line 103

def mouse_pressed()  = nil

#mouse_releasedObject



104
# File 'lib/reight/app.rb', line 104

def mouse_released() = nil

#mouse_wheelObject



109
# File 'lib/reight/app.rb', line 109

def mouse_wheel()    = nil

#pressing?(key) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/reight/app.rb', line 50

def pressing?(key)
  pressing_keys.include? key
end

#setupObject



82
83
# File 'lib/reight/app.rb', line 82

def setup()
end

#spritesObject



58
59
60
# File 'lib/reight/app.rb', line 58

def sprites()
  navigator.sprites
end

#touch_endedObject



111
# File 'lib/reight/app.rb', line 111

def touch_ended()    = nil

#touch_movedObject



112
# File 'lib/reight/app.rb', line 112

def touch_moved()    = nil

#touch_startedObject



110
# File 'lib/reight/app.rb', line 110

def touch_started()  = nil

#window_movedObject



113
# File 'lib/reight/app.rb', line 113

def window_moved()   = nil

#window_resizedObject



98
99
100
# File 'lib/reight/app.rb', line 98

def window_resized()
  navigator.window_resized
end