cage
This commit is contained in:
parent
a8b4438c58
commit
30f8389a2c
|
@ -60,8 +60,13 @@ class Action
|
||||||
if @object? then @object.removeAction @
|
if @object? then @object.removeAction @
|
||||||
@deleted = true
|
@deleted = true
|
||||||
|
|
||||||
|
perform: () ->
|
||||||
|
if @object.performAction?
|
||||||
|
@object.performAction @
|
||||||
|
else if _.isFunction @object
|
||||||
|
@object()
|
||||||
|
|
||||||
init: () -> @object.initAction? @
|
init: () -> @object.initAction? @
|
||||||
perform: () -> @object.performAction? @
|
|
||||||
finish: () -> @object.finishAction? @
|
finish: () -> @object.finishAction? @
|
||||||
finished: () ->
|
finished: () ->
|
||||||
# log "Action.finished #{@name} #{@object?.actionFinished?}"
|
# log "Action.finished #{@name} #{@object?.actionFinished?}"
|
||||||
|
|
|
@ -96,7 +96,7 @@ class Actor extends Emitter
|
||||||
|
|
||||||
startTimedAction: (action, duration) ->
|
startTimedAction: (action, duration) ->
|
||||||
action.duration = duration if duration >= 0
|
action.duration = duration if duration >= 0
|
||||||
# log "Actor.startTimedAction #{action.name} duration: #{duration}"
|
# log "Actor.startTimedAction #{action.name} duration: #{action.duration}"
|
||||||
Timer.addAction action
|
Timer.addAction action
|
||||||
|
|
||||||
module.exports = Actor
|
module.exports = Actor
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
# 000 000 000 000 000 000
|
# 000 000 000 000 000 000
|
||||||
# 0000000 000 000 0000000 00000000
|
# 0000000 000 000 0000000 00000000
|
||||||
|
|
||||||
|
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||||
|
|
||||||
class Cage
|
class Cage
|
||||||
|
|
||||||
constructor: (@size, @gap) ->
|
@cageMat = new THREE.MeshPhongMaterial
|
||||||
|
|
||||||
cageMat = new THREE.MeshPhongMaterial
|
|
||||||
color: 0x880000
|
color: 0x880000
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
|
@ -16,22 +16,24 @@ class Cage
|
||||||
emissive: 0x880000
|
emissive: 0x880000
|
||||||
emissiveIntensity: 0.02
|
emissiveIntensity: 0.02
|
||||||
|
|
||||||
rasterMat = new THREE.MeshPhongMaterial
|
@rasterMat = new THREE.MeshPhongMaterial
|
||||||
color: 0x880000
|
color: 0x880000
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
shininess: 20
|
shininess: 20
|
||||||
|
|
||||||
geom = @wallTiles 0
|
constructor: (@size, gap) ->
|
||||||
@raster = new THREE.Mesh geom, rasterMat
|
Cage.gap = gap
|
||||||
|
geom = Cage.wallTiles @size, 'inside', 0
|
||||||
|
@raster = new THREE.Mesh geom, Cage.rasterMat
|
||||||
@raster.translateX -0.5
|
@raster.translateX -0.5
|
||||||
@raster.translateY -0.5
|
@raster.translateY -0.5
|
||||||
@raster.translateZ -0.5
|
@raster.translateZ -0.5
|
||||||
@raster.receiveShadow = true
|
@raster.receiveShadow = true
|
||||||
world.scene.add @raster
|
world.scene.add @raster
|
||||||
|
|
||||||
geom = @wallTiles @gap
|
geom = Cage.wallTiles @size, 'inside', Cage.gap
|
||||||
@cage = new THREE.Mesh geom, cageMat
|
@cage = new THREE.Mesh geom, Cage.cageMat
|
||||||
@cage.translateX -0.5
|
@cage.translateX -0.5
|
||||||
@cage.translateY -0.5
|
@cage.translateY -0.5
|
||||||
@cage.translateZ -0.5
|
@cage.translateZ -0.5
|
||||||
|
@ -42,157 +44,155 @@ class Cage
|
||||||
world.scene.remove @raster
|
world.scene.remove @raster
|
||||||
world.scene.remove @cage
|
world.scene.remove @cage
|
||||||
|
|
||||||
wallTiles: (raster=0) ->
|
@wallTiles: (size, side, raster=Cage.gap) ->
|
||||||
|
|
||||||
faces = @size.x * @size.y * 2 + @size.x * @size.z * 2 + @size.y * @size.z * 2
|
faces = size.x * size.y * 2 + size.x * size.z * 2 + size.y * size.z * 2
|
||||||
triangles = faces * 2
|
triangles = faces * 2
|
||||||
|
|
||||||
positions = new Float32Array triangles * 3 * 3
|
positions = new Float32Array triangles * 3 * 3
|
||||||
normals = new Float32Array triangles * 3 * 3
|
normals = new Float32Array triangles * 3 * 3
|
||||||
|
|
||||||
s = 1-raster
|
s = 1-raster
|
||||||
o = raster
|
o = raster
|
||||||
i = -1
|
i = -1
|
||||||
offset = raster/20
|
offset = (side == 'outside' and -1 or 1) * raster/20
|
||||||
|
|
||||||
z = offset
|
xyPlate = (x, y, z) ->
|
||||||
n = 1
|
|
||||||
for x in [0...@size.x]
|
|
||||||
for y in [0...@size.y]
|
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = 1
|
||||||
|
|
||||||
z = @size.z - offset
|
yxPlate = (x, y, z) ->
|
||||||
n = -1
|
|
||||||
for x in [0...@size.x]
|
|
||||||
for y in [0...@size.y]
|
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z ; normals[i] = n
|
positions[i+=1] = z ; normals[i] = -1
|
||||||
|
|
||||||
y = offset
|
zxPlate = (x, y, z) ->
|
||||||
n = 1
|
|
||||||
for x in [0...@size.x]
|
|
||||||
for z in [0...@size.z]
|
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = 1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
|
|
||||||
y = @size.y - offset
|
xzPlate = (x, y, z) ->
|
||||||
n = -1
|
|
||||||
for x in [0...@size.x]
|
|
||||||
for z in [0...@size.z]
|
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
|
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x+o; normals[i] = 0
|
positions[i+=1] = x+o; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x+s; normals[i] = 0
|
positions[i+=1] = x+s; normals[i] = 0
|
||||||
positions[i+=1] = y ; normals[i] = n
|
positions[i+=1] = y ; normals[i] = -1
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
|
|
||||||
x = offset
|
yzPlate = (x, y, z) ->
|
||||||
n = 1
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
for y in [0...@size.y]
|
|
||||||
for z in [0...@size.z]
|
|
||||||
positions[i+=1] = x ; normals[i] = n
|
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = 1
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
|
|
||||||
x = @size.x-offset
|
zyPlate = (x, y, z) ->
|
||||||
n = -1
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
for y in [0...@size.y]
|
|
||||||
for z in [0...@size.z]
|
|
||||||
positions[i+=1] = x ; normals[i] = n
|
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+o; normals[i] = 0
|
positions[i+=1] = z+o; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
positions[i+=1] = y+o; normals[i] = 0
|
positions[i+=1] = y+o; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
positions[i+=1] = x ; normals[i] = n
|
positions[i+=1] = x ; normals[i] = -1
|
||||||
positions[i+=1] = y+s; normals[i] = 0
|
positions[i+=1] = y+s; normals[i] = 0
|
||||||
positions[i+=1] = z+s; normals[i] = 0
|
positions[i+=1] = z+s; normals[i] = 0
|
||||||
|
|
||||||
|
plates = side == 'outside' and [yxPlate, xyPlate, xzPlate, zxPlate, zyPlate, yzPlate] or [xyPlate, yxPlate, zxPlate, xzPlate, yzPlate, zyPlate]
|
||||||
|
for x in [0...size.x]
|
||||||
|
for y in [0...size.y]
|
||||||
|
plates[0] x, y, offset
|
||||||
|
plates[1] x, y, size.z - offset
|
||||||
|
|
||||||
|
for x in [0...size.x]
|
||||||
|
for z in [0...size.z]
|
||||||
|
plates[2] x, offset, z
|
||||||
|
plates[3] x, size.y - offset, z
|
||||||
|
|
||||||
|
for y in [0...size.y]
|
||||||
|
for z in [0...size.z]
|
||||||
|
plates[4] offset, y, z
|
||||||
|
plates[5] size.x-offset, y, z
|
||||||
|
|
||||||
geom = new THREE.BufferGeometry
|
geom = new THREE.BufferGeometry
|
||||||
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||||
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||||
|
|
|
@ -58,11 +58,11 @@ class Event
|
||||||
triggerActions: () ->
|
triggerActions: () ->
|
||||||
return if not @actions.length
|
return if not @actions.length
|
||||||
@time = world.getTime()
|
@time = world.getTime()
|
||||||
# log 'trigger actions', @time, @actions.length
|
# log "trigger actions #{@name}", @actions.length
|
||||||
@save_actions = _.clone @actions
|
@save_actions = _.clone @actions
|
||||||
while @save_actions.length
|
while @save_actions.length
|
||||||
action = last @save_actions
|
action = last @save_actions
|
||||||
# log "performAction #{action.name}" if action.name != 'noop'
|
# log "event.performAction #{action.name}" if action.name != 'noop'
|
||||||
action.performWithEvent @
|
action.performWithEvent @
|
||||||
if @save_actions.length and action == last @save_actions
|
if @save_actions.length and action == last @save_actions
|
||||||
@save_actions.pop()
|
@save_actions.pop()
|
||||||
|
|
|
@ -8,6 +8,7 @@ log = require "/Users/kodi/s/ko/js/tools/log"
|
||||||
|
|
||||||
Vector = require './lib/vector'
|
Vector = require './lib/vector'
|
||||||
Switch = require './switch'
|
Switch = require './switch'
|
||||||
|
Light = require './light'
|
||||||
Action = require './action'
|
Action = require './action'
|
||||||
|
|
||||||
class Gate extends Switch
|
class Gate extends Switch
|
||||||
|
@ -22,6 +23,12 @@ class Gate extends Switch
|
||||||
@sound_on = 'GATE_OPEN'
|
@sound_on = 'GATE_OPEN'
|
||||||
@sound_off = 'GATE_CLOSE'
|
@sound_off = 'GATE_CLOSE'
|
||||||
|
|
||||||
|
createLight: ->
|
||||||
|
@light = new Light
|
||||||
|
pos: @position
|
||||||
|
radius: 12.0
|
||||||
|
shadow: true
|
||||||
|
|
||||||
createMesh: () ->
|
createMesh: () ->
|
||||||
torusRadius = 0.05
|
torusRadius = 0.05
|
||||||
t1 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
t1 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||||
|
|
|
@ -17,12 +17,17 @@ class Levels
|
||||||
# easy
|
# easy
|
||||||
# "gold",
|
# "gold",
|
||||||
# "jump",
|
# "jump",
|
||||||
"escape", "gears",
|
# "escape",
|
||||||
|
# "gears",
|
||||||
# "gamma",
|
# "gamma",
|
||||||
"cube", "switch", "borg",
|
# "cube",
|
||||||
|
# "switch",
|
||||||
|
# "borg",
|
||||||
"mini",
|
"mini",
|
||||||
# "blocks",
|
# "blocks",
|
||||||
"bombs", "sandbox", "energy", "maze", "love",
|
# "bombs",
|
||||||
|
"sandbox",
|
||||||
|
"energy", "maze", "love",
|
||||||
# medium
|
# medium
|
||||||
"towers", "edge", "random", "plate", "nice", "entropy",
|
"towers", "edge", "random", "plate", "nice", "entropy",
|
||||||
# owen hay's levels (TODO: sort in)
|
# owen hay's levels (TODO: sort in)
|
||||||
|
|
|
@ -65,7 +65,7 @@ module.exports =
|
||||||
world.switch_counter = 0
|
world.switch_counter = 0
|
||||||
|
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
||||||
exit.setActive(world.switch_counter == 4)
|
exit.setActive(world.switch_counter == 4)
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,4 @@ module.exports =
|
||||||
for j in [0...5]
|
for j in [0...5]
|
||||||
for l in [0...5]
|
for l in [0...5]
|
||||||
if Math.pow(-1, i+j+l) == -1
|
if Math.pow(-1, i+j+l) == -1
|
||||||
world.addObjectAtPos('KikiStone', KikiPos(i,j,l))
|
world.addObjectAtPos 'KikiStone', i,j,l
|
||||||
|
|
|
@ -67,7 +67,7 @@ module.exports =
|
||||||
world.switch_counter = 0
|
world.switch_counter = 0
|
||||||
|
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate (world.getObjectWithName("exit"))
|
exit = kikiObjectToGate (world.getObjectWithName("exit"))
|
||||||
exit.setActive(world.switch_counter == 4)
|
exit.setActive(world.switch_counter == 4)
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports =
|
||||||
s = world.size
|
s = world.size
|
||||||
Switch = require '../switch'
|
Switch = require '../switch'
|
||||||
exit_switch = new Switch()
|
exit_switch = new Switch()
|
||||||
exit_switch.getEventWithName("switched").addAction world.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
|
||||||
|
@ -39,10 +39,10 @@ module.exports =
|
||||||
world.addObjectAtPos 'KikiStone', world.decenter 0, s.y/2,-1
|
world.addObjectAtPos 'KikiStone', world.decenter 0, s.y/2,-1
|
||||||
world.addObjectAtPos 'KikiStone', world.decenter -1, s.y/2, 0
|
world.addObjectAtPos 'KikiStone', world.decenter -1, s.y/2, 0
|
||||||
|
|
||||||
# world.addObjectLine 'KikiStone', world.decenter(-2, s.y/2,-2), world.decenter( 2, s.y/2,-2)
|
world.addObjectLine 'KikiStone', world.decenter(-2, s.y/2,-2), world.decenter( 2, s.y/2,-2)
|
||||||
# world.addObjectLine 'KikiStone', world.decenter( 2, s.y/2,-2), world.decenter( 2, s.y/2, 2)
|
world.addObjectLine 'KikiStone', world.decenter( 2, s.y/2,-2), world.decenter( 2, s.y/2, 2)
|
||||||
# world.addObjectLine 'KikiStone', world.decenter( 2, s.y/2, 2), world.decenter(-2, s.y/2, 2)
|
world.addObjectLine 'KikiStone', world.decenter( 2, s.y/2, 2), world.decenter(-2, s.y/2, 2)
|
||||||
# world.addObjectLine 'KikiStone', world.decenter(-2, s.y/2, 2), world.decenter(-2, s.y/2,-2)
|
world.addObjectLine 'KikiStone', world.decenter(-2, s.y/2, 2), world.decenter(-2, s.y/2,-2)
|
||||||
|
|
||||||
world.addObjectAtPos 'KikiWall', world.decenter 1, 0, 0
|
world.addObjectAtPos 'KikiWall', world.decenter 1, 0, 0
|
||||||
world.addObjectAtPos 'KikiWall', world.decenter 0, 0, 1
|
world.addObjectAtPos 'KikiWall', world.decenter 0, 0, 1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# level design by Michael Abel
|
# level design by Michael Abel
|
||||||
|
|
||||||
schemes=[test_scheme, tron_scheme,candy_scheme, default_scheme,
|
# schemes=[test_scheme, tron_scheme,candy_scheme, default_scheme,
|
||||||
green_scheme, yellow_scheme, blue_scheme, red_scheme, metal_scheme, bronze_scheme]
|
# green_scheme, yellow_scheme, blue_scheme, red_scheme, metal_scheme, bronze_scheme]
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
name: "gamma"
|
name: "gamma"
|
||||||
|
@ -28,21 +28,21 @@ module.exports =
|
||||||
world.switch_counter = 0
|
world.switch_counter = 0
|
||||||
|
|
||||||
aswitched = () ->
|
aswitched = () ->
|
||||||
applyColorScheme (schemes[world.switch_countera])
|
# applyColorScheme(schemes[world.switch_countera])
|
||||||
if world.switch_countera==schemes.length-1
|
if world.switch_countera==schemes.length-1
|
||||||
world.switch_countera=0
|
world.switch_countera=0
|
||||||
else
|
else
|
||||||
world.switch_countera+=1
|
world.switch_countera+=1
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
||||||
exit.setActive(world.switch_counter == 4)
|
exit.setActive(world.switch_counter == 4)
|
||||||
|
|
||||||
aswitch = KikiSwitch()
|
aswitch = new Switch()
|
||||||
bswitch = KikiSwitch()
|
bswitch = new Switch()
|
||||||
cswitch = KikiSwitch()
|
cswitch = new Switch()
|
||||||
dswitch = KikiSwitch()
|
dswitch = new Switch()
|
||||||
eswitch = KikiSwitch()
|
eswitch = new Switch()
|
||||||
|
|
||||||
aswitch.getEventWithName("switched").addAction(continuous(aswitched))
|
aswitch.getEventWithName("switched").addAction(continuous(aswitched))
|
||||||
bswitch.getEventWithName("switched").addAction(continuous((s=bswitch) -> switched(s)))
|
bswitch.getEventWithName("switched").addAction(continuous((s=bswitch) -> switched(s)))
|
||||||
|
|
|
@ -64,7 +64,7 @@ module.exports =
|
||||||
world.switch_counter = 0
|
world.switch_counter = 0
|
||||||
|
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
||||||
exit.setActive(world.switch_counter == 5)
|
exit.setActive(world.switch_counter == 5)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports =
|
||||||
s = world.size
|
s = world.size
|
||||||
|
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
||||||
exit.setActive(world.switch_counter == 5)
|
exit.setActive(world.switch_counter == 5)
|
||||||
|
|
||||||
|
|
|
@ -16,20 +16,20 @@ module.exports =
|
||||||
position: [0,0,1]
|
position: [0,0,1]
|
||||||
]
|
]
|
||||||
create: ->
|
create: ->
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(1,1,0))
|
world.addObjectAtPos 'KikiWall', 1,1,0
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(3,1,0))
|
world.addObjectAtPos 'KikiWall', 3,1,0
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(1,3,0))
|
world.addObjectAtPos 'KikiWall', 1,3,0
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(3,3,0))
|
world.addObjectAtPos 'KikiWall', 3,3,0
|
||||||
|
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(1,1,6))
|
world.addObjectAtPos 'KikiWall', 1,1,6
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(3,1,6))
|
world.addObjectAtPos 'KikiWall', 3,1,6
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(1,3,6))
|
world.addObjectAtPos 'KikiWall', 1,3,6
|
||||||
world.addObjectAtPos( 'KikiWall', KikiPos(3,3,6))
|
world.addObjectAtPos 'KikiWall', 3,3,6
|
||||||
|
|
||||||
world.addObjectAtPos( 'KikiStone', KikiPos(1,1,1))
|
world.addObjectAtPos 'KikiStone', 1,1,1
|
||||||
world.addObjectAtPos( 'KikiStone', KikiPos(3,1,1))
|
world.addObjectAtPos 'KikiStone', 3,1,1
|
||||||
world.addObjectAtPos( 'KikiStone', KikiPos(1,3,1))
|
world.addObjectAtPos 'KikiStone', 1,3,1
|
||||||
world.addObjectAtPos( 'KikiStone', KikiPos(3,3,1))
|
world.addObjectAtPos 'KikiStone', 3,3,1
|
||||||
|
|
||||||
world.addObjectAtPos( 'KikiStone', KikiPos(2,4,0))
|
world.addObjectAtPos 'KikiStone', 2,4,0
|
||||||
|
|
|
@ -34,53 +34,54 @@ module.exports =
|
||||||
h = 0
|
h = 0
|
||||||
# bomb and stones
|
# bomb and stones
|
||||||
|
|
||||||
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2, s.y/2, s.z/2))
|
world.addObjectAtPos 'KikiStone', s.x/2, s.y/2, s.z/2
|
||||||
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2, s.y-2, s.z/2))
|
world.addObjectAtPos 'KikiStone', s.x/2, s.y-2, s.z/2
|
||||||
|
|
||||||
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2, 1, s.z/2))
|
# world.addObjectAtPos 'KikiBomb', s.x/2, 1, s.z/2
|
||||||
|
|
||||||
# stone frames for switches
|
# stone frames for switches
|
||||||
|
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 0, h-1, s.z/2))
|
world.addObjectAtPos 'KikiWall', world.decenter 0, h-1, s.z/2
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 0, h+1, s.z/2))
|
world.addObjectAtPos 'KikiWall', world.decenter 0, h+1, s.z/2
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 1, h, s.z/2))
|
world.addObjectAtPos 'KikiWall', world.decenter 1, h, s.z/2
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-1, h, s.z/2))
|
world.addObjectAtPos 'KikiWall', world.decenter -1, h, s.z/2
|
||||||
|
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(s.x/2, h-1, 0))
|
world.addObjectAtPos 'KikiWall', world.decenter s.x/2, h-1, 0
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(s.x/2, h+1, 0))
|
world.addObjectAtPos 'KikiWall', world.decenter s.x/2, h+1, 0
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(s.x/2, h, 1))
|
world.addObjectAtPos 'KikiWall', world.decenter s.x/2, h, 1
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(s.x/2, h, -1))
|
world.addObjectAtPos 'KikiWall', world.decenter s.x/2, h, -1
|
||||||
|
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 0, h-1, -s.z/2+1))
|
world.addObjectAtPos 'KikiWall', world.decenter 0, h-1, -s.z/2+1
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 0, h+1, -s.z/2+1))
|
world.addObjectAtPos 'KikiWall', world.decenter 0, h+1, -s.z/2+1
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter( 1, h, -s.z/2+1))
|
world.addObjectAtPos 'KikiWall', world.decenter 1, h, -s.z/2+1
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-1, h, -s.z/2+1))
|
world.addObjectAtPos 'KikiWall', world.decenter -1, h, -s.z/2+1
|
||||||
|
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-s.x/2+1, h-1, 0))
|
world.addObjectAtPos 'KikiWall', world.decenter -s.x/2+1, h-1, 0
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-s.x/2+1, h+1, 0))
|
world.addObjectAtPos 'KikiWall', world.decenter -s.x/2+1, h+1, 0
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-s.x/2+1, h, 1))
|
world.addObjectAtPos 'KikiWall', world.decenter -s.x/2+1, h, 1
|
||||||
world.addObjectAtPos(KikiWall(), world.decenter(-s.x/2+1, h, -1))
|
world.addObjectAtPos 'KikiWall', world.decenter -s.x/2+1, h, -1
|
||||||
|
|
||||||
# switches
|
# switches
|
||||||
|
|
||||||
world.switch_counter = 0
|
world.switch_counter = 0
|
||||||
|
|
||||||
switched = (swtch) ->
|
switched = (swtch) ->
|
||||||
world.switch_counter += swtch.isActive() and 1 or -1
|
world.switch_counter += swtch.active and 1 or -1
|
||||||
exit = kikiObjectToGate(world.getObjectWithName("exit"))
|
exit = world.getObjectWithName "exit"
|
||||||
exit.setActive(world.switch_counter == 4)
|
exit.setActive world.switch_counter == 4
|
||||||
|
|
||||||
switch1 = KikiSwitch()
|
Switch = require '../switch'
|
||||||
switch1.getEventWithName("switched").addAction(continuous((s=switch1) -> switched(s)))
|
switch1 = new Switch()
|
||||||
switch2 = KikiSwitch()
|
switch1.getEventWithName("switched").addAction(world.continuous((s=switch1) -> switched(s)))
|
||||||
switch2.getEventWithName("switched").addAction(continuous((s=switch2) -> switched(s)))
|
switch2 = new Switch()
|
||||||
switch3 = KikiSwitch()
|
switch2.getEventWithName("switched").addAction(world.continuous((s=switch2) -> switched(s)))
|
||||||
switch3.getEventWithName("switched").addAction(continuous((s=switch3) -> switched(s)))
|
switch3 = new Switch()
|
||||||
switch4 = KikiSwitch()
|
switch3.getEventWithName("switched").addAction(world.continuous((s=switch3) -> switched(s)))
|
||||||
switch4.getEventWithName("switched").addAction(continuous((s=switch4) -> switched(s)))
|
switch4 = new Switch()
|
||||||
|
switch4.getEventWithName("switched").addAction(world.continuous((s=switch4) -> switched(s)))
|
||||||
|
|
||||||
world.addObjectAtPos(switch1, world.decenter(-s.x/2+1, 0, 0))
|
world.addObjectAtPos switch1, world.decenter -s.x/2+1, 0, 0
|
||||||
world.addObjectAtPos(switch2, world.decenter( s.x/2, 0, 0))
|
world.addObjectAtPos switch2, world.decenter s.x/2, 0, 0
|
||||||
world.addObjectAtPos(switch3, world.decenter(0, 0, -s.z/2+1))
|
world.addObjectAtPos switch3, world.decenter 0, 0, -s.z/2+1
|
||||||
world.addObjectAtPos(switch4, world.decenter(0, 0, s.z/2))
|
world.addObjectAtPos switch4, world.decenter 0, 0, s.z/2
|
||||||
|
|
|
@ -8,14 +8,15 @@ Item = require './item'
|
||||||
|
|
||||||
class Light extends Item
|
class Light extends Item
|
||||||
|
|
||||||
constructor: (pos, radius) ->
|
constructor: (opt) ->
|
||||||
@radius = radius ? 4
|
@radius = opt?.radius ? 4
|
||||||
@intensity = 1
|
@shadow = opt?.shadow ? false
|
||||||
|
@intensity = opt?.intensity ? 0.5
|
||||||
# @ambient_color = colors[KikiLight_base_color]
|
# @ambient_color = colors[KikiLight_base_color]
|
||||||
# @diffuse_color = colors[KikiLight_diffuse_color]
|
# @diffuse_color = colors[KikiLight_diffuse_color]
|
||||||
# @specular_color = colors[KikiLight_specular_color]
|
# @specular_color = colors[KikiLight_specular_color]
|
||||||
@point = new THREE.PointLight 0xffffff, @intensity, @radius, 2
|
@point = new THREE.PointLight 0xffffff, @intensity, @radius, 2
|
||||||
@point.castShadow = true
|
@point.castShadow = @shadow
|
||||||
@point.shadow.darkness = 0.5
|
@point.shadow.darkness = 0.5
|
||||||
@point.shadow.mapSize = new THREE.Vector2 2048, 2048
|
@point.shadow.mapSize = new THREE.Vector2 2048, 2048
|
||||||
@point.shadow.bias = 0.01
|
@point.shadow.bias = 0.01
|
||||||
|
@ -32,7 +33,7 @@ class Light extends Item
|
||||||
@mesh = new THREE.Mesh geom, mat
|
@mesh = new THREE.Mesh geom, mat
|
||||||
world.scene.add @point
|
world.scene.add @point
|
||||||
world.addLight @
|
world.addLight @
|
||||||
@setPosition pos if pos?
|
@setPosition opt.pos if opt?.pos?
|
||||||
super
|
super
|
||||||
|
|
||||||
del: ->
|
del: ->
|
||||||
|
|
|
@ -10,15 +10,16 @@ class Stone extends Pushable
|
||||||
|
|
||||||
constructor: (@slippery=false) ->
|
constructor: (@slippery=false) ->
|
||||||
|
|
||||||
@geom = new THREE.BoxGeometry 0.99,0.99,0.99
|
@geom = new THREE.BoxGeometry 0.98,0.98,0.98
|
||||||
|
# @geom.translate 0.01, 0.01, 0.01
|
||||||
|
|
||||||
@mat = new THREE.MeshPhongMaterial
|
@mat = new THREE.MeshPhongMaterial
|
||||||
color: 0xff8800
|
color: 0xff8800
|
||||||
side: THREE.FrontSide
|
side: THREE.DoubleSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.FlatShading
|
||||||
transparent: true
|
transparent: true
|
||||||
opacity: 0.58
|
opacity: 0.8
|
||||||
shininess: 0.9
|
shininess: 15
|
||||||
|
|
||||||
@mesh = new THREE.Mesh @geom, @mat
|
@mesh = new THREE.Mesh @geom, @mat
|
||||||
super
|
super
|
||||||
|
|
|
@ -62,10 +62,16 @@ class Switch extends Item
|
||||||
bulletImpact: -> @setActive not @active
|
bulletImpact: -> @setActive not @active
|
||||||
|
|
||||||
lightDeleted: () -> @light = null
|
lightDeleted: () -> @light = null
|
||||||
|
createLight: ->
|
||||||
|
@light = new Light
|
||||||
|
pos: @position
|
||||||
|
radius: 6.0
|
||||||
|
|
||||||
|
toggle: -> @setActive not @active
|
||||||
|
|
||||||
setActive: (status) ->
|
setActive: (status) ->
|
||||||
log "switch #{@name} active:#{status}"
|
|
||||||
if @active != status
|
if @active != status
|
||||||
|
log "switch #{@name} active:#{status}"
|
||||||
@active = status
|
@active = status
|
||||||
|
|
||||||
if @active
|
if @active
|
||||||
|
@ -73,7 +79,7 @@ class Switch extends Item
|
||||||
@startTimedAction @getActionWithId Action.ROTATE
|
@startTimedAction @getActionWithId Action.ROTATE
|
||||||
world.playSound @sound_on
|
world.playSound @sound_on
|
||||||
@events[@SWITCH_ON_EVENT].triggerActions()
|
@events[@SWITCH_ON_EVENT].triggerActions()
|
||||||
@light = new Light @position, 10.0
|
@createLight()
|
||||||
@light.on 'deleted', @lightDeleted
|
@light.on 'deleted', @lightDeleted
|
||||||
else
|
else
|
||||||
@stopAction @getActionWithId Action.ROTATE
|
@stopAction @getActionWithId Action.ROTATE
|
||||||
|
@ -84,7 +90,7 @@ class Switch extends Item
|
||||||
if @light
|
if @light
|
||||||
@light.del()
|
@light.del()
|
||||||
@light = null
|
@light = null
|
||||||
|
log 'trigger SWITCHED_EVENT'
|
||||||
@events[@SWITCHED_EVENT].triggerActions()
|
@events[@SWITCHED_EVENT].triggerActions()
|
||||||
|
|
||||||
setPosition: (pos) ->
|
setPosition: (pos) ->
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
# 000 000 000 000 000 000
|
# 000 000 000 000 000 000
|
||||||
# 00 00 000 000 0000000 0000000
|
# 00 00 000 000 0000000 0000000
|
||||||
|
|
||||||
|
Pos = require './lib/pos'
|
||||||
Item = require './item'
|
Item = require './item'
|
||||||
|
Cage = require './cage'
|
||||||
|
|
||||||
class Wall extends Item
|
class Wall extends Item
|
||||||
|
|
||||||
|
@ -13,32 +15,20 @@ class Wall extends Item
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
|
||||||
@geom = new THREE.BoxGeometry 1,1,1
|
geom = Cage.wallTiles new Pos(1,1,1), 'outside', 0
|
||||||
@mat = new THREE.MeshPhongMaterial
|
geom.translate -0.5, -0.5, -0.5
|
||||||
color: 0x0000ff
|
@raster = new THREE.Mesh geom, Cage.rasterMat
|
||||||
side: THREE.FrontSide
|
@raster.receiveShadow = true
|
||||||
shading: THREE.SmoothShading
|
|
||||||
transparent: true
|
geom = Cage.wallTiles new Pos(1,1,1), 'outside', Cage.gap
|
||||||
opacity: 0.85
|
geom.translate -0.5, -0.5, -0.5
|
||||||
shininess: 5
|
@plates = new THREE.Mesh geom, Cage.cageMat
|
||||||
@mesh = new THREE.Mesh @geom, @mat
|
@plates.receiveShadow = true
|
||||||
@mesh.castShadow = true
|
|
||||||
@mesh.receiveShadow = true
|
@mesh = new THREE.Object3D
|
||||||
|
@mesh.add @raster
|
||||||
|
@mesh.add @plates
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
# s = 0.45
|
|
||||||
# d = 0.5
|
|
||||||
|
|
||||||
# glDisable(GL_LIGHTING);
|
|
||||||
# colors[KikiWall_base_color].glColor();
|
|
||||||
# glDepthMask(false);
|
|
||||||
# kDisplaySolidCube(1.0);
|
|
||||||
# glDepthMask(true);
|
|
||||||
|
|
||||||
# colors[KikiWall_plate_color].glColor();
|
|
||||||
# glEnable(GL_LIGHTING);
|
|
||||||
# glBegin(GL_QUADS);
|
|
||||||
#
|
|
||||||
# glEnd();
|
|
||||||
|
|
||||||
module.exports = Wall
|
module.exports = Wall
|
|
@ -76,9 +76,9 @@ class World extends Actor
|
||||||
# 000 000 000 000 0 000 000 000 000 000 000
|
# 000 000 000 000 0 000 000 000 000 000 000
|
||||||
# 0000000 000 000 000 000 00000000 000 000 000 000
|
# 0000000 000 000 000 000 00000000 000 000 000 000
|
||||||
|
|
||||||
@fov = 70
|
@fov = 90
|
||||||
@near = 0.001
|
@near = 0.1
|
||||||
@far = 500
|
@far = 20
|
||||||
@aspect = @view.offsetWidth / @view.offsetHeight
|
@aspect = @view.offsetWidth / @view.offsetHeight
|
||||||
@dist = 10
|
@dist = 10
|
||||||
|
|
||||||
|
@ -279,11 +279,13 @@ class World extends Actor
|
||||||
|
|
||||||
addLight: (light) ->
|
addLight: (light) ->
|
||||||
@lights.push light
|
@lights.push light
|
||||||
@enableShadows true
|
@enableShadows true if light.shadow
|
||||||
|
|
||||||
removeLight: (light) ->
|
removeLight: (light) ->
|
||||||
_.pull @lights, light
|
_.pull @lights, light
|
||||||
@enableShadows false if not @lights.length
|
for l in @lights
|
||||||
|
shadow = true if l.shadow
|
||||||
|
@enableShadows shadow
|
||||||
|
|
||||||
enableShadows: (enable) ->
|
enableShadows: (enable) ->
|
||||||
@renderer.shadowMap.enabled = enable
|
@renderer.shadowMap.enabled = enable
|
||||||
|
@ -298,8 +300,8 @@ class World extends Actor
|
||||||
log "world.exitLevel", action
|
log "world.exitLevel", action
|
||||||
@finish()
|
@finish()
|
||||||
# @player.status.setMoves 0
|
# @player.status.setMoves 0
|
||||||
exitIndex = parseInt action.name.slice 5
|
# exitIndex = parseInt action.name?.slice 5
|
||||||
log "world.exitLevel exitIndex:#{exitIndex}"
|
# log "world.exitLevel exitIndex:#{exitIndex}"
|
||||||
# if @dict.exits[exitIndex]?.world?
|
# if @dict.exits[exitIndex]?.world?
|
||||||
# w = @dict.exits[exitIndex].world
|
# w = @dict.exits[exitIndex].world
|
||||||
# w() if _.isFunction w
|
# w() if _.isFunction w
|
||||||
|
@ -320,158 +322,6 @@ class World extends Actor
|
||||||
|
|
||||||
isInvalidPos: (pos) -> not @isValidPos pos
|
isInvalidPos: (pos) -> not @isValidPos pos
|
||||||
|
|
||||||
# 0000000 0000000 000 00000000 0000000 000000000 000 000 000 000 00000000
|
|
||||||
# 000 000 000 000 000 000 000 000 000 000 0000 000 000
|
|
||||||
# 000 000 0000000 000 0000000 000 000 000 000 000 0 000 0000000
|
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
|
||||||
# 0000000 0000000 0000000 00000000 0000000 000 0000000 000 000 000 00000000
|
|
||||||
|
|
||||||
addObjectLine: (object, sx,sy,sz, ex,ey,ez) ->
|
|
||||||
if sx instanceof Pos
|
|
||||||
start = sx
|
|
||||||
end = sy
|
|
||||||
else
|
|
||||||
start = new Pos sx,sy,sz
|
|
||||||
end = new Pos ex,ey,ez
|
|
||||||
# adds a line of objects of type to the world. start and end should be 3-tuples or Pos objects
|
|
||||||
if start instanceof Pos
|
|
||||||
start = [start.x, start.y, start.z]
|
|
||||||
[sx, sy, sz] = start
|
|
||||||
if end instanceof Pos
|
|
||||||
end = [end.x, end.y, end.z]
|
|
||||||
[ex, ey, ez] = end
|
|
||||||
|
|
||||||
diff = [ex-sx, ey-sy, ez-sz]
|
|
||||||
maxdiff = _.max diff.map Math.abs
|
|
||||||
deltas = diff.map (a) -> a/maxdiff
|
|
||||||
for i in [0...maxdiff]
|
|
||||||
# pos = apply(Pos, (map (lambda a, b: int(a+i*b), start, deltas)))
|
|
||||||
pos = new Pos (start[j]+i*deltas[j] for j in [0..2])
|
|
||||||
if @isUnoccupiedPos pos
|
|
||||||
if type(object) == types.StringType
|
|
||||||
@addObjectAtPos eval(object), pos
|
|
||||||
else
|
|
||||||
@addObjectAtPos object(), pos
|
|
||||||
|
|
||||||
addObjectPoly: (object, points, close=1) ->
|
|
||||||
# adds a polygon of objects of type to the world. points should be 3-tuples or Pos objects
|
|
||||||
if close
|
|
||||||
points.append (points[0])
|
|
||||||
for index in range(1, len(points))
|
|
||||||
@addObjectLine object, points[index-1], points[index]
|
|
||||||
|
|
||||||
addObjectRandom: (object, number) ->
|
|
||||||
# adds number objects of type at random positions to the world
|
|
||||||
for i in [0...number]
|
|
||||||
if type (object) == types.StringType
|
|
||||||
@setObjectRandom eval object
|
|
||||||
else
|
|
||||||
@setObjectRandom object()
|
|
||||||
|
|
||||||
setObjectRandom: (object) ->
|
|
||||||
# adds number objects of type at random positions to the world
|
|
||||||
object_set = 0
|
|
||||||
while not object_set # hack alert!
|
|
||||||
random_pos = Pos random.randrange(@size.x),
|
|
||||||
random.randrange(@size.y),
|
|
||||||
random.randrange(@size.z)
|
|
||||||
if not object.isSpaceEgoistic() or @isUnoccupiedPos(random_pos)
|
|
||||||
@addObjectAtPos object, random_pos
|
|
||||||
object_set = 1
|
|
||||||
|
|
||||||
# 000 000 00000000 000 00000000
|
|
||||||
# 000 000 000 000 000 000
|
|
||||||
# 000000000 0000000 000 00000000
|
|
||||||
# 000 000 000 000 000
|
|
||||||
# 000 000 00000000 0000000 000
|
|
||||||
|
|
||||||
help: (index=0) ->
|
|
||||||
# displays help messages
|
|
||||||
|
|
||||||
# text_list = @dict["help"]
|
|
||||||
# more_text = index < len (text_list) - 1
|
|
||||||
# less_text = index > 0
|
|
||||||
#
|
|
||||||
# list = text_list[index].split("$key(")
|
|
||||||
# for i in range (1, len(list))
|
|
||||||
# close = list[i].find(")")
|
|
||||||
# list[i] = Controller.player.getKeyForAction (list[i][:close]) + list[i][close+1:]
|
|
||||||
#
|
|
||||||
# list.append ("\n\n$scale(0.5)(%d/%d)" % (index+1, len (text_list)))
|
|
||||||
# help_text = KikiPageText ("".join(list), more_text, less_text)
|
|
||||||
#
|
|
||||||
# if more_text:
|
|
||||||
# help_text.getEventWithName ("next").addAction (once (lambda i=index+1: @help (i)))
|
|
||||||
# if less_text:
|
|
||||||
# help_text.getEventWithName ("previous").addAction (once (lambda i=index-1: @help (i)))
|
|
||||||
|
|
||||||
outro: (index=0) ->
|
|
||||||
# well hidden outro :-)
|
|
||||||
outro_text = """
|
|
||||||
$scale(1.5)congratulations!\n\n$scale(1)you rescued\nthe nano world!
|
|
||||||
|
|
||||||
the last dumb mutant bot\nhas been destroyed.\n\nthe maker is functioning again.
|
|
||||||
kiki will go now\nand see all his new friends.\n\nyou should maybe\ndo the same?
|
|
||||||
the maker wants to thank you!\n\n(btw.: you thought\nyou didn't see\nkiki's maker in the game?
|
|
||||||
you are wrong!\nyou saw him\nall the time,\nbecause kiki\nlives inside him!)\n\n$scale(1.5)the end
|
|
||||||
p.s.: the maker of the game\nwants to thank you as well!\n\ni definitely want your feedback:
|
|
||||||
please send me a mail (monsterkodi@users.sf.net)\nwith your experiences,
|
|
||||||
which levels you liked, etc.\n\nthanks in advance and have a nice day,\n\nyours kodi
|
|
||||||
"""
|
|
||||||
|
|
||||||
more_text = index < outro_text.length-1
|
|
||||||
less_text = index > 0
|
|
||||||
|
|
||||||
page_text = outro_text[index]
|
|
||||||
page_text += "\n\n$scale(0.5)(#{index+1}/#{outro_text.length})"
|
|
||||||
|
|
||||||
page = KikiPageText(page_text, more_text, less_text)
|
|
||||||
page.getEventWithName("hide").addAction(once(display_main_menu))
|
|
||||||
|
|
||||||
if more_text
|
|
||||||
page.getEventWithName("next").addAction (i=index+1) => @outro i
|
|
||||||
if less_text
|
|
||||||
page.getEventWithName("previous").addAction (i=index-1) => @outro i
|
|
||||||
|
|
||||||
resetProjection: -> world.getProjection().setViewport 0.0, 0.0, 1.0, 1.0
|
|
||||||
|
|
||||||
toggle: (objectName) ->
|
|
||||||
# toggles object with name objectName
|
|
||||||
@startTimedAction(@getObjectWithName(objectName).getActionWithName("toggle"))
|
|
||||||
|
|
||||||
# 00000000 0000000 0000000
|
|
||||||
# 000 000 000
|
|
||||||
# 0000000 0000000 000
|
|
||||||
# 000 000 000
|
|
||||||
# 00000000 0000000 0000000
|
|
||||||
|
|
||||||
escape: (self) -> # handles an ESC key event
|
|
||||||
|
|
||||||
@resetProjection()
|
|
||||||
|
|
||||||
if "escape" in @dict
|
|
||||||
if _.isFunction @dict["escape"]
|
|
||||||
@dict["escape"]()
|
|
||||||
else
|
|
||||||
exec @dict["escape"] in globals()
|
|
||||||
return
|
|
||||||
|
|
||||||
menu = new Menu()
|
|
||||||
menu.getEventWithName("hide").addAction once @resetProjection
|
|
||||||
|
|
||||||
# if Controller.isDebugVersion()
|
|
||||||
# menu.addItem (Controller.getLocalizedString("next level"), once(lambda w=self: w.performAction("exit 0",0)))
|
|
||||||
# if "help" in @dict
|
|
||||||
# menu.addItem (Controller.getLocalizedString("help"), once(@help))
|
|
||||||
menu.addItem(Controller.getLocalizedString("restart"), once(@restart))
|
|
||||||
|
|
||||||
esc_menu_action = once @escape
|
|
||||||
log "level_index #{world.level_index}"
|
|
||||||
menu.addItem(Controller.getLocalizedString("load level"), (i=world.level_index,a=esc_menu_action) -> levelSelection(i, a))
|
|
||||||
menu.addItem(Controller.getLocalizedString("setup"), once @quickSetup)
|
|
||||||
menu.addItem(Controller.getLocalizedString("about"), once @display_about)
|
|
||||||
menu.addItem(Controller.getLocalizedString("quit"), once world.quit)
|
|
||||||
|
|
||||||
# 0000000 00000000 000 000 0000000
|
# 0000000 00000000 000 000 0000000
|
||||||
# 000 000 000 000 000
|
# 000 000 000 000 000
|
||||||
# 000 0000000 000 000 0000000
|
# 000 0000000 000 000 0000000
|
||||||
|
@ -499,6 +349,73 @@ class World extends Actor
|
||||||
lrest = index % lsize
|
lrest = index % lsize
|
||||||
new Pos index/lsize, lrest/@size.z, lrest%@size.z
|
new Pos index/lsize, lrest/@size.z, lrest%@size.z
|
||||||
|
|
||||||
|
# 0000000 0000000 0000000 0000000 0000000 000 00000000 0000000 000000000
|
||||||
|
# 000 000 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
|
# 000000000 000 000 000 000 000 000 0000000 000 0000000 000 000
|
||||||
|
# 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
|
# 000 000 0000000 0000000 0000000 0000000 0000000 00000000 0000000 000
|
||||||
|
|
||||||
|
addObjectAtPos: (object, x, y, z) ->
|
||||||
|
pos = new Pos x, y, z
|
||||||
|
object = @newObject object
|
||||||
|
@setObjectAtPos object, pos
|
||||||
|
# log "addObjectAtPos #{object.name}", pos
|
||||||
|
@addObject object
|
||||||
|
|
||||||
|
addObjectLine: (object, sx,sy,sz, ex,ey,ez) ->
|
||||||
|
if sx instanceof Pos
|
||||||
|
start = sx
|
||||||
|
end = sy
|
||||||
|
else
|
||||||
|
start = new Pos sx,sy,sz
|
||||||
|
end = new Pos ex,ey,ez
|
||||||
|
# adds a line of objects of type to the world. start and end should be 3-tuples or Pos objects
|
||||||
|
if start instanceof Pos
|
||||||
|
start = [start.x, start.y, start.z]
|
||||||
|
[sx, sy, sz] = start
|
||||||
|
if end instanceof Pos
|
||||||
|
end = [end.x, end.y, end.z]
|
||||||
|
[ex, ey, ez] = end
|
||||||
|
|
||||||
|
diff = [ex-sx, ey-sy, ez-sz]
|
||||||
|
maxdiff = _.max diff.map Math.abs
|
||||||
|
deltas = diff.map (a) -> a/maxdiff
|
||||||
|
for i in [0...maxdiff]
|
||||||
|
# pos = apply(Pos, (map (lambda a, b: int(a+i*b), start, deltas)))
|
||||||
|
pos = new Pos (start[j]+i*deltas[j] for j in [0..2])
|
||||||
|
if @isUnoccupiedPos pos
|
||||||
|
@addObjectAtPos object, pos
|
||||||
|
# if _.isString object
|
||||||
|
# @addObjectAtPos eval(object), pos
|
||||||
|
# else
|
||||||
|
# @addObjectAtPos object(), pos
|
||||||
|
|
||||||
|
addObjectPoly: (object, points, close=1) ->
|
||||||
|
# adds a polygon of objects of type to the world. points should be 3-tuples or Pos objects
|
||||||
|
if close
|
||||||
|
points.append (points[0])
|
||||||
|
for index in range(1, len(points))
|
||||||
|
@addObjectLine object, points[index-1], points[index]
|
||||||
|
|
||||||
|
addObjectRandom: (object, number) ->
|
||||||
|
# adds number objects of type at random positions to the world
|
||||||
|
for i in [0...number]
|
||||||
|
if type (object) == types.StringType
|
||||||
|
@setObjectRandom eval object
|
||||||
|
else
|
||||||
|
@setObjectRandom object()
|
||||||
|
|
||||||
|
setObjectRandom: (object) ->
|
||||||
|
# adds number objects of type at random positions to the world
|
||||||
|
object_set = 0
|
||||||
|
while not object_set # hack alert!
|
||||||
|
random_pos = Pos random.randrange(@size.x),
|
||||||
|
random.randrange(@size.y),
|
||||||
|
random.randrange(@size.z)
|
||||||
|
if not object.isSpaceEgoistic() or @isUnoccupiedPos(random_pos)
|
||||||
|
@addObjectAtPos object, random_pos
|
||||||
|
object_set = 1
|
||||||
|
|
||||||
# 0000000 0000000 000 00000000 0000000 000000000 0000000
|
# 0000000 0000000 000 00000000 0000000 000000000 0000000
|
||||||
# 000 000 000 000 000 000 000 000 000
|
# 000 000 000 000 000 000 000 000 000
|
||||||
# 000 000 0000000 000 0000000 000 000 0000000
|
# 000 000 0000000 000 0000000 000 000 0000000
|
||||||
|
@ -565,13 +482,6 @@ class World extends Actor
|
||||||
else
|
else
|
||||||
@objects.push object # if objects.indexOf(object) < 0
|
@objects.push object # if objects.indexOf(object) < 0
|
||||||
|
|
||||||
addObjectAtPos: (object, x, y, z) ->
|
|
||||||
pos = new Pos x, y, z
|
|
||||||
object = @newObject object
|
|
||||||
@setObjectAtPos object, pos
|
|
||||||
# log "addObjectAtPos #{object.name}", pos
|
|
||||||
@addObject object
|
|
||||||
|
|
||||||
removeObject: (object) ->
|
removeObject: (object) ->
|
||||||
@unsetObject object
|
@unsetObject object
|
||||||
_.pull @lights, object
|
_.pull @lights, object
|
||||||
|
@ -585,6 +495,13 @@ class World extends Actor
|
||||||
world.playSound 'BOT_LAND'
|
world.playSound 'BOT_LAND'
|
||||||
true
|
true
|
||||||
|
|
||||||
|
toggle: (objectName) ->
|
||||||
|
# toggles object with name objectName
|
||||||
|
object = @getObjectWithName objectName
|
||||||
|
log "world.toggle #{objectName} #{object?}"
|
||||||
|
# @startTimedAction object.getActionWithName "toggle"
|
||||||
|
object.getActionWithName("toggle").perform()
|
||||||
|
|
||||||
# 0000000 00000000 000 00000000 000000000 00000000
|
# 0000000 00000000 000 00000000 000000000 00000000
|
||||||
# 000 000 000 000 000 000 000
|
# 000 000 000 000 000 000 000
|
||||||
# 000 000 0000000 000 0000000 000 0000000
|
# 000 000 0000000 000 0000000 000 0000000
|
||||||
|
@ -628,7 +545,7 @@ class World extends Actor
|
||||||
|
|
||||||
getObjectWithName: (objectName) ->
|
getObjectWithName: (objectName) ->
|
||||||
for o in @objects
|
for o in @objects
|
||||||
if objectName == o.getName()
|
if objectName == o.name
|
||||||
return o
|
return o
|
||||||
log "World.getObjectWithName :: no object found with name #{objectName}"
|
log "World.getObjectWithName :: no object found with name #{objectName}"
|
||||||
null
|
null
|
||||||
|
@ -650,11 +567,11 @@ class World extends Actor
|
||||||
# log "world.objectWillMoveToPos #{object.name} #{duration}", pos
|
# log "world.objectWillMoveToPos #{object.name} #{duration}", pos
|
||||||
|
|
||||||
if @isInvalidPos pos
|
if @isInvalidPos pos
|
||||||
log "world.objectWillMoveToPos [WARNING] invalid pos:", pos
|
log "world.objectWillMoveToPos [WARNING] #{object.name} invalid pos:", pos
|
||||||
return
|
return
|
||||||
|
|
||||||
if object.getPos().eql pos
|
if object.getPos().eql pos
|
||||||
log "world.objectWillMoveToPos [WARNING] equal pos:", pos
|
log "world.objectWillMoveToPos [WARNING] #{object.name} equal pos:", pos
|
||||||
return
|
return
|
||||||
|
|
||||||
if cell = @getCellAtPos pos
|
if cell = @getCellAtPos pos
|
||||||
|
@ -664,9 +581,9 @@ class World extends Actor
|
||||||
# temporary object at new pos will vanish before object will arrive . delete it
|
# temporary object at new pos will vanish before object will arrive . delete it
|
||||||
objectAtNewPos.del()
|
objectAtNewPos.del()
|
||||||
else
|
else
|
||||||
log "world.objectWillMoveToPos [WARNING] timing conflict at pos:", pos
|
log "world.objectWillMoveToPos [WARNING] #{object.name} timing conflict at pos:", pos
|
||||||
else
|
else
|
||||||
log "world.objectWillMoveToPos [WARNING] already occupied:", pos
|
log "world.objectWillMoveToPos [WARNING] #{object.name} already occupied:", pos
|
||||||
|
|
||||||
if object.name != 'player'
|
if object.name != 'player'
|
||||||
log "---------- tmpObjects not player? #{object.name}"
|
log "---------- tmpObjects not player? #{object.name}"
|
||||||
|
@ -695,7 +612,7 @@ class World extends Actor
|
||||||
# tmpObject.del()
|
# tmpObject.del()
|
||||||
|
|
||||||
if @isInvalidPos targetPos
|
if @isInvalidPos targetPos
|
||||||
log "World.objectMoved invalid targetPos:", targetPos
|
log "World.objectMoved [WARNING] #{movedObject.name} invalid targetPos:", targetPos
|
||||||
return
|
return
|
||||||
|
|
||||||
# if tmpObject = @getObjectOfTypeAtPos TmpObject, pos
|
# if tmpObject = @getObjectOfTypeAtPos TmpObject, pos
|
||||||
|
@ -706,7 +623,7 @@ class World extends Actor
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if @isOccupiedPos targetPos
|
if @isOccupiedPos targetPos
|
||||||
log "World.objectMoved object moved to occupied pos:", targetPos
|
log "World.objectMoved [WARNING] #{movedObject.name} moved to occupied pos:", targetPos
|
||||||
|
|
||||||
# log 'World.objectMovedFromPos sourcePos:', sourcePos
|
# log 'World.objectMovedFromPos sourcePos:', sourcePos
|
||||||
# log 'World.objectMovedFromPos targetPos:', targetPos
|
# log 'World.objectMovedFromPos targetPos:', targetPos
|
||||||
|
@ -729,7 +646,7 @@ class World extends Actor
|
||||||
if targetCell?
|
if targetCell?
|
||||||
targetCell.addObject movedObject
|
targetCell.addObject movedObject
|
||||||
else
|
else
|
||||||
log 'world.objectMoved [WARNING] no target cell?'
|
log "world.objectMoved [WARNING] #{movedObject.name} no target cell?"
|
||||||
|
|
||||||
setObjectColor: (color_name, color) ->
|
setObjectColor: (color_name, color) ->
|
||||||
if color_name == 'base'
|
if color_name == 'base'
|
||||||
|
@ -818,7 +735,7 @@ class World extends Actor
|
||||||
return true
|
return true
|
||||||
|
|
||||||
mayObjectPushToPos: (object, pos, duration) ->
|
mayObjectPushToPos: (object, pos, duration) ->
|
||||||
log "world.mayObjectPushToPos object:#{object.name} duration:#{duration}", pos
|
# log "world.mayObjectPushToPos object:#{object.name} duration:#{duration}", pos
|
||||||
# returns true, if a pushable object is at pos and may be pushed
|
# returns true, if a pushable object is at pos and may be pushed
|
||||||
return false if @isInvalidPos pos
|
return false if @isInvalidPos pos
|
||||||
|
|
||||||
|
@ -838,10 +755,9 @@ class World extends Actor
|
||||||
else return false
|
else return false
|
||||||
|
|
||||||
pushableObject = @getOccupantAtPos pos
|
pushableObject = @getOccupantAtPos pos
|
||||||
log "pushableObject #{pushableObject?.name}"
|
# log "pushableObject #{pushableObject?.name}"
|
||||||
if pushableObject? and pushableObject instanceof Pushable #and
|
if pushableObject? and pushableObject instanceof Pushable #and
|
||||||
# pushableObject instanceof MotorGear # bad
|
# pushableObject instanceof MotorGear # bad
|
||||||
log 'pushedByObjectInDirection'
|
|
||||||
pushableObject.pushedByObjectInDirection object, direction, duration
|
pushableObject.pushedByObjectInDirection object, direction, duration
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -855,6 +771,95 @@ class World extends Actor
|
||||||
# Spikes::initialize()
|
# Spikes::initialize()
|
||||||
# Text::reinit()
|
# Text::reinit()
|
||||||
|
|
||||||
|
# 000 000 00000000 000 00000000
|
||||||
|
# 000 000 000 000 000 000
|
||||||
|
# 000000000 0000000 000 00000000
|
||||||
|
# 000 000 000 000 000
|
||||||
|
# 000 000 00000000 0000000 000
|
||||||
|
|
||||||
|
help: (index=0) ->
|
||||||
|
# displays help messages
|
||||||
|
|
||||||
|
# text_list = @dict["help"]
|
||||||
|
# more_text = index < len (text_list) - 1
|
||||||
|
# less_text = index > 0
|
||||||
|
#
|
||||||
|
# list = text_list[index].split("$key(")
|
||||||
|
# for i in range (1, len(list))
|
||||||
|
# close = list[i].find(")")
|
||||||
|
# list[i] = Controller.player.getKeyForAction (list[i][:close]) + list[i][close+1:]
|
||||||
|
#
|
||||||
|
# list.append ("\n\n$scale(0.5)(%d/%d)" % (index+1, len (text_list)))
|
||||||
|
# help_text = KikiPageText ("".join(list), more_text, less_text)
|
||||||
|
#
|
||||||
|
# if more_text:
|
||||||
|
# help_text.getEventWithName ("next").addAction (once (lambda i=index+1: @help (i)))
|
||||||
|
# if less_text:
|
||||||
|
# help_text.getEventWithName ("previous").addAction (once (lambda i=index-1: @help (i)))
|
||||||
|
|
||||||
|
outro: (index=0) ->
|
||||||
|
# well hidden outro :-)
|
||||||
|
outro_text = """
|
||||||
|
$scale(1.5)congratulations!\n\n$scale(1)you rescued\nthe nano world!
|
||||||
|
|
||||||
|
the last dumb mutant bot\nhas been destroyed.\n\nthe maker is functioning again.
|
||||||
|
kiki will go now\nand see all his new friends.\n\nyou should maybe\ndo the same?
|
||||||
|
the maker wants to thank you!\n\n(btw.: you thought\nyou didn't see\nkiki's maker in the game?
|
||||||
|
you are wrong!\nyou saw him\nall the time,\nbecause kiki\nlives inside him!)\n\n$scale(1.5)the end
|
||||||
|
p.s.: the maker of the game\nwants to thank you as well!\n\ni definitely want your feedback:
|
||||||
|
please send me a mail (monsterkodi@users.sf.net)\nwith your experiences,
|
||||||
|
which levels you liked, etc.\n\nthanks in advance and have a nice day,\n\nyours kodi
|
||||||
|
"""
|
||||||
|
|
||||||
|
more_text = index < outro_text.length-1
|
||||||
|
less_text = index > 0
|
||||||
|
|
||||||
|
page_text = outro_text[index]
|
||||||
|
page_text += "\n\n$scale(0.5)(#{index+1}/#{outro_text.length})"
|
||||||
|
|
||||||
|
page = KikiPageText(page_text, more_text, less_text)
|
||||||
|
page.getEventWithName("hide").addAction(once(display_main_menu))
|
||||||
|
|
||||||
|
if more_text
|
||||||
|
page.getEventWithName("next").addAction (i=index+1) => @outro i
|
||||||
|
if less_text
|
||||||
|
page.getEventWithName("previous").addAction (i=index-1) => @outro i
|
||||||
|
|
||||||
|
resetProjection: -> world.getProjection().setViewport 0.0, 0.0, 1.0, 1.0
|
||||||
|
|
||||||
|
# 00000000 0000000 0000000
|
||||||
|
# 000 000 000
|
||||||
|
# 0000000 0000000 000
|
||||||
|
# 000 000 000
|
||||||
|
# 00000000 0000000 0000000
|
||||||
|
|
||||||
|
escape: (self) -> # handles an ESC key event
|
||||||
|
|
||||||
|
@resetProjection()
|
||||||
|
|
||||||
|
if "escape" in @dict
|
||||||
|
if _.isFunction @dict["escape"]
|
||||||
|
@dict["escape"]()
|
||||||
|
else
|
||||||
|
exec @dict["escape"] in globals()
|
||||||
|
return
|
||||||
|
|
||||||
|
menu = new Menu()
|
||||||
|
menu.getEventWithName("hide").addAction once @resetProjection
|
||||||
|
|
||||||
|
# if Controller.isDebugVersion()
|
||||||
|
# menu.addItem (Controller.getLocalizedString("next level"), once(lambda w=self: w.performAction("exit 0",0)))
|
||||||
|
# if "help" in @dict
|
||||||
|
# menu.addItem (Controller.getLocalizedString("help"), once(@help))
|
||||||
|
menu.addItem(Controller.getLocalizedString("restart"), once(@restart))
|
||||||
|
|
||||||
|
esc_menu_action = once @escape
|
||||||
|
log "level_index #{world.level_index}"
|
||||||
|
menu.addItem(Controller.getLocalizedString("load level"), (i=world.level_index,a=esc_menu_action) -> levelSelection(i, a))
|
||||||
|
menu.addItem(Controller.getLocalizedString("setup"), once @quickSetup)
|
||||||
|
menu.addItem(Controller.getLocalizedString("about"), once @display_about)
|
||||||
|
menu.addItem(Controller.getLocalizedString("quit"), once world.quit)
|
||||||
|
|
||||||
# 000 000 0000000 000 000
|
# 000 000 0000000 000 000
|
||||||
# 000 0 000 000 000 000 000
|
# 000 0 000 000 000 000 000
|
||||||
# 000000000 000000000 000 000
|
# 000000000 000000000 000 000
|
||||||
|
|
Loading…
Reference in New Issue
Block a user