This commit is contained in:
monsterkodi 2016-08-15 03:17:46 +02:00
parent 43c9898aff
commit 1c5b6d624a
3 changed files with 16 additions and 37 deletions

View File

@ -43,8 +43,6 @@ class Bot extends Pushable
color: 0x2222ff color: 0x2222ff
side: THREE.FrontSide side: THREE.FrontSide
shading: THREE.SmoothShading shading: THREE.SmoothShading
roughness: 0.9
metalness: 1
shininess: 5 shininess: 5
@mesh = new THREE.Mesh geom, botMat @mesh = new THREE.Mesh geom, botMat
@ -248,7 +246,7 @@ class Bot extends Pushable
when Action.FALL_FORWARD when Action.FALL_FORWARD
@current_position = @position.plus @getDir().mul(cosFac).plus @getDown().mul(cosFac) @current_position = @position.plus @getDir().mul(relTime).plus @getDown().mul(relTime)
return return
when Action.FALL when Action.FALL
@ -382,7 +380,7 @@ class Bot extends Pushable
@startTimedAction @getActionWithId(Action.NOOP), 0 @startTimedAction @getActionWithId(Action.NOOP), 0
return return
if action.id == Action.PUSH and not @direction.isZero() #or action.id == Action.FALL # not @direction.isZero() if action.id == Action.PUSH and not @direction.isZero()
log 'super (Pushable) action!' log 'super (Pushable) action!'
super action super action
return return
@ -394,13 +392,9 @@ class Bot extends Pushable
# find next action depending on type of finished action and surrounding environment # find next action depending on type of finished action and surrounding environment
if action.id == Action.JUMP_FORWARD if action.id == Action.JUMP_FORWARD
forwardPos = @position.plus @getDir() forwardPos = @position.plus @getDir()
# log 'jump forwardPos', forwardPos if world.isUnoccupiedPos forwardPos # forward will be empty
if world.isUnoccupiedPos forwardPos if world.isUnoccupiedPos forwardPos.minus @getUp() # below forward will also be empty
# forward will be empty
if world.isUnoccupiedPos forwardPos.minus @getUp()
# below forward will also be empty
@move_action = @getActionWithId Action.FALL_FORWARD @move_action = @getActionWithId Action.FALL_FORWARD
# @move_action.takeRwest action
else else
@move_action = @getActionWithId Action.FORWARD @move_action = @getActionWithId Action.FORWARD
world.playSound 'BOT_LAND', @getPos(), 0.25 world.playSound 'BOT_LAND', @getPos(), 0.25
@ -409,24 +403,19 @@ class Bot extends Pushable
@move_action = @getActionWithId Action.CLIMB_UP @move_action = @getActionWithId Action.CLIMB_UP
world.playSound 'BOT_LAND', @getPos(), 0.5 world.playSound 'BOT_LAND', @getPos(), 0.5
else if world.isUnoccupiedPos @position.plus @getDown() # below will be empty else if world.isUnoccupiedPos @position.plus @getDown() # below will be empty
# log 'below will be empty!'
if @move # sticky if moving if @move # sticky if moving
if world.isUnoccupiedPos @position.plus @getDir() if world.isUnoccupiedPos @position.plus @getDir() # forward will be empty
# 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 occupant == null 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 occupant == null or not occupant.isSlippery()
@move_action = @getActionWithId Action.CLIMB_UP @move_action = @getActionWithId Action.CLIMB_UP
if @move_action == null if @move_action == null
# log 'bot.actionFinished fall!'
@move_action = @getActionWithId Action.FALL @move_action = @getActionWithId Action.FALL
# @move_action.takeRest action
else if action.id == Action.FALL or action.id == Action.FALL_FORWARD # landed else if action.id == Action.FALL or action.id == Action.FALL_FORWARD # landed
if @ == world.player if @ == world.player
@ -435,7 +424,6 @@ class Bot extends Pushable
world.playSound 'BOT_LAND', @getPos() world.playSound 'BOT_LAND', @getPos()
if @move_action if @move_action
# log "add move_action! #{@move_action.name}"
Timer.addAction @move_action Timer.addAction @move_action
return return
@ -474,7 +462,6 @@ class Bot extends Pushable
else # forward down is solid else # forward down is solid
@move_action = @getActionWithId Action.FORWARD @move_action = @getActionWithId Action.FORWARD
else # forward is not empty else # forward is not empty
log 'forward is not empty'
moveAction = @getActionWithId Action.FORWARD moveAction = @getActionWithId Action.FORWARD
if @push and world.mayObjectPushToPos @, forwardPos, moveAction.getDuration() if @push and world.mayObjectPushToPos @, forwardPos, moveAction.getDuration()
moveAction.reset() moveAction.reset()
@ -507,12 +494,5 @@ class Bot extends Pushable
@mesh.quaternion.copy @current_orientation @mesh.quaternion.copy @current_orientation
@leftTire.rotation.set Vector.DEG2RAD(180*@left_tire_rot), Vector.DEG2RAD(90), 0 @leftTire.rotation.set Vector.DEG2RAD(180*@left_tire_rot), Vector.DEG2RAD(90), 0
@rightTire.rotation.set Vector.DEG2RAD(180*@right_tire_rot), Vector.DEG2RAD(-90), 0 @rightTire.rotation.set Vector.DEG2RAD(180*@right_tire_rot), Vector.DEG2RAD(-90), 0
# if (@move_action or @rotate_action) and not @died
# unsigned now = getTime()
# if ((int)(now - last_fume) > mapMsTime (40))
# fume = new KikiBotFume()
# world.addObject fume
# fume.setPosition @current_position - @getCurrentDir() * 0.4
# @last_fume = now
module.exports = Bot module.exports = Bot

View File

@ -241,9 +241,8 @@ class Player extends Bot
initAction: (action) -> initAction: (action) ->
# log "initAction #{action.id} #{action.name}" # log "initAction #{action.id} #{action.name}"
switch action.id switch action.id
when Action.CLIMB_DOWN, Action.FORWARD # when Action.CLIMB_DOWN, Action.FORWARD
# @status.addMoves 1 # @status.addMoves 1
log 'init action forward'
when Action.TURN_LEFT, Action.TURN_RIGHT when Action.TURN_LEFT, Action.TURN_RIGHT
world.playSound 'BOT_MOVE' world.playSound 'BOT_MOVE'
when Action.JUMP when Action.JUMP
@ -348,8 +347,6 @@ class Player extends Bot
if not @rotate_action? and not @spiked # player is not performing a rotation and unspiked if not @rotate_action? and not @spiked # player is not performing a rotation and unspiked
@rotate_action = @getActionWithId @rotate @rotate_action = @getActionWithId @rotate
Timer.addAction @rotate_action Timer.addAction @rotate_action
else
log 'already rotating!'
return true return true
when @key.jump when @key.jump
@ -417,12 +414,13 @@ class Player extends Bot
when @key.jump when @key.jump
@jump = false @jump = false
if @jump_once @jump_once = false
if not @move_action? and world.isUnoccupiedPos @position.plus @getUp() # if @jump_once
@jump_once = false # if not @move_action? and world.isUnoccupiedPos @position.plus @getUp()
@move_action = @getActionWithId Action.JUMP # @jump_once = false
world.playSound 'BOT_JUMP' # @move_action = @getActionWithId Action.JUMP
Timer.addAction @move_action # world.playSound 'BOT_JUMP'
# Timer.addAction @move_action
return true return true
when @key.left, @key.right when @key.left, @key.right

View File

@ -719,6 +719,7 @@ class World extends Actor
log "world.objectWillMoveToPos [WARNING] already occupied:", pos log "world.objectWillMoveToPos [WARNING] already occupied:", pos
if object != @player if object != @player
log '---------- tmpObjects'
@unsetObject object # remove object from cell grid @unsetObject object # remove object from cell grid
# log 'tmpObject at new pos', pos # log 'tmpObject at new pos', pos
tmpObject = new TmpObject object # insert tmp object at new pos tmpObject = new TmpObject object # insert tmp object at new pos