push
This commit is contained in:
parent
c953279c39
commit
f0d7bf95ee
|
@ -45,7 +45,7 @@ class Action
|
|||
i ?= -1
|
||||
m ?= Action.ONCE
|
||||
d ?= 0
|
||||
log "newAction #{i} #{n} #{d} #{m}"
|
||||
# log "Action.constructor #{i} #{n} #{d} #{m}"
|
||||
@object = o
|
||||
@name = n
|
||||
@id = i
|
||||
|
@ -62,7 +62,7 @@ class Action
|
|||
@deleted = true
|
||||
|
||||
perform: () ->
|
||||
# log "action.perform #{@name} action? #{@object.performAction?} #{@object.name}"
|
||||
# log "Action.perform #{@name} action? #{@object.performAction?} #{@object.name}" if @name == 'push'
|
||||
if @object.performAction?
|
||||
@object.performAction @
|
||||
else if _.isFunction @object
|
||||
|
|
|
@ -20,8 +20,8 @@ class Bomb extends Pushable
|
|||
@size = 0.55
|
||||
@splitted = false
|
||||
|
||||
geom = new THREE.DodecahedronGeometry @size
|
||||
geom2 = new THREE.DodecahedronGeometry @size
|
||||
geom = new THREE.DodecahedronGeometry 1
|
||||
geom2 = new THREE.DodecahedronGeometry 1
|
||||
geom2.rotateX Vector.DEG2RAD 90
|
||||
geom.merge geom2
|
||||
|
||||
|
@ -34,6 +34,7 @@ class Bomb extends Pushable
|
|||
shininess: 20
|
||||
|
||||
@mesh = new THREE.Mesh geom, @mat
|
||||
@updateMesh()
|
||||
super
|
||||
|
||||
@addEventWithName 'explode'
|
||||
|
|
|
@ -40,19 +40,18 @@ class Item extends Actor
|
|||
|
||||
setPosition: (x,y,z) ->
|
||||
@position = new Vector x,y,z
|
||||
@current_position = new Vector x,y,z
|
||||
@mesh?.position.copy @position
|
||||
@setCurrentPosition @position
|
||||
|
||||
getPos: -> new Pos @current_position
|
||||
setPos: (x,y,z) ->
|
||||
p = new Pos x,y,z
|
||||
@position = @current_position = new Vector p
|
||||
setPos: (x,y,z) -> @setPosition new Pos x,y,z
|
||||
|
||||
setOrientation: (q) ->
|
||||
@current_orientation = @orientation = new Quaternion q
|
||||
# log "item.setOrientation:", @orientation
|
||||
|
||||
setCurrentPosition: (p) -> @current_position = p
|
||||
setCurrentPosition: (p) ->
|
||||
@current_position = new Vector p
|
||||
@mesh?.position.copy @current_position
|
||||
|
||||
setCurrentOrientation: (q) -> @current_orientation = q
|
||||
|
||||
module.exports = Item
|
|
@ -23,9 +23,9 @@ class Levels
|
|||
# "cube",
|
||||
# "switch",
|
||||
# "borg",
|
||||
# "mini",
|
||||
"mini",
|
||||
# "blocks",
|
||||
"bombs",
|
||||
# "bombs",
|
||||
# "sandbox",
|
||||
# "energy",
|
||||
# "maze",
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
# level design by Owen Hay
|
||||
|
||||
# 0000000 00000000 0000000 0000000 00000000
|
||||
# 000 000 000 000 000 000 000 000
|
||||
# 000 0000 0000000 000000000 0000000 00000000
|
||||
# 000 000 000 000 000 000 000 000
|
||||
# 0000000 000 000 000 000 0000000 000
|
||||
|
||||
module.exports =
|
||||
name: "grasp"
|
||||
design: "Owen Hay"
|
||||
scheme: "blue_scheme"
|
||||
intro: "grasp"
|
||||
size: [11,11,11]
|
||||
|
@ -39,7 +45,8 @@ module.exports =
|
|||
world.addObjectAtPos('KikiStone', s.x/2+2, s.y/2, 4)
|
||||
world.addObjectAtPos('KikiStone', s.x/2-2, s.y/2, 4)
|
||||
|
||||
exit_switch = KikiSwitch()
|
||||
exit_switch.getEventWithName("switched").addAction(continuous(() -> world.toggle("exit")))
|
||||
world.addObjectAtPos(exit_switch, s.x/2, s.y/2, 0)
|
||||
Switch = require '../switch'
|
||||
exit_switch = new Switch
|
||||
exit_switch.getEventWithName("switched").addAction continuous -> world.toggle "exit"
|
||||
world.addObjectAtPos exit_switch, s.x/2, s.y/2, 0
|
||||
|
|
@ -43,23 +43,19 @@ class Pushable extends Item
|
|||
initAction: (action) ->
|
||||
switch action.id
|
||||
when Action.PUSH, Action.FALL
|
||||
# log 'Pushable.initAction FALL direction:', @direction
|
||||
world.objectWillMoveToPos @, @position.plus(@direction), action.getDuration()
|
||||
|
||||
performAction: (action) ->
|
||||
# log "Pushable.performAction action #{action.name}"
|
||||
switch action.id
|
||||
when Action.PUSH, Action.FALL
|
||||
@setCurrentPosition @position.plus @direction.mul action.getRelativeTime()
|
||||
|
||||
finishAction: (action) ->
|
||||
# log "Pushable.finishAction #{action.name}"
|
||||
switch action.id
|
||||
when Action.PUSH, Action.FALL
|
||||
@move_action = null
|
||||
targetPos = @current_position.round()
|
||||
world.objectMoved @, @position, targetPos
|
||||
log "Pushable.finishAction setPosition:", targetPos
|
||||
@setPosition targetPos
|
||||
|
||||
actionFinished: (action) ->
|
||||
|
|
|
@ -21,8 +21,8 @@ class Timer
|
|||
# log "Timer.removeActionsOfObject"
|
||||
@event.removeActionsOfObject o
|
||||
|
||||
@addAction: (a) ->
|
||||
log "Timer.addAction #{a.name}"
|
||||
@addAction: (a) ->
|
||||
# log "Timer.addAction #{a.name} duration: #{a.duration}"
|
||||
@event.addAction a
|
||||
|
||||
@removeAction: (a) ->
|
||||
|
|
|
@ -61,7 +61,7 @@ class World extends Actor
|
|||
|
||||
super
|
||||
|
||||
@noRotations = false
|
||||
@noRotations = true
|
||||
|
||||
@screenSize = new Size @view.clientWidth, @view.clientHeight
|
||||
# log "view @screenSize:", @screenSize
|
||||
|
@ -365,7 +365,7 @@ class World extends Actor
|
|||
pos = new Pos x, y, z
|
||||
object = @newObject object
|
||||
@setObjectAtPos object, pos
|
||||
log "addObjectAtPos #{object.name}", pos
|
||||
# log "addObjectAtPos #{object.name}", pos
|
||||
@addObject object
|
||||
|
||||
addObjectLine: (object, sx,sy,sz, ex,ey,ez) ->
|
||||
|
|
Loading…
Reference in New Issue
Block a user