diff --git a/coffee/bot.coffee b/coffee/bot.coffee index f415a36..a09a5d6 100644 --- a/coffee/bot.coffee +++ b/coffee/bot.coffee @@ -408,11 +408,11 @@ class Bot extends Pushable if world.isUnoccupiedPos @position.plus @getDir() # forward will be empty if world.isOccupiedPos @position.plus @getDir().minus @getUp() # below forward is solid occupant = world.getOccupantAtPos @position.plus @getDir().minus @getUp() - if occupant == null or not occupant.isSlippery() + if not occupant? or not occupant?.isSlippery() @move_action = @getActionWithId Action.FORWARD else occupant = world.getOccupantAtPos @position.plus @getDir() - if occupant == null or not occupant.isSlippery() + if not occupant? or not occupant?.isSlippery() @move_action = @getActionWithId Action.CLIMB_UP if @move_action == null diff --git a/coffee/levels/escape.coffee b/coffee/levels/escape.coffee index a64a58f..e2bfdfd 100644 --- a/coffee/levels/escape.coffee +++ b/coffee/levels/escape.coffee @@ -28,9 +28,9 @@ module.exports = create: -> # s = world.size - - exit_switch = KikiSwitch() - exit_switch.getEventWithName("switched").addAction(continuous(() -> world.toggle("exit"))) + Switch = require '../switch' + exit_switch = new Switch() + exit_switch.getEventWithName("switched").addAction world.continuous () -> world.toggle "exit" world.addObjectAtPos(exit_switch, world.decenter( 0, -2, 0)) world.addObjectAtPos('KikiStone', world.decenter( 0, s.y/2, 0)) diff --git a/coffee/levels/jump.coffee b/coffee/levels/jump.coffee index 9497d3b..23c1e92 100644 --- a/coffee/levels/jump.coffee +++ b/coffee/levels/jump.coffee @@ -9,10 +9,10 @@ module.exports = jump on the stones to reach it - you can attach to a stone when falling by + you can attach to a stone when falling if you move into its direction """ - player: position: [0,0,5] + player: position: [0,0,5] exits: [ name: "exit" active: 1 @@ -22,11 +22,11 @@ module.exports = s = world.size - world.addObjectAtPos('KikiWall', world.decenter(0,0,1 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(0,0,3 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(0,0,6 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(0,1,10 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(1,0,10 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(-1,0,10 - s.z/2)) - world.addObjectAtPos('KikiWall', world.decenter(0,-1,10 - s.z/2)) + world.addObjectAtPos 'KikiWall', world.decenter 0,0,1 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter 0,0,3 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter 0,0,6 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter 0,1,10 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter 1,0,10 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter -1,0,10 - s.z/2 + world.addObjectAtPos 'KikiWall', world.decenter 0,-1,10 - s.z/2 \ No newline at end of file diff --git a/coffee/lib/pos.coffee b/coffee/lib/pos.coffee index bc915b2..414035e 100644 --- a/coffee/lib/pos.coffee +++ b/coffee/lib/pos.coffee @@ -32,7 +32,7 @@ class Pos minus: (p) -> new Pos @x-p.x, @y-p.y, @z-p.z plus: (p) -> new Pos @x+p.x, @y+p.y, @z+p.z mul: (f) -> new Pos @x*f, @y*f, @z*f - div: (d) -> new Pos @x/d, @y/d, @z/d + div: (d) -> new Pos Math.floor(@x/d), Math.floor(@y/d), Math.floor(@z/d) eql: (p) -> @x==p.x and @y==p.y and @z==p.z add: (p) -> diff --git a/coffee/lib/vector.coffee b/coffee/lib/vector.coffee index aa73cb2..101958f 100644 --- a/coffee/lib/vector.coffee +++ b/coffee/lib/vector.coffee @@ -24,7 +24,6 @@ class Vector @w = w if Number.isNaN @x throw new Error - # log "Vector #{x} #{y} #{z} #{w} -> #{@x} #{@y} #{@z} #{@w}" copy: (v) -> @x = v.x @@ -114,9 +113,7 @@ class Vector point.minus(planeNormal).dot point.minus(planePos).dot(planeNormal) @rayPlaneIntersectionFactor: (rayPos, rayDir, planePos, planeNormal) -> - # ((planePos - rayPos) * planeNormal) / (rayDirection * planeNormal); r = planePos.minus(rayPos).dot(planeNormal) / rayDir.dot(planeNormal) - # log 'rayPlaneIntersectionFactor', r if Number.isNaN r log 'rayPos', rayPos log 'rayDir', rayDir diff --git a/coffee/world.coffee b/coffee/world.coffee index 5cba9b2..4b71405 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -150,11 +150,12 @@ class World extends Actor @levelList = [ # intro "steps", - "start", + # "start", #"move", "electro", "elevate", # "throw", # easy - "gold", "jump", "escape", "gears", + # "gold", + "jump", "escape", "gears", # "gamma", "cube", "switch", "borg", "mini",