class AuthorEngine::Game
Attributes
Public Class Methods
new(code:)
click to toggle source
# File lib/author_engine/game/game.rb, line 17 def initialize(code:) @authorengine_code = code if RUBY_ENGINE == "opal" @authorengine_scale = 1.0 @authorengine_canvas = `document.getElementById('canvas')` @authorengine_canvas_context = `#{@authorengine_canvas}.getContext('2d')` end if RUBY_ENGINE != "opal" @authorengine_sprites = SpriteEditor.instance.sprites @authorengine_levels = [] # Create a "Deep Copy" to allow for swapping of a level's sprites without corrupting LevelEditor's version LevelEditor.instance.levels.each do |level| @authorengine_levels << level.sort_by {|sprite| sprite.z}.map {|sprite| sprite.dup} end size = 16 @authorengine_levels.each {|level| level.each {|sprite| sprite.x = sprite.x * size; sprite.y = sprite.y * size}} spritesheet = SpriteEditor.instance.spritesheet @authorengine_collision_detection = CollisionDetection.new(@authorengine_sprites, @authorengine_levels, SaveFile::SpriteSheetData.new(spritesheet.width, spritesheet.height, spritesheet.to_blob)) self.instance_eval(code) end @background_color = black end
Public Instance Methods
draw()
click to toggle source
# File lib/author_engine/game/game.rb, line 57 def draw end
draw_background()
click to toggle source
# File lib/author_engine/game/game.rb, line 50 def draw_background rect(0, 0, width, height, @background_color) end
init()
click to toggle source
# File lib/author_engine/game/game.rb, line 54 def init end
update()
click to toggle source
# File lib/author_engine/game/game.rb, line 60 def update end