getting the objects on screen, but without attributes
This commit is contained in:
parent
5a4bf30559
commit
043d821836
@ -23,11 +23,10 @@ class MainView
|
|||||||
ParseTask.parse(1).then do |result|
|
ParseTask.parse(1).then do |result|
|
||||||
is = Ast::Expression.from_basic(result)
|
is = Ast::Expression.from_basic(result)
|
||||||
Virtual::Compiler.compile( is , Virtual.machine.space.get_main )
|
Virtual::Compiler.compile( is , Virtual.machine.space.get_main )
|
||||||
puts Virtual.machine.space
|
|
||||||
end.fail do |error|
|
end.fail do |error|
|
||||||
puts "Error: #{error}"
|
raise "Error: #{error}"
|
||||||
end
|
end
|
||||||
space = SpaceView.new Sof::Members.new(Virtual.machine.space).objects
|
space = SpaceView.new
|
||||||
@container.add_child space
|
@container.add_child space
|
||||||
|
|
||||||
animate = Proc.new do
|
animate = Proc.new do
|
||||||
|
@ -1,26 +1,46 @@
|
|||||||
|
|
||||||
class SpaceView < PIXI::Graphics
|
class SpaceView < PIXI::Graphics
|
||||||
|
|
||||||
def initialize objects
|
def initialize
|
||||||
super()
|
super()
|
||||||
|
space = Virtual.machine.space
|
||||||
|
# just a way to get the space into a list. objects is an id => occurence mapping.
|
||||||
|
# occurence.object is the object
|
||||||
|
objects = Sof::Members.new(space).objects
|
||||||
@objects = objects
|
@objects = objects
|
||||||
@pos1 = PIXI::Point.new 100 , 100
|
# create a mapping from id to volt models
|
||||||
@pos2 = PIXI::Point.new 200 , 200
|
@view_objects = {}
|
||||||
@text1 = PIXI::Text.new "ONE"
|
|
||||||
@text2 = PIXI::Text.new "TWO"
|
|
||||||
@text1.position = @pos1
|
|
||||||
@text2.position = @pos2
|
|
||||||
|
|
||||||
add_child @text1
|
@objects.each do |i , o|
|
||||||
add_child @text2
|
view = Volt::Model.new
|
||||||
|
# view._object_id = i
|
||||||
|
@view_objects[i] = view
|
||||||
|
at = PIXI::Point.new 100 , 100
|
||||||
|
name = PIXI::Text.new i.to_s
|
||||||
|
view._name = name
|
||||||
|
add_child name
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# should almost be called draw by now
|
||||||
def update
|
def update
|
||||||
|
update_positions
|
||||||
self.clear
|
self.clear
|
||||||
self.lineStyle(4, 0xffd900, 2)
|
prev = nil
|
||||||
self.moveTo(@pos1.x , @pos1.y )
|
@view_objects.each do |i , view|
|
||||||
self.lineTo( @pos2.x , @pos2.y)
|
if prev
|
||||||
@pos1.x += 1
|
self.lineStyle(4, 0xffd900, 2)
|
||||||
|
self.moveTo( prev._name.position.x , prev._name.position.y )
|
||||||
|
self.lineTo( view._name.position.x , view._name.position.y )
|
||||||
|
end
|
||||||
|
prev = view
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_positions
|
||||||
|
@view_objects.each do |i , view|
|
||||||
|
view._name.position.x += 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user