adding space and tryout with lines
This commit is contained in:
parent
ab48f10ee8
commit
456fdc93e1
@ -1,6 +1,7 @@
|
|||||||
require 'opal/pixi'
|
require 'opal/pixi'
|
||||||
require 'native'
|
require 'native'
|
||||||
require "main/lib/registers_view"
|
require "main/lib/registers_view"
|
||||||
|
require "main/lib/space_view"
|
||||||
|
|
||||||
class MainView
|
class MainView
|
||||||
|
|
||||||
@ -15,11 +16,16 @@ class MainView
|
|||||||
html_con = body.firstElementChild
|
html_con = body.firstElementChild
|
||||||
html_con.insertBefore renderer.view , html_con.lastElementChild
|
html_con.insertBefore renderer.view , html_con.lastElementChild
|
||||||
|
|
||||||
@container.add_child RegisterView.new(height - 150)
|
registers = RegisterView.new(height - 150)
|
||||||
|
@container.add_child registers
|
||||||
|
space = SpaceView.new
|
||||||
|
@container.add_child space
|
||||||
|
|
||||||
animate = Proc.new do
|
animate = Proc.new do
|
||||||
`requestAnimationFrame(animate)`
|
`requestAnimationFrame(animate)`
|
||||||
renderer.render @container
|
registers.update
|
||||||
|
space.update
|
||||||
|
renderer.render @container
|
||||||
end
|
end
|
||||||
animate.call
|
animate.call
|
||||||
|
|
||||||
|
@ -14,5 +14,8 @@ class RegisterView < PIXI::Container
|
|||||||
@registers[name] = reg
|
@registers[name] = reg
|
||||||
self.add_child reg
|
self.add_child reg
|
||||||
end
|
end
|
||||||
|
def update
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
26
app/main/lib/space_view.rb
Normal file
26
app/main/lib/space_view.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
class SpaceView < PIXI::Graphics
|
||||||
|
|
||||||
|
def initialize objects
|
||||||
|
super()
|
||||||
|
@objects = objects
|
||||||
|
@pos1 = PIXI::Point.new 100 , 100
|
||||||
|
@pos2 = PIXI::Point.new 200 , 200
|
||||||
|
@text1 = PIXI::Text.new "ONE"
|
||||||
|
@text2 = PIXI::Text.new "TWO"
|
||||||
|
@text1.position = @pos1
|
||||||
|
@text2.position = @pos2
|
||||||
|
|
||||||
|
add_child @text1
|
||||||
|
add_child @text2
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
self.clear
|
||||||
|
self.lineStyle(4, 0xffd900, 2)
|
||||||
|
self.moveTo(@pos1.x , @pos1.y )
|
||||||
|
self.lineTo( @pos2.x , @pos2.y)
|
||||||
|
@pos1.x += 1
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user