getting the objects on screen, but without attributes

This commit is contained in:
Torsten Ruger 2015-07-13 18:49:46 +03:00
parent 5a4bf30559
commit 043d821836
2 changed files with 35 additions and 16 deletions

View File

@ -23,11 +23,10 @@ class MainView
ParseTask.parse(1).then do |result|
is = Ast::Expression.from_basic(result)
Virtual::Compiler.compile( is , Virtual.machine.space.get_main )
puts Virtual.machine.space
end.fail do |error|
puts "Error: #{error}"
raise "Error: #{error}"
end
space = SpaceView.new Sof::Members.new(Virtual.machine.space).objects
space = SpaceView.new
@container.add_child space
animate = Proc.new do

View File

@ -1,26 +1,46 @@
class SpaceView < PIXI::Graphics
def initialize objects
def initialize
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
@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
# create a mapping from id to volt models
@view_objects = {}
add_child @text1
add_child @text2
@objects.each do |i , o|
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
# should almost be called draw by now
def update
update_positions
self.clear
self.lineStyle(4, 0xffd900, 2)
self.moveTo(@pos1.x , @pos1.y )
self.lineTo( @pos2.x , @pos2.y)
@pos1.x += 1
prev = nil
@view_objects.each do |i , view|
if prev
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