player
This commit is contained in:
parent
ce3a777701
commit
40e492d217
|
@ -10,6 +10,19 @@ class Bot extends Pushable
|
||||||
|
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
|
|
||||||
|
@geom = new THREE.SphereGeometry 1, 32, 32
|
||||||
|
@mat = new THREE.MeshPhongMaterial
|
||||||
|
color: 0x0000ff
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 0.9
|
||||||
|
shininess: 0.99
|
||||||
|
|
||||||
|
@mesh = new THREE.Mesh @geom, @mat
|
||||||
|
world.scene.add @mesh
|
||||||
|
# @mesh.matrixAutoUpdate = true
|
||||||
|
|
||||||
@left_tire_rot = 0.0
|
@left_tire_rot = 0.0
|
||||||
@right_tire_rot = 0.0
|
@right_tire_rot = 0.0
|
||||||
@last_fume = 0
|
@last_fume = 0
|
||||||
|
|
|
@ -6,11 +6,32 @@
|
||||||
# 000 000 00000000 000 000
|
# 000 000 00000000 000 000
|
||||||
|
|
||||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||||
|
Vector = require './lib/vector'
|
||||||
|
Pos = require './lib/pos'
|
||||||
|
event = require 'events'
|
||||||
|
|
||||||
class Item
|
class Item extends event
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@move_action = null
|
||||||
|
@direction = new Vector
|
||||||
|
|
||||||
|
del: ->
|
||||||
|
world.removeObject @
|
||||||
|
@emit 'deleted'
|
||||||
|
|
||||||
|
initAction: ->
|
||||||
|
performAction: ->
|
||||||
|
finishAction: ->
|
||||||
|
actionFinished: ->
|
||||||
|
newCellMate: ->
|
||||||
|
cellMateLeft: ->
|
||||||
|
bulletImpact: ->
|
||||||
|
render: ->
|
||||||
|
|
||||||
isSpaceEgoistic: -> true
|
isSpaceEgoistic: -> true
|
||||||
|
isSlippery: -> false
|
||||||
|
|
||||||
setPosition: (p) ->
|
setPosition: (p) ->
|
||||||
@position = @current_position = p
|
@position = @current_position = p
|
||||||
if @mesh?
|
if @mesh?
|
||||||
|
@ -24,4 +45,14 @@ class Item
|
||||||
@mesh.translateZ @position.z
|
@mesh.translateZ @position.z
|
||||||
log 'setPosition', p, @mesh.position
|
log 'setPosition', p, @mesh.position
|
||||||
|
|
||||||
|
getPos: -> new Pos @current_position
|
||||||
|
|
||||||
|
getPosition: -> @position
|
||||||
|
getOrientation: -> @orientation
|
||||||
|
getCurrentPosition: -> @current_position
|
||||||
|
getCurrentOrientation: -> @current_orientation
|
||||||
|
setOrientation: (q) -> @current_orientation = @orientation = q
|
||||||
|
setCurrentPosition: (p) -> @current_position = p
|
||||||
|
setCurrentOrientation: (q) -> @current_orientation = q
|
||||||
|
|
||||||
module.exports = Item
|
module.exports = Item
|
|
@ -51,7 +51,6 @@ class Player extends Bot
|
||||||
|
|
||||||
# Controller.player_status->setStatus status
|
# Controller.player_status->setStatus status
|
||||||
|
|
||||||
|
|
||||||
getActionForKey: (keyName) ->
|
getActionForKey: (keyName) ->
|
||||||
index = 0
|
index = 0
|
||||||
while actionKeyMapping[index].actionName
|
while actionKeyMapping[index].actionName
|
||||||
|
@ -83,7 +82,7 @@ class Player extends Bot
|
||||||
|
|
||||||
setRecordedKey: (keyName) ->
|
setRecordedKey: (keyName) ->
|
||||||
index = 0
|
index = 0
|
||||||
while (actionKeyMapping[index].actionName)
|
while actionKeyMapping[index].actionName
|
||||||
if keyName == actionKeyMapping[index].keyName and actionKeyMapping[index].actionName != RecordingActionName
|
if keyName == actionKeyMapping[index].keyName and actionKeyMapping[index].actionName != RecordingActionName
|
||||||
setKeyForAction "", actionKeyMapping[index].actionName
|
setKeyForAction "", actionKeyMapping[index].actionName
|
||||||
index += 1
|
index += 1
|
||||||
|
@ -93,7 +92,7 @@ class Player extends Bot
|
||||||
updatePosition: () ->
|
updatePosition: () ->
|
||||||
if (move_action)
|
if (move_action)
|
||||||
relTime = (Controller.getTime() - move_action.getStart()) / move_action.getDuration()
|
relTime = (Controller.getTime() - move_action.getStart()) / move_action.getDuration()
|
||||||
if (relTime <= 1.0)
|
if relTime <= 1.0
|
||||||
switch move_action.getId()
|
switch move_action.getId()
|
||||||
when ACTION_FORWARD
|
when ACTION_FORWARD
|
||||||
current_position = position + relTime * getDir()
|
current_position = position + relTime * getDir()
|
||||||
|
@ -112,20 +111,20 @@ class Player extends Bot
|
||||||
KVector playerDir = getCurrentDir()
|
KVector playerDir = getCurrentDir()
|
||||||
KVector playerUp = current_orientation.rotate (KVector(0,1,0)).normal()
|
KVector playerUp = current_orientation.rotate (KVector(0,1,0)).normal()
|
||||||
|
|
||||||
if (look_angle) # player is looking up or down
|
if (@look_angle) # player is looking up or down
|
||||||
projection.setXVector (playerUp.cross (playerDir).normal())
|
projection.setXVector playerUp.cross (playerDir).normal()
|
||||||
look_rot = KQuaternion.rotationAroundVector look_angle, projection.getXVector()
|
look_rot = KQuaternion.rotationAroundVector @look_angle, projection.getXVector()
|
||||||
projection.setYVector (look_rot.rotate (playerUp))
|
projection.setYVector look_rot.rotate (playerUp)
|
||||||
projection.setZVector (look_rot.rotate (-playerDir))
|
projection.setZVector look_rot.rotate (-playerDir)
|
||||||
else
|
else
|
||||||
# smooth camera rotation a little bit
|
# smooth camera rotation a little bit
|
||||||
lookDelta = (2.0 - projection.getZVector() * playerDir) * Controller.getSpeed() / 50.0
|
lookDelta = (2.0 - projection.getZVector() * playerDir) * Controller.getSpeed() / 50.0
|
||||||
KVector newLookVector = (1.0 - lookDelta) * projection.getZVector() - lookDelta * playerDir
|
KVector newLookVector = (1.0 - lookDelta) * projection.getZVector() - lookDelta * playerDir
|
||||||
newLookVector.normalize()
|
newLookVector.normalize()
|
||||||
|
|
||||||
projection.setXVector (playerUp.cross(newLookVector).normal())
|
projection.setXVector playerUp.cross(newLookVector).normal()
|
||||||
projection.setYVector (playerUp)
|
projection.setYVector playerUp
|
||||||
projection.setZVector (newLookVector)
|
projection.setZVector newLookVector
|
||||||
|
|
||||||
return projection
|
return projection
|
||||||
|
|
||||||
|
@ -148,9 +147,9 @@ class Player extends Bot
|
||||||
posDelta = 0.2
|
posDelta = 0.2
|
||||||
projection.setPosition ((1.0 - posDelta) * projection.getPosition() + posDelta * cameraPos)
|
projection.setPosition ((1.0 - posDelta) * projection.getPosition() + posDelta * cameraPos)
|
||||||
|
|
||||||
if (look_angle)
|
if (@look_angle)
|
||||||
projection.setXVector(playerUp.cross(playerDir).normal())
|
projection.setXVector(playerUp.cross(playerDir).normal())
|
||||||
KQuaternion look_rot = KQuaternion.rotationAroundVector(look_angle, projection.getXVector())
|
KQuaternion look_rot = KQuaternion.rotationAroundVector(@look_angle, projection.getXVector())
|
||||||
projection.setYVector(look_rot.rotate(playerUp))
|
projection.setYVector(look_rot.rotate(playerUp))
|
||||||
projection.setZVector(look_rot.rotate(-playerDir))
|
projection.setZVector(look_rot.rotate(-playerDir))
|
||||||
else
|
else
|
||||||
|
@ -201,7 +200,7 @@ class Player extends Bot
|
||||||
# if camera below bot, rotate up
|
# if camera below bot, rotate up
|
||||||
if (botToCameraNormal * playerUp < 0)
|
if (botToCameraNormal * playerUp < 0)
|
||||||
# calculate angle between player to camera vector and player up vector
|
# calculate angle between player to camera vector and player up vector
|
||||||
verticalAngle = RAD2DEG (acos (kMinMax(-1.0, 1.0, botToCameraNormal * playerUp))) - 90.0
|
verticalAngle = RAD2DEG (Math.acos(kMinMax(-1.0, 1.0, botToCameraNormal * playerUp))) - 90.0
|
||||||
cameraPos = playerPos + KQuaternion.rotationAroundVector(verticalAngle/40.0, botToCameraNormal.cross(playerUp)).rotate(botToCamera)
|
cameraPos = playerPos + KQuaternion.rotationAroundVector(verticalAngle/40.0, botToCameraNormal.cross(playerUp)).rotate(botToCamera)
|
||||||
|
|
||||||
botToCamera = cameraPos - playerPos
|
botToCamera = cameraPos - playerPos
|
||||||
|
@ -222,8 +221,8 @@ class Player extends Bot
|
||||||
# .................................................................. try view bot from behind
|
# .................................................................. try view bot from behind
|
||||||
# calculate horizontal angle between bot orientation and vector to camera
|
# calculate horizontal angle between bot orientation and vector to camera
|
||||||
mappedToXZ ((botToCamera - playerUp * (botToCamera * playerUp)).normal())
|
mappedToXZ ((botToCamera - playerUp * (botToCamera * playerUp)).normal())
|
||||||
horizontalAngle = RAD2DEG (acos (kMinMax(-1.0, 1.0, -playerDir * mappedToXZ)))
|
horizontalAngle = RAD2DEG (Math.acos(kMinMax(-1.0, 1.0, -playerDir * mappedToXZ)))
|
||||||
if (botToCameraNormal * playerRight > 0)
|
if botToCameraNormal * playerRight > 0
|
||||||
horizontalAngle = -horizontalAngle
|
horizontalAngle = -horizontalAngle
|
||||||
|
|
||||||
cameraPos = playerPos + KQuaternion.rotationAroundVector(horizontalAngle / (rot_factor * 400.0), playerUp).rotate botToCamera
|
cameraPos = playerPos + KQuaternion.rotationAroundVector(horizontalAngle / (rot_factor * 400.0), playerUp).rotate botToCamera
|
||||||
|
@ -251,9 +250,9 @@ class Player extends Bot
|
||||||
KVector newUpVector = newLookVector.cross(newRightVector).normal()
|
KVector newUpVector = newLookVector.cross(newRightVector).normal()
|
||||||
|
|
||||||
# finished interpolations, update camera matrix
|
# finished interpolations, update camera matrix
|
||||||
projection.setZVector (newLookVector)
|
projection.setZVector newLookVector
|
||||||
projection.setXVector (newRightVector)
|
projection.setXVector newRightVector
|
||||||
projection.setYVector (newUpVector)
|
projection.setYVector newUpVector
|
||||||
|
|
||||||
return projection
|
return projection
|
||||||
|
|
||||||
|
@ -261,53 +260,53 @@ class Player extends Bot
|
||||||
actionId = action.getId()
|
actionId = action.getId()
|
||||||
switch actionId
|
switch actionId
|
||||||
when ACTION_CLIMB_DOWN, ACTION_FORWARD
|
when ACTION_CLIMB_DOWN, ACTION_FORWARD
|
||||||
status.addMoves(1)
|
status.addMoves 1
|
||||||
when ACTION_TURN_LEFT, ACTION_TURN_RIGHT
|
when ACTION_TURN_LEFT, ACTION_TURN_RIGHT
|
||||||
Controller.sound.playSound(KikiSound.BOT_MOVE)
|
Controller.sound.playSound KikiSound.BOT_MOVE
|
||||||
when ACTION_JUMP, ACTION_JUMP_FORWARD
|
when ACTION_JUMP, ACTION_JUMP_FORWARD
|
||||||
status.addMoves(actionId == ACTION_JUMP ? 1 : 2)
|
status.addMoves actionId == ACTION_JUMP and 1 or 2
|
||||||
Controller.sound.playSound(KikiSound.BOT_JUMP)
|
Controller.sound.playSound KikiSound.BOT_JUMP
|
||||||
|
|
||||||
KikiBot.initAction(action)
|
KikiBot.initAction(action)
|
||||||
|
|
||||||
performAction: (action) ->
|
performAction: (action) ->
|
||||||
relTime = action.getRelativeTime()
|
relTime = action.getRelativeTime()
|
||||||
|
|
||||||
switch (action.getId())
|
switch action.getId()
|
||||||
when ACTION_NOOP then return
|
when ACTION_NOOP then return
|
||||||
|
|
||||||
when ACTION_LOOK_UP
|
when ACTION_LOOK_UP
|
||||||
look_angle = relTime * -90.0
|
@look_angle = relTime * -90.0
|
||||||
|
|
||||||
when ACTION_LOOK_DOWN
|
when ACTION_LOOK_DOWN
|
||||||
look_angle = relTime * 90.0
|
@look_angle = relTime * 90.0
|
||||||
|
|
||||||
when ACTION_LOOK_RESET
|
when ACTION_LOOK_RESET
|
||||||
if look_angle > 0
|
if @look_angle > 0
|
||||||
look_angle = Math.min look_angle, (1.0-relTime) * 90.0
|
@look_angle = Math.min @look_angle, (1.0-relTime) * 90.0
|
||||||
else
|
else
|
||||||
look_angle = Math.max look_angle, (1.0-relTime) * -90.0
|
@look_angle = Math.max @look_angle, (1.0-relTime) * -90.0
|
||||||
else
|
else
|
||||||
KikiBot.performAction(action)
|
KikiBot.performAction action
|
||||||
|
|
||||||
finishAction: (action) ->
|
finishAction: (action) ->
|
||||||
actionId = action.getId()
|
actionId = action.getId()
|
||||||
|
|
||||||
if (actionId == ACTION_LOOK_RESET)
|
if actionId == ACTION_LOOK_RESET
|
||||||
look_action = null
|
@look_action = null
|
||||||
look_angle = 0.0
|
@look_angle = 0.0
|
||||||
else
|
else
|
||||||
if (action == move_action) # move finished, update direction
|
if action == move_action # move finished, update direction
|
||||||
dir_sgn = new_dir_sgn
|
dir_sgn = new_dir_sgn
|
||||||
|
|
||||||
if (actionId != ACTION_LOOK_UP and actionId != ACTION_LOOK_DOWN)
|
if actionId != ACTION_LOOK_UP and actionId != ACTION_LOOK_DOWN
|
||||||
KikiBot.finishAction(action)
|
KikiBot.finishAction(action)
|
||||||
|
|
||||||
if (actionId == ACTION_TURN_LEFT or actionId == ACTION_TURN_RIGHT)
|
if actionId == ACTION_TURN_LEFT or actionId == ACTION_TURN_RIGHT
|
||||||
if (rotate)
|
if rotate
|
||||||
rotate_action = getActionWithId (rotate)
|
rotate_action = getActionWithId rotate
|
||||||
rotate_action.reset()
|
rotate_action.reset()
|
||||||
Controller.timer_event.addAction (rotate_action)
|
Controller.timer_event.addAction rotate_action
|
||||||
|
|
||||||
die: () ->
|
die: () ->
|
||||||
Controller.removeKeyHandler (this)
|
Controller.removeKeyHandler (this)
|
||||||
|
@ -324,8 +323,8 @@ class Player extends Bot
|
||||||
KikiBot.reset()
|
KikiBot.reset()
|
||||||
Controller.timer_event.removeActionsOfObject *
|
Controller.timer_event.removeActionsOfObject *
|
||||||
|
|
||||||
look_action = null
|
@look_action = null
|
||||||
look_angle = 0.0
|
@look_angle = 0.0
|
||||||
new_dir_sgn = 1.0
|
new_dir_sgn = 1.0
|
||||||
rotate = 0
|
rotate = 0
|
||||||
|
|
||||||
|
@ -342,15 +341,16 @@ class Player extends Bot
|
||||||
saveRecorder()
|
saveRecorder()
|
||||||
@recorder = new KikiRecorder file
|
@recorder = new KikiRecorder file
|
||||||
|
|
||||||
#define KEY_HANDLED if (recorder) recorder->recordKey (key) return true
|
|
||||||
|
|
||||||
handleKey: (key) ->
|
handleKey: (key) ->
|
||||||
keyName = key.getUnmodifiedName()
|
keyName = key.getUnmodifiedName()
|
||||||
|
keyHandled = ->
|
||||||
|
@recorder?.recordKey key
|
||||||
|
true
|
||||||
|
|
||||||
if (keyName == forward_key or keyName == backward_key)
|
if keyName == forward_key or keyName == backward_key
|
||||||
move = true # try to move as long as the key is not released
|
move = true # try to move as long as the key is not released
|
||||||
|
|
||||||
if (move_action == null) # player is currently not performing a move action
|
if move_action == null # player is currently not performing a move action
|
||||||
# forward or backward direction
|
# forward or backward direction
|
||||||
new_dir_sgn = dir_sgn = (key.getUnmodifiedName() == backward_key) ? -1 : 1
|
new_dir_sgn = dir_sgn = (key.getUnmodifiedName() == backward_key) ? -1 : 1
|
||||||
|
|
||||||
|
@ -358,87 +358,88 @@ class Player extends Bot
|
||||||
else
|
else
|
||||||
new_dir_sgn = (keyName == backward_key) ? -1 : 1
|
new_dir_sgn = (keyName == backward_key) ? -1 : 1
|
||||||
|
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if (keyName == turn_left_key or keyName == turn_right_key)
|
if keyName == turn_left_key or keyName == turn_right_key
|
||||||
rotate = (keyName == turn_left_key) ? ACTION_TURN_LEFT : ACTION_TURN_RIGHT
|
rotate = (keyName == turn_left_key) ? ACTION_TURN_LEFT : ACTION_TURN_RIGHT
|
||||||
|
|
||||||
if (rotate_action == null and spiked == false) # player is not performing a rotation and unspiked
|
if (rotate_action == null and spiked == false) # player is not performing a rotation and unspiked
|
||||||
rotate_action = getActionWithId rotate
|
rotate_action = getActionWithId rotate
|
||||||
Controller.timer_event.addAction rotate_action
|
Controller.timer_event.addAction rotate_action
|
||||||
|
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if key.name == jump_key
|
if key.name == jump_key
|
||||||
jump = true # switch to jump mode until jump_key released
|
jump = true # switch to jump mode until jump_key released
|
||||||
jump_once = true
|
jump_once = true
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if key.name == push_key
|
if key.name == push_key
|
||||||
push = true
|
push = true
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if keyName == shoot_key
|
if keyName == shoot_key
|
||||||
if (shoot == false)
|
if not shoot
|
||||||
shoot = true
|
shoot = true
|
||||||
Controller.timer_event.addAction (getActionWithId (ACTION_SHOOT))
|
Controller.timer_event.addAction (getActionWithId (ACTION_SHOOT))
|
||||||
|
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if keyName == look_up_key or keyName == look_down_key
|
if keyName == look_up_key or keyName == look_down_key
|
||||||
if (!look_action)
|
if not @look_action
|
||||||
look_action = getActionWithId ((key.name == look_up_key) ? ACTION_LOOK_UP : ACTION_LOOK_DOWN)
|
@look_action = getActionWithId ((key.name == look_up_key) ? ACTION_LOOK_UP : ACTION_LOOK_DOWN)
|
||||||
look_action.reset()
|
@look_action.reset()
|
||||||
Controller.timer_event.addAction (look_action)
|
Controller.timer_event.addAction (@look_action)
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
if keyName == view_key
|
if keyName == view_key
|
||||||
world.changeCameraMode()
|
world.changeCameraMode()
|
||||||
KEY_HANDLED
|
return keyHandled()
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
#define KEY_RELEASE_HANDLED if (recorder) recorder->recordKeyRelease (key) return true
|
|
||||||
|
|
||||||
handleKeyRelease: (key) ->
|
handleKeyRelease: (key) ->
|
||||||
keyName = key.getUnmodifiedName()
|
keyName = key.getUnmodifiedName()
|
||||||
|
releaseHandled = ->
|
||||||
|
@recorder?.recordKeyRelease key
|
||||||
|
true
|
||||||
|
|
||||||
if (keyName == shoot_key)
|
if keyName == shoot_key
|
||||||
Controller.timer_event.removeAction (getActionWithId(ACTION_SHOOT))
|
Controller.timer_event.removeAction getActionWithId ACTION_SHOOT
|
||||||
shoot = false
|
shoot = false
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if (keyName == forward_key or keyName == backward_key)
|
if keyName == forward_key or keyName == backward_key
|
||||||
move = false
|
move = false
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if key.name == jump_key
|
if key.name == jump_key
|
||||||
jump = false
|
jump = false
|
||||||
if jump_once
|
if jump_once
|
||||||
if (move_action == null and world.isUnoccupiedPos (position + getUp()))
|
if move_action == null and world.isUnoccupiedPos position.plus getUp()
|
||||||
jump_once = false
|
jump_once = false
|
||||||
move_action = getActionWithId (ACTION_JUMP)
|
move_action = getActionWithId ACTION_JUMP
|
||||||
Controller.sound.playSound (KikiSound.BOT_JUMP)
|
Controller.sound.playSound (KikiSound.BOT_JUMP)
|
||||||
Controller.timer_event.addAction (move_action)
|
Controller.timer_event.addAction (move_action)
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if keyName == turn_left_key or keyName == turn_right_key
|
if keyName == turn_left_key or keyName == turn_right_key
|
||||||
rotate = 0
|
rotate = 0
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if key.name == push_key
|
if key.name == push_key
|
||||||
push = false
|
push = false
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if keyName == look_down_key or keyName == look_up_key
|
if keyName == look_down_key or keyName == look_up_key
|
||||||
if (look_action and look_action.getId() != ACTION_LOOK_RESET)
|
if @look_action and @look_action.getId() != ACTION_LOOK_RESET
|
||||||
Controller.timer_event.removeAction (look_action)
|
Controller.timer_event.removeAction @look_action
|
||||||
look_action = getActionWithId (ACTION_LOOK_RESET)
|
@look_action = getActionWithId ACTION_LOOK_RESET
|
||||||
Controller.timer_event.addAction (look_action)
|
Controller.timer_event.addAction @look_action
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
if keyName == view_key
|
if keyName == view_key
|
||||||
KEY_RELEASE_HANDLED
|
return releaseHandled()
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -468,7 +469,7 @@ class Player extends Bot
|
||||||
return colors[KikiPlayer_tire_color]
|
return colors[KikiPlayer_tire_color]
|
||||||
|
|
||||||
finishRotateAction: () ->
|
finishRotateAction: () ->
|
||||||
if (rotate_action)
|
if rotate_action
|
||||||
rotate = false
|
rotate = false
|
||||||
finishAction(rotate_action)
|
finishAction(rotate_action)
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,17 @@
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 000
|
# 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
# 000 0000000 0000000 000 000 000 000 0000000 0000000 00000000
|
# 000 0000000 0000000 000 000 000 000 0000000 0000000 00000000
|
||||||
|
|
||||||
class Pushable
|
Item = require './item'
|
||||||
|
|
||||||
|
class Pushable extends Item
|
||||||
|
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
|
super
|
||||||
@pusher = null
|
@pusher = null
|
||||||
@direction = new KVector()
|
@direction = new KVector()
|
||||||
|
|
||||||
# addAction (new KikiAction (this, ACTION_PUSH, "push"));
|
@addAction new KikiAction @, ACTION_PUSH, "push"
|
||||||
# addAction (new KikiAction (this, ACTION_FALL, "fall", 40));
|
@addAction new KikiAction @, ACTION_FALL, "fall", 40
|
||||||
|
|
||||||
pushedByObjectInDirection: (object, dir, duration) ->
|
pushedByObjectInDirection: (object, dir, duration) ->
|
||||||
|
|
||||||
|
@ -25,7 +27,7 @@ class Pushable
|
||||||
# pushAction->setDuration Controller.unmapMsTime duration
|
# pushAction->setDuration Controller.unmapMsTime duration
|
||||||
# Controller.timer_event->addAction (pushAction);
|
# Controller.timer_event->addAction (pushAction);
|
||||||
|
|
||||||
initAction (action) ->
|
initAction: (action) ->
|
||||||
# switch action->getId()
|
# switch action->getId()
|
||||||
# when ACTION_FALL
|
# when ACTION_FALL
|
||||||
# Controller.world->objectWillMoveToPos @, @position + @direction, action->getDuration()
|
# Controller.world->objectWillMoveToPos @, @position + @direction, action->getDuration()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user