remove pixi, going back to html
This commit is contained in:
parent
e51d6cb3fa
commit
1d005862ac
2
Gemfile
2
Gemfile
@ -13,8 +13,6 @@ gem 'volt-bootstrap', '~> 0.0.10'
|
||||
gem 'csso-rails', '~> 0.3.4', require: false
|
||||
gem 'uglifier', '>= 2.4.0', require: false
|
||||
|
||||
gem 'opal-pixi' , :path => "../opal-pixi"
|
||||
|
||||
#gem "salama" , "0.2" , :path => "../salama"
|
||||
|
||||
gem "parslet" , path: "../parslet"
|
||||
|
@ -1,9 +1,3 @@
|
||||
PATH
|
||||
remote: ../opal-pixi
|
||||
specs:
|
||||
opal-pixi (0.1.0)
|
||||
opal (~> 0.7.2)
|
||||
|
||||
PATH
|
||||
remote: ../parslet
|
||||
specs:
|
||||
@ -172,7 +166,6 @@ DEPENDENCIES
|
||||
chromedriver2-helper (~> 0.0.8)
|
||||
concurrent-ruby-ext (~> 0.8.0)
|
||||
csso-rails (~> 0.3.4)
|
||||
opal-pixi!
|
||||
opal-rspec (~> 0.4.2)
|
||||
parslet!
|
||||
poltergeist (~> 1.5.0)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
||||
require 'opal/pixi'
|
||||
require 'native'
|
||||
|
||||
require "salama"
|
||||
|
||||
require_relative "registers_view"
|
||||
@ -9,20 +8,8 @@ require_relative "space_view"
|
||||
class MainView
|
||||
|
||||
def initialize
|
||||
@container = PIXI::Container.new
|
||||
|
||||
height = `window.innerHeight` - 150
|
||||
width = `window.innerWidth` - 200
|
||||
max = PIXI::Point.new width , height
|
||||
puts "max #{max.x}, #{max.y}"
|
||||
renderer = PIXI::WebGLRenderer.new( max.x , max.y , {"backgroundColor" => 0xFFFFFF})
|
||||
body = Native(`window.document.body`)
|
||||
# bit of a hack as it assumes index's structure
|
||||
html_con = body.firstElementChild
|
||||
html_con.insertBefore renderer.view , html_con.lastElementChild
|
||||
|
||||
registers = RegisterView.new(max)
|
||||
@container.add_child registers
|
||||
|
||||
ParseTask.parse(1).then do |result|
|
||||
is = Ast::Expression.from_basic(result)
|
||||
@ -32,17 +19,8 @@ class MainView
|
||||
raise "Error: #{error}"
|
||||
end
|
||||
space = SpaceView.new(max)
|
||||
@container.add_child space
|
||||
|
||||
animate = Proc.new do
|
||||
`requestAnimationFrame(animate)`
|
||||
registers.draw_me
|
||||
space.draw_me
|
||||
renderer.render @container
|
||||
end
|
||||
animate.call
|
||||
|
||||
end
|
||||
|
||||
attr_reader :container
|
||||
end
|
||||
|
@ -5,11 +5,9 @@ class ObjectView
|
||||
|
||||
def initialize o
|
||||
super()
|
||||
self.text = PIXI::Text.new("no")
|
||||
self.text.position = PIXI::Point.new( rand(1000) , rand(550))
|
||||
puts "NO O " unless o
|
||||
self.object = o
|
||||
self.text.text = short
|
||||
self.text = short
|
||||
@attributes = {}
|
||||
end
|
||||
|
||||
@ -27,12 +25,5 @@ class ObjectView
|
||||
def get(name)
|
||||
@attributes[name]
|
||||
end
|
||||
def position
|
||||
#raise "NONAME" unless self.text
|
||||
self.text.position
|
||||
end
|
||||
|
||||
def distance to
|
||||
self.position - to.position
|
||||
end
|
||||
end
|
||||
|
@ -1,21 +1,8 @@
|
||||
|
||||
class RegisterView < PIXI::Container
|
||||
class RegisterView
|
||||
|
||||
@@register_names = (0..8).collect {|i| "r#{i}"}
|
||||
|
||||
def initialize max
|
||||
super()
|
||||
@registers = {}
|
||||
x = 0
|
||||
@@register_names.each do |name|
|
||||
reg = PIXI::Text.new( name )
|
||||
reg.position = PIXI::Point.new x , max.x - 100
|
||||
x += reg.width + 20
|
||||
@registers[name] = reg
|
||||
self.add_child reg
|
||||
end
|
||||
def draw_me
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,12 +1,10 @@
|
||||
|
||||
class SpaceView < PIXI::Graphics
|
||||
class SpaceView
|
||||
include Sof::Util
|
||||
|
||||
def initialize max
|
||||
super()
|
||||
@max = max
|
||||
@max.x -= 50
|
||||
@max.y -= 20
|
||||
|
||||
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
|
||||
@ -31,61 +29,6 @@ class SpaceView < PIXI::Graphics
|
||||
fill_attributes
|
||||
end
|
||||
|
||||
# should almost be called draw by now
|
||||
def draw_me
|
||||
update_positions
|
||||
self.clear
|
||||
@view_objects.each do |i , view|
|
||||
self.lineStyle(4, 0xffd900, 2)
|
||||
puts "v" if view.nil?
|
||||
view.attributes.each do |n , v |
|
||||
next if n == :id
|
||||
next unless v.is_a? ObjectView
|
||||
next unless v.is_parfait
|
||||
puts "v2" if view.nil?
|
||||
puts "0" if v.nil?
|
||||
self.moveTo( view.position.x , view.position.y )
|
||||
# self.lineTo( v.position.x , v.position.y )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def force from , to , offset = 0
|
||||
dir_x = from.x - to.x
|
||||
dir_x2 = (dir_x - offset ) * (dir_x - offset )
|
||||
dir_y = from.y - to.y
|
||||
dir_y2 =( dir_y - offset) * (dir_y - offset)
|
||||
if( dir_x2 < 0.1 and dir_y2 < 0.1 )
|
||||
puts "Were close"
|
||||
dir_x = rand(3)
|
||||
dir_y = rand(3)
|
||||
end
|
||||
f = dir_x * dir_x + dir_y * dir_y
|
||||
f = f / 200
|
||||
f = 0.01 if f < 0.01
|
||||
#puts "force #{f}"
|
||||
PIXI::Point.new( dir_x / f , dir_y / f)
|
||||
end
|
||||
|
||||
def update_positions
|
||||
@view_objects.each do |i , view|
|
||||
view.attributes.each do |n , v |
|
||||
next if n == :id
|
||||
next unless v.is_a? ObjectView
|
||||
next unless v.is_parfait
|
||||
view.position.add_and_bounce force( view.position , v.position , 20 ).scale_by(-1.5) , @max
|
||||
end
|
||||
@view_objects.each do |ii , vv |
|
||||
next if i == ii
|
||||
view.position.add_and_bounce force( view.position , vv.position ) , @max
|
||||
end
|
||||
offset = 100
|
||||
view.position.add_and_bounce force( view.position , view.position.at_x(-offset) ) , @max
|
||||
view.position.add_and_bounce force( view.position , view.position.at_y(-offset) ) , @max
|
||||
view.position.add_and_bounce force( view.position , view.position.at_y(@max.y + offset) ) , @max
|
||||
view.position.add_and_bounce force( view.position , view.position.at_x(@max.x + offset) ) , @max
|
||||
end
|
||||
end
|
||||
|
||||
def fill_attributes
|
||||
@view_objects.each do |i , view|
|
||||
|
Loading…
Reference in New Issue
Block a user