make game all screen

This commit is contained in:
Torsten Ruger 2015-07-09 12:32:29 +03:00
parent 84c66f7b97
commit 3f8f5cdc72
3 changed files with 12 additions and 10 deletions

View File

@ -7,9 +7,7 @@ module Main
class MainController < Volt::ModelController
def index
Game.new()
end
def about

View File

@ -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

View File

@ -2,6 +2,3 @@
Home
<:Body>
<div id="game_canvas">
</div>