diff --git a/app/main/controllers/main_controller.rb b/app/main/controllers/main_controller.rb index c08d08f..90f9a9e 100644 --- a/app/main/controllers/main_controller.rb +++ b/app/main/controllers/main_controller.rb @@ -7,9 +7,7 @@ module Main class MainController < Volt::ModelController def index - Game.new() - end def about diff --git a/app/main/lib/game.rb b/app/main/lib/game.rb index 5e89a98..47316c9 100644 --- a/app/main/lib/game.rb +++ b/app/main/lib/game.rb @@ -1,15 +1,22 @@ require 'opal/pixi' require 'native' +#require_relative "registers" class Game + def initialize - stage = PIXI::Stage.new 0x66FF99 - renderer = PIXI::WebGLRenderer.new 400, 300 + stage = PIXI::Container.new + + height = `window.innerHeight` + width = `window.innerWidth` + puts width + renderer = PIXI::WebGLRenderer.new( width - 100 , height - 100, {}) # opal-jquery would clean this up body = Native(`window.document.body`) # bit of a hack as it assumes index's structure - body.firstElementChild.firstElementChild.appendChild renderer.view + html_con = body.firstElementChild + html_con.insertBefore renderer.view , html_con.lastElementChild texture = PIXI::Texture.from_image "/assets/images/bunny.png" bunny = PIXI::Sprite.new texture @@ -19,10 +26,10 @@ class Game stage.add_child(bunny) animate = Proc.new do - `requestAnimFrame(animate)` + `requestAnimationFrame(animate)` bunny.rotation += 0.1 renderer.render stage end - `requestAnimFrame(animate)` + animate.call end end diff --git a/app/main/views/main/index.html b/app/main/views/main/index.html index 57e8a87..4776f93 100644 --- a/app/main/views/main/index.html +++ b/app/main/views/main/index.html @@ -2,6 +2,3 @@ Home <:Body> - -
-