make game all screen
This commit is contained in:
parent
84c66f7b97
commit
3f8f5cdc72
@ -7,9 +7,7 @@ module Main
|
||||
class MainController < Volt::ModelController
|
||||
|
||||
def index
|
||||
|
||||
Game.new()
|
||||
|
||||
end
|
||||
|
||||
def about
|
||||
|
@ -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
|
||||
|
@ -2,6 +2,3 @@
|
||||
Home
|
||||
|
||||
<:Body>
|
||||
|
||||
<div id="game_canvas">
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user