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 class MainController < Volt::ModelController
def index def index
Game.new() Game.new()
end end
def about def about

View File

@ -1,15 +1,22 @@
require 'opal/pixi' require 'opal/pixi'
require 'native' require 'native'
#require_relative "registers"
class Game class Game
def initialize def initialize
stage = PIXI::Stage.new 0x66FF99 stage = PIXI::Container.new
renderer = PIXI::WebGLRenderer.new 400, 300
height = `window.innerHeight`
width = `window.innerWidth`
puts width
renderer = PIXI::WebGLRenderer.new( width - 100 , height - 100, {})
# opal-jquery would clean this up # opal-jquery would clean this up
body = Native(`window.document.body`) body = Native(`window.document.body`)
# bit of a hack as it assumes index's structure # 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" texture = PIXI::Texture.from_image "/assets/images/bunny.png"
bunny = PIXI::Sprite.new texture bunny = PIXI::Sprite.new texture
@ -19,10 +26,10 @@ class Game
stage.add_child(bunny) stage.add_child(bunny)
animate = Proc.new do animate = Proc.new do
`requestAnimFrame(animate)` `requestAnimationFrame(animate)`
bunny.rotation += 0.1 bunny.rotation += 0.1
renderer.render stage renderer.render stage
end end
`requestAnimFrame(animate)` animate.call
end end
end end

View File

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