This commit is contained in:
monsterkodi 2016-08-16 01:15:08 +02:00
parent 2e755f1d68
commit e5d6ea65f1
6 changed files with 18 additions and 20 deletions

View File

@ -408,11 +408,11 @@ class Bot extends Pushable
if world.isUnoccupiedPos @position.plus @getDir() # forward will be empty if world.isUnoccupiedPos @position.plus @getDir() # forward will be empty
if world.isOccupiedPos @position.plus @getDir().minus @getUp() # below forward is solid if world.isOccupiedPos @position.plus @getDir().minus @getUp() # below forward is solid
occupant = world.getOccupantAtPos @position.plus @getDir().minus @getUp() 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 @move_action = @getActionWithId Action.FORWARD
else else
occupant = world.getOccupantAtPos @position.plus @getDir() 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 @move_action = @getActionWithId Action.CLIMB_UP
if @move_action == null if @move_action == null

View File

@ -28,9 +28,9 @@ module.exports =
create: -> create: ->
# #
s = world.size s = world.size
Switch = require '../switch'
exit_switch = KikiSwitch() exit_switch = new Switch()
exit_switch.getEventWithName("switched").addAction(continuous(() -> world.toggle("exit"))) exit_switch.getEventWithName("switched").addAction world.continuous () -> world.toggle "exit"
world.addObjectAtPos(exit_switch, world.decenter( 0, -2, 0)) world.addObjectAtPos(exit_switch, world.decenter( 0, -2, 0))
world.addObjectAtPos('KikiStone', world.decenter( 0, s.y/2, 0)) world.addObjectAtPos('KikiStone', world.decenter( 0, s.y/2, 0))

View File

@ -9,7 +9,7 @@ module.exports =
jump on the stones to reach it 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 if you move into its direction
""" """
player: position: [0,0,5] player: position: [0,0,5]
@ -22,11 +22,11 @@ module.exports =
s = world.size s = world.size
world.addObjectAtPos('KikiWall', world.decenter(0,0,1 - 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,3 - s.z/2
world.addObjectAtPos('KikiWall', world.decenter(0,0,6 - 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 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(-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,-1,10 - s.z/2

View File

@ -32,7 +32,7 @@ class Pos
minus: (p) -> new Pos @x-p.x, @y-p.y, @z-p.z 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 plus: (p) -> new Pos @x+p.x, @y+p.y, @z+p.z
mul: (f) -> new Pos @x*f, @y*f, @z*f 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 eql: (p) -> @x==p.x and @y==p.y and @z==p.z
add: (p) -> add: (p) ->

View File

@ -24,7 +24,6 @@ class Vector
@w = w @w = w
if Number.isNaN @x if Number.isNaN @x
throw new Error throw new Error
# log "Vector #{x} #{y} #{z} #{w} -> #{@x} #{@y} #{@z} #{@w}"
copy: (v) -> copy: (v) ->
@x = v.x @x = v.x
@ -114,9 +113,7 @@ class Vector
point.minus(planeNormal).dot point.minus(planePos).dot(planeNormal) point.minus(planeNormal).dot point.minus(planePos).dot(planeNormal)
@rayPlaneIntersectionFactor: (rayPos, rayDir, planePos, planeNormal) -> @rayPlaneIntersectionFactor: (rayPos, rayDir, planePos, planeNormal) ->
# ((planePos - rayPos) * planeNormal) / (rayDirection * planeNormal);
r = planePos.minus(rayPos).dot(planeNormal) / rayDir.dot(planeNormal) r = planePos.minus(rayPos).dot(planeNormal) / rayDir.dot(planeNormal)
# log 'rayPlaneIntersectionFactor', r
if Number.isNaN r if Number.isNaN r
log 'rayPos', rayPos log 'rayPos', rayPos
log 'rayDir', rayDir log 'rayDir', rayDir

View File

@ -150,11 +150,12 @@ class World extends Actor
@levelList = [ @levelList = [
# intro # intro
"steps", "steps",
"start", # "start",
#"move", "electro", "elevate", #"move", "electro", "elevate",
# "throw", # "throw",
# easy # easy
"gold", "jump", "escape", "gears", # "gold",
"jump", "escape", "gears",
# "gamma", # "gamma",
"cube", "switch", "borg", "cube", "switch", "borg",
"mini", "mini",