wire
This commit is contained in:
parent
e20381d55d
commit
aa54788ff1
|
@ -9,19 +9,20 @@ Vector = require './lib/vector'
|
||||||
|
|
||||||
class Face
|
class Face
|
||||||
|
|
||||||
|
@X = 0
|
||||||
|
@Y = 1
|
||||||
|
@Z = 2
|
||||||
|
@NX = 3
|
||||||
|
@NY = 4
|
||||||
|
@NZ = 5
|
||||||
|
|
||||||
@orientationForFace: (face) ->
|
@orientationForFace: (face) ->
|
||||||
switch face % 6
|
switch face % 6
|
||||||
# when 0 then return Quaternion.rot_90_Y
|
|
||||||
# when 1 then return Quaternion.rot_0
|
|
||||||
# when 2 then return Quaternion.rot_270_X
|
|
||||||
# when 3 then return Quaternion.rot_270_Y
|
|
||||||
# when 4 then return Quaternion.rot_90_X
|
|
||||||
# when 5 then return Quaternion.rot_180_X
|
|
||||||
when 0 then return Quaternion.rot_90_Y
|
when 0 then return Quaternion.rot_90_Y
|
||||||
when 1 then return Quaternion.rot_90_X
|
when 1 then return Quaternion.rot_270_X
|
||||||
when 2 then return Quaternion.rot_0
|
when 2 then return Quaternion.rot_0
|
||||||
when 3 then return Quaternion.rot_270_Y
|
when 3 then return Quaternion.rot_270_Y
|
||||||
when 4 then return Quaternion.rot_270_X
|
when 4 then return Quaternion.rot_90_X
|
||||||
when 5 then return Quaternion.rot_180_X
|
when 5 then return Quaternion.rot_180_X
|
||||||
|
|
||||||
@normalVectorForFace: (face) ->
|
@normalVectorForFace: (face) ->
|
||||||
|
@ -32,11 +33,4 @@ class Face
|
||||||
when 2 then return new Vector 0, 0, o
|
when 2 then return new Vector 0, 0, o
|
||||||
new Vector
|
new Vector
|
||||||
|
|
||||||
@X = 0
|
|
||||||
@Y = 1
|
|
||||||
@Z = 2
|
|
||||||
@NX = 3
|
|
||||||
@NY = 4
|
|
||||||
@NZ = 5
|
|
||||||
|
|
||||||
module.exports = Face
|
module.exports = Face
|
||||||
|
|
|
@ -10,6 +10,21 @@ Vector = require './lib/vector'
|
||||||
|
|
||||||
class Geom
|
class Geom
|
||||||
|
|
||||||
|
@wire: ->
|
||||||
|
quads = 16
|
||||||
|
triangles = quads*2+8
|
||||||
|
positions = new Float32Array triangles*9
|
||||||
|
normals = new Float32Array triangles*9
|
||||||
|
pi = -1
|
||||||
|
pi = @quadStrip positions, normals, pi, @wireQuadStrip1
|
||||||
|
pi = @quadStrip positions, normals, pi, @wireQuadStrip2
|
||||||
|
pi = @triangleList positions, normals, pi, @wireTriangles
|
||||||
|
geom = new THREE.BufferGeometry
|
||||||
|
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||||
|
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||||
|
geom.translate 0,0,-0.5+0.008
|
||||||
|
geom
|
||||||
|
|
||||||
@kolben: ->
|
@kolben: ->
|
||||||
quads = 6+8
|
quads = 6+8
|
||||||
triangles = quads*2
|
triangles = quads*2
|
||||||
|
@ -184,6 +199,43 @@ class Geom
|
||||||
normals[pi] = n[i]
|
normals[pi] = n[i]
|
||||||
pi
|
pi
|
||||||
|
|
||||||
|
# 000 000 000 00000000 00000000
|
||||||
|
# 000 0 000 000 000 000 000
|
||||||
|
# 000000000 000 0000000 0000000
|
||||||
|
# 000 000 000 000 000 000
|
||||||
|
# 00 00 000 000 000 00000000
|
||||||
|
|
||||||
|
@wireQuadStrip1 = [
|
||||||
|
0, 0.18, 0, 0, 0.14, 0.05, 0.14, 0.14, 0, 0.1, 0.1, 0.05,
|
||||||
|
0.18, 0, 0, 0.14, 0, 0.05,
|
||||||
|
0.14, -0.14, 0, 0.1, -0.1, 0.05,
|
||||||
|
0, -0.18, 0, 0, -0.14, 0.05,
|
||||||
|
-0.14, -0.14, 0, -0.1, -0.1, 0.05,
|
||||||
|
-0.18, 0, 0, -0.14, 0, 0.05,
|
||||||
|
-0.14, 0.14, 0, -0.1, 0.1, 0.05,
|
||||||
|
0, 0.18, 0, 0, 0.14, 0.05,
|
||||||
|
]
|
||||||
|
@wireQuadStrip2 = [
|
||||||
|
0, 0.14, 0.05, 0, 0.07, 0.08, 0.1, 0.1, 0.05, 0.05, 0.05, 0.08,
|
||||||
|
0.14, 0, 0.05, 0.07, 0, 0.08,
|
||||||
|
0.1, -0.1, 0.05, 0.05, -0.05, 0.08,
|
||||||
|
0, -0.14, 0.05, 0, -0.07, 0.08,
|
||||||
|
-0.1, -0.1, 0.05, -0.05, -0.05, 0.08,
|
||||||
|
-0.14, 0, 0.05, -0.07, 0, 0.08,
|
||||||
|
-0.1, 0.1, 0.05, -0.05, 0.05, 0.08,
|
||||||
|
0, 0.14, 0.05, 0, 0.07, 0.08,
|
||||||
|
]
|
||||||
|
@wireTriangles = [
|
||||||
|
0, 0.07, 0.08, 0.05, 0.05, 0.08, 0,0,0.02,
|
||||||
|
0.05, 0.05, 0.08, 0.07, 0, 0.08, 0,0,0.02,
|
||||||
|
0.07, 0, 0.08, 0.05, -0.05, 0.08, 0,0,0.02,
|
||||||
|
0.05, -0.05, 0.08, 0, -0.07, 0.08, 0,0,0.02,
|
||||||
|
0, -0.07, 0.08, -0.05, -0.05, 0.08, 0,0,0.02,
|
||||||
|
-0.05, -0.05, 0.08, -0.07, 0, 0.08, 0,0,0.02,
|
||||||
|
-0.07, 0, 0.08, -0.05, 0.05, 0.08, 0,0,0.02,
|
||||||
|
-0.05, 0.05, 0.08, 0, 0.07, 0.08, 0,0,0.02
|
||||||
|
]
|
||||||
|
|
||||||
# 000 000 0000000 000 0000000 00000000 000 000
|
# 000 000 0000000 000 0000000 00000000 000 000
|
||||||
# 000 000 000 000 000 000 000 000 0000 000
|
# 000 000 000 000 000 000 000 000 0000 000
|
||||||
# 0000000 000 000 000 0000000 0000000 000 0 000
|
# 0000000 000 000 000 0000000 0000000 000 0 000
|
||||||
|
@ -427,9 +479,9 @@ class Geom
|
||||||
0.2, 0.27, 0.077, 0.05, 0.33, 0.077, 0.05, 0.33, -0.077, 0.2, 0.27, -0.077,
|
0.2, 0.27, 0.077, 0.05, 0.33, 0.077, 0.05, 0.33, -0.077, 0.2, 0.27, -0.077,
|
||||||
-0.27, 0.2, 0.077, -0.33, 0.05, 0.077, -0.33, 0.05, -0.077, -0.27, 0.2, -0.077,
|
-0.27, 0.2, 0.077, -0.33, 0.05, 0.077, -0.33, 0.05, -0.077, -0.27, 0.2, -0.077,
|
||||||
-0.2, -0.27, 0.077, -0.05, -0.33, 0.077, -0.05, -0.33, -0.077, -0.2, -0.27, -0.077,
|
-0.2, -0.27, 0.077, -0.05, -0.33, 0.077, -0.05, -0.33, -0.077, -0.2, -0.27, -0.077,
|
||||||
0.100, 0, 0.5, 0.071, 0.071, 0.5, 0, 0.100, 0.5, 0.071, -0.071, 0.5,
|
0.1, 0, 0.5, 0.071, 0.071, 0.5, 0, 0.1, 0.5, 0.071, -0.071, 0.5,
|
||||||
-0.100, 0, 0.5, -0.071, -0.071, 0.5, 0, -0.100, 0.5, -0.071, 0.071, 0.5,
|
-0.1, 0, 0.5, -0.071, -0.071, 0.5, 0, -0.1, 0.5, -0.071, 0.071, 0.5,
|
||||||
0.071, -0.071, 0.5, 0, 0.100, 0.5, -0.071, 0.071, 0.5, 0, -0.100, 0.5,
|
0.071, -0.071, 0.5, 0, 0.1, 0.5, -0.071, 0.071, 0.5, 0, -0.1, 0.5,
|
||||||
0.2, 0, -0.077, 0.141, -0.141, -0.077, 0, -0.2, -0.077, 0.141, 0.141, -0.077,
|
0.2, 0, -0.077, 0.141, -0.141, -0.077, 0, -0.2, -0.077, 0.141, 0.141, -0.077,
|
||||||
-0.2, 0, -0.077, -0.141, 0.141, -0.077, 0, 0.2, -0.077, -0.141, -0.141, -0.077,
|
-0.2, 0, -0.077, -0.141, 0.141, -0.077, 0, 0.2, -0.077, -0.141, -0.141, -0.077,
|
||||||
0.141, 0.141, -0.077, 0, -0.2, -0.077, -0.141, -0.141, -0.077, 0, 0.2, -0.077,
|
0.141, 0.141, -0.077, 0, -0.2, -0.077, -0.141, -0.141, -0.077, 0, 0.2, -0.077,
|
||||||
|
@ -456,23 +508,23 @@ class Geom
|
||||||
0, 0.200, 0.077, 0, 0.059, 0.220,
|
0, 0.200, 0.077, 0, 0.059, 0.220,
|
||||||
]
|
]
|
||||||
@generatorQuadStrip3 = [
|
@generatorQuadStrip3 = [
|
||||||
0, 0.100, 0.354, 0, 0.100, 0.5, 0.071, 0.071, 0.354, 0.071, 0.071, 0.5,
|
0, 0.1, 0.354, 0, 0.1, 0.5, 0.071, 0.071, 0.354, 0.071, 0.071, 0.5,
|
||||||
0.100, 0, 0.354, 0.100, 0, 0.5,
|
0.1, 0, 0.354, 0.1, 0, 0.5,
|
||||||
0.071, -0.071, 0.354, 0.071, -0.071, 0.5,
|
0.071, -0.071, 0.354, 0.071, -0.071, 0.5,
|
||||||
0, -0.100, 0.354, 0, -0.100, 0.5,
|
0, -0.1, 0.354, 0, -0.1, 0.5,
|
||||||
-0.071, -0.071, 0.354, -0.071, -0.071, 0.5,
|
-0.071, -0.071, 0.354, -0.071, -0.071, 0.5,
|
||||||
-0.100, 0, 0.354, -0.100, 0, 0.5,
|
-0.1, 0, 0.354, -0.1, 0, 0.5,
|
||||||
-0.071, 0.071, 0.354, -0.071, 0.071, 0.5,
|
-0.071, 0.071, 0.354, -0.071, 0.071, 0.5,
|
||||||
0, 0.100, 0.354, 0, 0.100, 0.5,
|
0, 0.1, 0.354, 0, 0.1, 0.5,
|
||||||
]
|
]
|
||||||
@generatorQuadStrip4 = [
|
@generatorQuadStrip4 = [
|
||||||
0.042, 0.042, 0.220, 0.071, 0.071, 0.354, 0.059, 0, 0.220, 0.100, 0, 0.354,
|
0.042, 0.042, 0.220, 0.071, 0.071, 0.354, 0.059, 0, 0.220, 0.1, 0, 0.354,
|
||||||
0.042, -0.042, 0.220, 0.071, -0.071, 0.354,
|
0.042, -0.042, 0.220, 0.071, -0.071, 0.354,
|
||||||
0, -0.059, 0.220, 0, -0.100, 0.354,
|
0, -0.059, 0.220, 0, -0.1, 0.354,
|
||||||
-0.042, -0.042, 0.220, -0.071, -0.071, 0.354,
|
-0.042, -0.042, 0.220, -0.071, -0.071, 0.354,
|
||||||
-0.059, 0, 0.220, -0.100, 0, 0.354,
|
-0.059, 0, 0.220, -0.1, 0, 0.354,
|
||||||
-0.042, 0.042, 0.220, -0.071, 0.071, 0.354,
|
-0.042, 0.042, 0.220, -0.071, 0.071, 0.354,
|
||||||
0, 0.059, 0.220, 0, 0.100, 0.354,
|
0, 0.059, 0.220, 0, 0.1, 0.354,
|
||||||
0.042, 0.042, 0.220, 0.071, 0.071, 0.354,
|
0.042, 0.042, 0.220, 0.071, 0.071, 0.354,
|
||||||
]
|
]
|
||||||
@generatorQuadStrip5 = [
|
@generatorQuadStrip5 = [
|
||||||
|
@ -532,21 +584,21 @@ class Geom
|
||||||
# 0 000 000 0000000 0 00000000
|
# 0 000 000 0000000 0 00000000
|
||||||
|
|
||||||
@valveQuads = [
|
@valveQuads = [
|
||||||
0.100, 0, 0.5, 0.071, 0.071, 0.5, 0, 0.100, 0.5, 0.071, -0.071, 0.5,
|
0.1, 0, 0.5, 0.071, 0.071, 0.5, 0, 0.1, 0.5, 0.071, -0.071, 0.5,
|
||||||
-0.100, 0, 0.5, -0.071, -0.071, 0.5, 0, -0.100, 0.5, -0.071, 0.071, 0.5,
|
-0.1, 0, 0.5, -0.071, -0.071, 0.5, 0, -0.1, 0.5, -0.071, 0.071, 0.5,
|
||||||
0.071, -0.071, 0.5, 0, 0.100, 0.5, -0.071, 0.071, 0.5, 0, -0.100, 0.5,
|
0.071, -0.071, 0.5, 0, 0.1, 0.5, -0.071, 0.071, 0.5, 0, -0.1, 0.5,
|
||||||
0.100, 0, -0.5, 0.071, -0.071, -0.5, 0, -0.100, -0.5, 0.071, 0.071, -0.5,
|
0.1, 0, -0.5, 0.071, -0.071, -0.5, 0, -0.1, -0.5, 0.071, 0.071, -0.5,
|
||||||
-0.100, 0, -0.5, -0.071, 0.071, -0.5, 0, 0.100, -0.5, -0.071, -0.071, -0.5,
|
-0.1, 0, -0.5, -0.071, 0.071, -0.5, 0, 0.1, -0.5, -0.071, -0.071, -0.5,
|
||||||
0.071, 0.071, -0.5, 0, -0.100, -0.5, -0.071, -0.071, -0.5, 0, 0.100, -0.5,
|
0.071, 0.071, -0.5, 0, -0.1, -0.5, -0.071, -0.071, -0.5, 0, 0.1, -0.5,
|
||||||
]
|
]
|
||||||
@valveQuadStrip1 = [
|
@valveQuadStrip1 = [
|
||||||
0.071, 0.071, -0.346, 0.042, 0.042, -0.220, 0.100, 0, -0.346, 0.059, 0, -0.220,
|
0.071, 0.071, -0.346, 0.042, 0.042, -0.220, 0.1, 0, -0.346, 0.059, 0, -0.220,
|
||||||
0.071, -0.071, -0.346, 0.042, -0.042, -0.220,
|
0.071, -0.071, -0.346, 0.042, -0.042, -0.220,
|
||||||
0, -0.100, -0.346, 0, -0.059, -0.220,
|
0, -0.1, -0.346, 0, -0.059, -0.220,
|
||||||
-0.071, -0.071, -0.346, -0.042, -0.042, -0.220,
|
-0.071, -0.071, -0.346, -0.042, -0.042, -0.220,
|
||||||
-0.100, 0, -0.346, -0.059, 0, -0.220,
|
-0.1, 0, -0.346, -0.059, 0, -0.220,
|
||||||
-0.071, 0.071, -0.346, -0.042, 0.042, -0.220,
|
-0.071, 0.071, -0.346, -0.042, 0.042, -0.220,
|
||||||
0, 0.100, -0.346, 0, 0.059, -0.220,
|
0, 0.1, -0.346, 0, 0.059, -0.220,
|
||||||
0.071, 0.071, -0.346, 0.042, 0.042, -0.220
|
0.071, 0.071, -0.346, 0.042, 0.042, -0.220
|
||||||
]
|
]
|
||||||
@valveQuadStrip2 = [
|
@valveQuadStrip2 = [
|
||||||
|
@ -560,33 +612,33 @@ class Geom
|
||||||
0.042, 0.042, -0.220, 0.042, 0.042, 0.220
|
0.042, 0.042, -0.220, 0.042, 0.042, 0.220
|
||||||
]
|
]
|
||||||
@valveQuadStrip3 = [
|
@valveQuadStrip3 = [
|
||||||
0.071, 0.071, -0.5, 0.071, 0.071, -0.346, 0.100, 0, -0.5, 0.100, 0, -0.346,
|
0.071, 0.071, -0.5, 0.071, 0.071, -0.346, 0.1, 0, -0.5, 0.1, 0, -0.346,
|
||||||
0.071, -0.071, -0.5, 0.071, -0.071, -0.346,
|
0.071, -0.071, -0.5, 0.071, -0.071, -0.346,
|
||||||
0, -0.100, -0.5, 0, -0.100, -0.346,
|
0, -0.1, -0.5, 0, -0.1, -0.346,
|
||||||
-0.071, -0.071, -0.5, -0.071, -0.071, -0.346,
|
-0.071, -0.071, -0.5, -0.071, -0.071, -0.346,
|
||||||
-0.100, 0, -0.5, -0.100, 0, -0.346,
|
-0.1, 0, -0.5, -0.1, 0, -0.346,
|
||||||
-0.071, 0.071, -0.5, -0.071, 0.071, -0.346,
|
-0.071, 0.071, -0.5, -0.071, 0.071, -0.346,
|
||||||
0, 0.100, -0.5, 0, 0.100, -0.346,
|
0, 0.1, -0.5, 0, 0.1, -0.346,
|
||||||
0.071, 0.071, -0.5, 0.071, 0.071, -0.346,
|
0.071, 0.071, -0.5, 0.071, 0.071, -0.346,
|
||||||
]
|
]
|
||||||
@valveQuadStrip4 = [
|
@valveQuadStrip4 = [
|
||||||
0, 0.100, 0.354, 0, 0.100, 0.5, 0.071, 0.071, 0.354, 0.071, 0.071, 0.5,
|
0, 0.1, 0.354, 0, 0.1, 0.5, 0.071, 0.071, 0.354, 0.071, 0.071, 0.5,
|
||||||
0.100, 0, 0.354, 0.100, 0, 0.5,
|
0.1, 0, 0.354, 0.1, 0, 0.5,
|
||||||
0.071, -0.071, 0.354, 0.071, -0.071, 0.5,
|
0.071, -0.071, 0.354, 0.071, -0.071, 0.5,
|
||||||
0, -0.100, 0.354, 0, -0.100, 0.5,
|
0, -0.1, 0.354, 0, -0.1, 0.5,
|
||||||
-0.071, -0.071, 0.354, -0.071, -0.071, 0.5,
|
-0.071, -0.071, 0.354, -0.071, -0.071, 0.5,
|
||||||
-0.100, 0, 0.354, -0.100, 0, 0.5,
|
-0.1, 0, 0.354, -0.1, 0, 0.5,
|
||||||
-0.071, 0.071, 0.354, -0.071, 0.071, 0.5,
|
-0.071, 0.071, 0.354, -0.071, 0.071, 0.5,
|
||||||
0, 0.100, 0.354, 0, 0.100, 0.5,
|
0, 0.1, 0.354, 0, 0.1, 0.5,
|
||||||
]
|
]
|
||||||
@valveQuadStrip5 = [
|
@valveQuadStrip5 = [
|
||||||
0.042, 0.042, 0.220, 0.071, 0.071, 0.354, 0.059, 0, 0.220, 0.100, 0, 0.354,
|
0.042, 0.042, 0.220, 0.071, 0.071, 0.354, 0.059, 0, 0.220, 0.1, 0, 0.354,
|
||||||
0.042, -0.042, 0.220, 0.071, -0.071, 0.354,
|
0.042, -0.042, 0.220, 0.071, -0.071, 0.354,
|
||||||
0, -0.059, 0.220, 0, -0.100, 0.354,
|
0, -0.059, 0.220, 0, -0.1, 0.354,
|
||||||
-0.042, -0.042, 0.220, -0.071, -0.071, 0.354,
|
-0.042, -0.042, 0.220, -0.071, -0.071, 0.354,
|
||||||
-0.059, 0, 0.220, -0.100, 0, 0.354,
|
-0.059, 0, 0.220, -0.1, 0, 0.354,
|
||||||
-0.042, 0.042, 0.220, -0.071, 0.071, 0.354,
|
-0.042, 0.042, 0.220, -0.071, 0.071, 0.354,
|
||||||
0, 0.059, 0.220, 0, 0.100, 0.354,
|
0, 0.059, 0.220, 0, 0.1, 0.354,
|
||||||
0.042, 0.042, 0.220, 0.071, 0.071, 0.354,
|
0.042, 0.042, 0.220, 0.071, 0.071, 0.354,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
module.exports =
|
module.exports =
|
||||||
Gear: require './gear'
|
Gear: require './gear'
|
||||||
Stone: require './stone'
|
Stone: require './stone'
|
||||||
|
Wire: require './wire'
|
||||||
|
WireStone: require './wirestone'
|
||||||
Wall: require './wall'
|
Wall: require './wall'
|
||||||
MotorGear: require './motorgear'
|
MotorGear: require './motorgear'
|
||||||
MotorCylinder: require './motorcylinder'
|
MotorCylinder: require './motorcylinder'
|
||||||
|
|
|
@ -38,9 +38,10 @@ class Levels
|
||||||
# "fallen",
|
# "fallen",
|
||||||
# "cheese",
|
# "cheese",
|
||||||
# "invisimaze",
|
# "invisimaze",
|
||||||
"spiral",
|
# "spiral",
|
||||||
# difficult
|
# difficult
|
||||||
"slick", "bridge", "flower", "stones", "walls", "grid",
|
# "slick",
|
||||||
|
"bridge", "flower", "stones", "walls", "grid",
|
||||||
"rings",
|
"rings",
|
||||||
# "core",
|
# "core",
|
||||||
"bronze", "pool",
|
"bronze", "pool",
|
||||||
|
|
|
@ -22,27 +22,28 @@ module.exports =
|
||||||
place a wire stone
|
place a wire stone
|
||||||
next to the exit
|
next to the exit
|
||||||
"""
|
"""
|
||||||
player: position: [0,-3,1]
|
player:
|
||||||
|
position: [0,-3,1]
|
||||||
exits: [
|
exits: [
|
||||||
name: "exit"
|
name: "exit"
|
||||||
active: 0
|
active: 0
|
||||||
position: [0,-1,0]
|
position: [0,-1,0]
|
||||||
]
|
]
|
||||||
create: ->
|
create: ->
|
||||||
|
|
||||||
s = world.size
|
s = world.size
|
||||||
|
{Face,MotorCylinder,MotorGear,Generator,Wire} = require '../items'
|
||||||
|
|
||||||
world.addObjectAtPos KikiMotorGear(KikiFace.NY), KikiPos s.x/2-1, s.y-1, s.z/2
|
world.addObjectAtPos new MotorGear(Face.NY), s.x/2-1, s.y-1, s.z/2
|
||||||
world.addObjectAtPos KikiMotorCylinder(KikiFace.NY), KikiPos s.x/2-1, s.y-2, s.z/2
|
world.addObjectAtPos new MotorCylinder(Face.NY), s.x/2-1, s.y-2, s.z/2
|
||||||
world.addObjectAtPos KikiGenerator(KikiFace.NY), KikiPos s.x/2+1, s.y-1, s.z/2
|
world.addObjectAtPos new Generator(Face.NY), s.x/2+1, s.y-1, s.z/2
|
||||||
world.addObjectLine "KikiWire (KikiFace.NY, KikiWire.VERTICAL)", s.x/2, s.y-1, 0, s.x/2, s.y-1, s.z
|
world.addObjectLine new Wire(Face.NY, Wire.VERTICAL), s.x/2, s.y-1, 0, s.x/2, s.y-1, s.z
|
||||||
world.addObjectLine "KikiWire (KikiFace.PY, KikiWire.VERTICAL)", s.x/2, 0, 0, s.x/2, 0, s.z
|
world.addObjectLine new Wire(Face.Y, Wire.VERTICAL), s.x/2, 0, 0, s.x/2, 0, s.z
|
||||||
world.addObjectLine "KikiWire (KikiFace.PZ, KikiWire.VERTICAL)", s.x/2, 0, 0, s.x/2, s.y, 0
|
world.addObjectLine new Wire(Face.Z, Wire.VERTICAL), s.x/2, 0, 0, s.x/2, s.y, 0
|
||||||
world.addObjectLine "KikiWire (KikiFace.NZ, KikiWire.VERTICAL)", s.x/2, 0, s.z-1, s.x/2, s.y, s.z-1
|
world.addObjectLine new Wire(Face.NZ, Wire.VERTICAL), s.x/2, 0, s.z-1, s.x/2, s.y, s.z-1
|
||||||
|
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+3, 0, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2+3, 0, s.z/2
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-3, 0, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2-3, 0, s.z/2
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+2, 1, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2+2, 1, s.z/2
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-2, 1, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2-2, 1, s.z/2
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+1, 2, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2+1, 2, s.z/2
|
||||||
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-1, 2, s.z/2
|
world.addObjectAtPos 'WireStone', s.x/2-1, 2, s.z/2
|
||||||
|
|
|
@ -18,17 +18,26 @@ module.exports =
|
||||||
create: ->
|
create: ->
|
||||||
|
|
||||||
s = world.size
|
s = world.size
|
||||||
{Gear,Generator,MotorCylinder,MotorGear,Face,Wall} = require '../items'
|
{Gear,Generator,MotorCylinder,MotorGear,Face,Wall,Wire,WireStone,Stone} = require '../items'
|
||||||
|
|
||||||
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 7, 5, 0
|
||||||
|
# world.addObjectAtPos new Wire(Face.NZ, Wire.ALL), 7, 5, 0
|
||||||
|
# world.addObjectAtPos new Wire(Face.Y, Wire.ALL), 7, 5, 0
|
||||||
|
# world.addObjectAtPos new Wire(Face.NY, Wire.ALL), 7, 5, 0
|
||||||
|
# world.addObjectAtPos new Wire(Face.X, Wire.ALL), 7, 5, 0
|
||||||
|
# world.addObjectAtPos new Wire(Face.NX, Wire.ALL), 7, 5, 0
|
||||||
|
|
||||||
world.addObjectAtPos new Generator(Face.Z), 5, 7, 0
|
world.addObjectAtPos new Generator(Face.Z), 5, 7, 0
|
||||||
world.addObjectAtPos new Wall(), 6, 7, 0
|
world.addObjectAtPos new Stone(), 6, 7, 0
|
||||||
world.addObjectAtPos new Wall(), 6, 7, 1
|
world.addObjectAtPos new Stone(), 6, 7, 2
|
||||||
world.addObjectAtPos new Wall(), 6, 7, 2
|
world.addObjectAtPos new WireStone(), 6, 7, 1
|
||||||
|
world.addObjectAtPos new WireStone(), 3, 7, 1
|
||||||
|
|
||||||
world.addObjectAtPos new MotorCylinder(Face.Z), 4, 5, 1
|
world.addObjectAtPos new MotorCylinder(Face.Z), 4, 5, 1
|
||||||
world.addObjectAtPos new MotorGear(Face.Z), 4, 5, 0
|
world.addObjectAtPos new MotorGear(Face.Z), 4, 5, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 6, 5, 0
|
# world.addObjectAtPos new Gear(Face.Z), 6, 5, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 5, 6, 0
|
# world.addObjectAtPos new Gear(Face.Z), 5, 6, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
# world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
||||||
return
|
return
|
||||||
world.addObjectAtPos new Gear(Face.Z), 6, 6, 0
|
world.addObjectAtPos new Gear(Face.Z), 6, 6, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 4, 4, 0
|
world.addObjectAtPos new Gear(Face.Z), 4, 4, 0
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Vector
|
||||||
if Number.isNaN @x or Number.isNaN @w
|
if Number.isNaN @x or Number.isNaN @w
|
||||||
throw new Error
|
throw new Error
|
||||||
|
|
||||||
|
clone: -> new Vector @
|
||||||
copy: (v) ->
|
copy: (v) ->
|
||||||
@x = v.x
|
@x = v.x
|
||||||
@y = v.y
|
@y = v.y
|
||||||
|
|
|
@ -13,6 +13,12 @@ module.exports =
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
shininess: 20
|
shininess: 20
|
||||||
|
|
||||||
|
wire: new THREE.MeshPhongMaterial
|
||||||
|
color: 0xff0000
|
||||||
|
side: THREE.DoubleSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
shininess: 40
|
||||||
|
|
||||||
raster: new THREE.MeshPhongMaterial
|
raster: new THREE.MeshPhongMaterial
|
||||||
color: 0x880000
|
color: 0x880000
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
|
@ -27,7 +33,7 @@ module.exports =
|
||||||
|
|
||||||
plate: new THREE.MeshPhongMaterial
|
plate: new THREE.MeshPhongMaterial
|
||||||
color: 0x880000
|
color: 0x880000
|
||||||
side: THREE.FrontSide
|
side: THREE.DoubleSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
shininess: 10
|
shininess: 10
|
||||||
emissive: 0x880000
|
emissive: 0x880000
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Player extends Bot
|
||||||
posDelta = world.getSpeed() / 10.0
|
posDelta = world.getSpeed() / 10.0
|
||||||
playerDir = @getCurrentDir()
|
playerDir = @getCurrentDir()
|
||||||
playerUp = @current_orientation.rotate(new Vector(0,1,0)).normal()
|
playerUp = @current_orientation.rotate(new Vector(0,1,0)).normal()
|
||||||
camPos = @current_position.plus playerDir.mul 0.4*(1-Math.abs(@look_angle)/90)
|
camPos = @current_position.clone()
|
||||||
if @look_angle < 0
|
if @look_angle < 0
|
||||||
camPos.add playerUp.mul -2*@look_angle/90
|
camPos.add playerUp.mul -2*@look_angle/90
|
||||||
@projection.setPosition @projection.getPosition().mul(1.0-posDelta).plus camPos.mul posDelta
|
@projection.setPosition @projection.getPosition().mul(1.0-posDelta).plus camPos.mul posDelta
|
||||||
|
|
|
@ -5,11 +5,22 @@
|
||||||
# 00 00 000 000 000 00000000
|
# 00 00 000 000 000 00000000
|
||||||
|
|
||||||
Item = require './item'
|
Item = require './item'
|
||||||
|
Geom = require './geom'
|
||||||
|
Face = require './face'
|
||||||
|
Vector = require './lib/vector'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class Wire extends Item
|
class Wire extends Item
|
||||||
|
|
||||||
constructor: (@face, @connections) ->
|
@UP =1
|
||||||
|
@RIGHT =2
|
||||||
|
@DOWN =4
|
||||||
|
@LEFT =8
|
||||||
|
@VERTICAL =5
|
||||||
|
@HORIZONTAL =10
|
||||||
|
@ALL =15
|
||||||
|
|
||||||
|
constructor: (@face=Face.Z, @connections=Wire.ALL) ->
|
||||||
super
|
super
|
||||||
@active = false
|
@active = false
|
||||||
@value = 1.0
|
@value = 1.0
|
||||||
|
@ -18,7 +29,39 @@ class Wire extends Item
|
||||||
@SWITCH_ON_EVENT = @addEventWithName "on"
|
@SWITCH_ON_EVENT = @addEventWithName "on"
|
||||||
@SWITCHED_EVENT = @addEventWithName "switched"
|
@SWITCHED_EVENT = @addEventWithName "switched"
|
||||||
|
|
||||||
@updateActive: ->
|
createMesh: ->
|
||||||
|
o = 0.005
|
||||||
|
geom = new THREE.Geometry
|
||||||
|
|
||||||
|
h = 0.1
|
||||||
|
s = 0.5
|
||||||
|
w = s+o
|
||||||
|
|
||||||
|
if @connections & Wire.RIGHT
|
||||||
|
plane = new THREE.PlaneGeometry w, h
|
||||||
|
plane.translate w/2, 0, -s+o
|
||||||
|
geom.merge plane
|
||||||
|
if @connections & Wire.LEFT
|
||||||
|
plane = new THREE.PlaneGeometry w, h
|
||||||
|
plane.translate -w/2, 0, -s+o
|
||||||
|
geom.merge plane
|
||||||
|
if @connections & Wire.UP
|
||||||
|
plane = new THREE.PlaneGeometry h, w
|
||||||
|
plane.translate 0, w/2, -s+o
|
||||||
|
geom.merge plane
|
||||||
|
if @connections & Wire.DOWN
|
||||||
|
plane = new THREE.PlaneGeometry h, w
|
||||||
|
plane.translate 0, -w/2, -s+o
|
||||||
|
geom.merge plane
|
||||||
|
|
||||||
|
@wire = new THREE.Mesh geom, Material.wire
|
||||||
|
@mesh = new THREE.Mesh Geom.wire(), Material.plate
|
||||||
|
@mesh.add @wire
|
||||||
|
@mesh.receiveShadow = true
|
||||||
|
@mesh.position.copy Face.normalVectorForFace(@face).mul -(0.5+o)
|
||||||
|
@mesh.quaternion.copy Face.orientationForFace @face
|
||||||
|
|
||||||
|
updateActive: ->
|
||||||
for wire in @getNeighborWires()
|
for wire in @getNeighborWires()
|
||||||
@setActive true if wire.active
|
@setActive true if wire.active
|
||||||
|
|
||||||
|
@ -52,20 +95,20 @@ class Wire extends Item
|
||||||
rot = Face.orientationForFace @face
|
rot = Face.orientationForFace @face
|
||||||
n = Face.normalVectorForFace @face
|
n = Face.normalVectorForFace @face
|
||||||
|
|
||||||
neighbor_dirs.push_back new Vector
|
neighbor_dirs.push new Vector
|
||||||
|
|
||||||
if @connections & RIGHT
|
if @connections & Wire.RIGHT
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(1,0,0)
|
neighbor_dirs.push rot.rotate new Vector(1,0,0)
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(1,0,0) + n
|
neighbor_dirs.push rot.rotate new Vector(1,0,0).plus n
|
||||||
if @connections & LEFT
|
if @connections & Wire.LEFT
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(-1,0,0)
|
neighbor_dirs.push rot.rotate new Vector(-1,0,0)
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(-1,0,0) + n
|
neighbor_dirs.push rot.rotate new Vector(-1,0,0).plus n
|
||||||
if @connections & UP
|
if @connections & Wire.UP
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(0,1,0)
|
neighbor_dirs.push rot.rotate new Vector(0,1,0)
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(0,1,0) + n
|
neighbor_dirs.push rot.rotate new Vector(0,1,0).plus n
|
||||||
if @connections & DOWN
|
if @connections & Wire.DOWN
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(0,-1,0)
|
neighbor_dirs.push rot.rotate new Vector(0,-1,0)
|
||||||
neighbor_dirs.push_back rot.rotate new Vector(0,-1,0) + n
|
neighbor_dirs.push rot.rotate new Vector(0,-1,0).plus n
|
||||||
|
|
||||||
for i in [0...neighbor_dirs.length]
|
for i in [0...neighbor_dirs.length]
|
||||||
neighbors = world.getObjectsOfTypeAtPos Wire, @position.plus neighbor_dirs[i]
|
neighbors = world.getObjectsOfTypeAtPos Wire, @position.plus neighbor_dirs[i]
|
||||||
|
@ -76,62 +119,22 @@ class Wire extends Item
|
||||||
for neighbor_point in neighbor_points
|
for neighbor_point in neighbor_points
|
||||||
if (neighbor_point.minus point).length() < 0.1
|
if (neighbor_point.minus point).length() < 0.1
|
||||||
wires.push iter
|
wires.push iter
|
||||||
|
|
||||||
wires
|
wires
|
||||||
|
|
||||||
getConnectionPoints: ->
|
getConnectionPoints: ->
|
||||||
points = []
|
points = []
|
||||||
to_border = 0.5 * Face.normalVectorForFace @face
|
to_border = Face.normalVectorForFace(@face).mul 0.5
|
||||||
rot = Face.orientationForFace @face
|
rot = Face.orientationForFace @face
|
||||||
|
if @connections & Wire.RIGHT
|
||||||
if (connections & RIGHT)
|
points.push @position.plus to_border.plus rot.rotate new Vector 0.5, 0, 0
|
||||||
points.push position.plus to_border.plus rot.rotate new Vector 0.5, 0, 0
|
if @connections & Wire.LEFT
|
||||||
if (connections & LEFT)
|
points.push @position.plus to_border.plus rot.rotate new Vector -0.5, 0, 0
|
||||||
points.push position.plus to_border.plus rot.rotate new Vector -0.5, 0, 0
|
if @connections & Wire.UP
|
||||||
if (connections & UP)
|
points.push @position.plus to_border.plus rot.rotate new Vector 0, 0.5, 0
|
||||||
points.push position.plus to_border.plus rot.rotate new Vector 0, 0.5, 0
|
if @connections & Wire.DOWN
|
||||||
if (connections & DOWN)
|
points.push @position.plus to_border.plus rot.rotate new Vector 0, -0.5, 0
|
||||||
points.push position.plus to_border.plus rot.rotate new Vector 0, -0.5, 0
|
|
||||||
|
|
||||||
points
|
points
|
||||||
|
|
||||||
display: ->
|
# KikiBillBoard::displayTextureWithSize 0.15
|
||||||
# KikiObject::preDisplay();
|
|
||||||
# KVector face_normal = KikiFace::normalVectorForFace (face);
|
|
||||||
# float o = 0.005;
|
|
||||||
# ((0.5-o) * face_normal).glTranslate();
|
|
||||||
#
|
|
||||||
# glPushMatrix();
|
|
||||||
#
|
|
||||||
# KMatrix mat(KikiFace::orientationForFace (face));
|
|
||||||
# mat.glMultMatrix();
|
|
||||||
#
|
|
||||||
# colors[KikiWire_base_color].glColor();
|
|
||||||
#
|
|
||||||
# render_wire;
|
|
||||||
#
|
|
||||||
# glDisable (GL_CULL_FACE);
|
|
||||||
# float h = 0.05;
|
|
||||||
# float s = 0.5+o;
|
|
||||||
# glNormal3f(0.0, 0.0, 1.0);
|
|
||||||
# if (connections & RIGHT) glRectf ( 0.0, -h, s, h);
|
|
||||||
# if (connections & LEFT) glRectf (-s, -h, 0.0, h);
|
|
||||||
# if (connections & UP) glRectf (-h, 0.0, h, s);
|
|
||||||
# if (connections & DOWN) glRectf (-h, -s, h, 0.0);
|
|
||||||
# glEnable (GL_CULL_FACE);
|
|
||||||
#
|
|
||||||
# glPopMatrix();
|
|
||||||
#
|
|
||||||
# if (active)
|
|
||||||
# KColor c (colors[KikiWire_light_color]);
|
|
||||||
# c.setAlpha (value);
|
|
||||||
# c.glColor();
|
|
||||||
#
|
|
||||||
# (face_normal * -0.1).glTranslate();
|
|
||||||
#
|
|
||||||
# KikiBillBoard::displayTextureWithSize
|
|
||||||
# (Controller.world->getTextureId(KikiWorld::TEXTURE_GRADIENT), 0.15);
|
|
||||||
#
|
|
||||||
# KikiObject::postDisplay();
|
|
||||||
|
|
||||||
module.exports = Wire
|
module.exports = Wire
|
||||||
|
|
|
@ -8,28 +8,25 @@ Stone = require './stone'
|
||||||
Wall = require './wall'
|
Wall = require './wall'
|
||||||
Face = require './face'
|
Face = require './face'
|
||||||
Wire = require './wire'
|
Wire = require './wire'
|
||||||
|
Action = require './action'
|
||||||
Generator = require './generator'
|
Generator = require './generator'
|
||||||
|
|
||||||
class WireStone extends Stone
|
class WireStone extends Stone
|
||||||
|
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
@wires = [null, null, null, null, null, null]
|
@wires = [null, null, null, null, null, null]
|
||||||
|
super
|
||||||
|
|
||||||
initAction: (action) ->
|
initAction: (action) ->
|
||||||
|
|
||||||
switch action.id
|
switch action.id
|
||||||
|
|
||||||
when Action.FALL, Action.PUSH
|
when Action.FALL, Action.PUSH
|
||||||
|
|
||||||
for i in [0...6]
|
for i in [0...6]
|
||||||
if @wires[i]?
|
if @wires[i]?
|
||||||
world.unsetObject @wires[i]
|
world.unsetObject @wires[i]
|
||||||
@wires[i].setActive false
|
@wires[i].setActive false
|
||||||
|
|
||||||
for generator in world.getObjectsOfType Generator
|
for generator in world.getObjectsOfType Generator
|
||||||
if generator.active
|
if generator.active
|
||||||
generator.activateWires()
|
generator.activateWires()
|
||||||
|
|
||||||
super action
|
super action
|
||||||
|
|
||||||
setPosition: (pos) ->
|
setPosition: (pos) ->
|
||||||
|
@ -37,7 +34,7 @@ class WireStone extends Stone
|
||||||
newPos = pos.minus Face.normalVectorForFace i
|
newPos = pos.minus Face.normalVectorForFace i
|
||||||
if @isFreePos newPos
|
if @isFreePos newPos
|
||||||
if not @wires[i]?
|
if not @wires[i]?
|
||||||
@wires[i] = new Wire i
|
@wires[i] = new Wire (i+3)%6
|
||||||
world.addObjectAtPos @wires[i], newPos
|
world.addObjectAtPos @wires[i], newPos
|
||||||
else
|
else
|
||||||
world.setObjectAtPos @wires[i], newPos
|
world.setObjectAtPos @wires[i], newPos
|
||||||
|
@ -55,14 +52,14 @@ class WireStone extends Stone
|
||||||
setCurrentPosition: (pos) ->
|
setCurrentPosition: (pos) ->
|
||||||
super pos
|
super pos
|
||||||
for i in [0...6]
|
for i in [0...6]
|
||||||
@wires[i]?.setPosition pos.minus Face.normalVectorForFace i
|
@wires[i]?.setPosition @current_position.minus Face.normalVectorForFace i
|
||||||
|
|
||||||
isFreePos: (pos) ->
|
isFreePos: (pos) ->
|
||||||
if world.isUnoccupiedPos pos
|
if world.isUnoccupiedPos pos
|
||||||
return true
|
return true
|
||||||
if world.isValidPos pos
|
if world.isValidPos pos
|
||||||
occupant = world.getOccupantAtPos pos
|
occupant = world.getOccupantAtPos pos
|
||||||
return (occupant instanceof Wall) or not (occupant instanceof Stone)
|
return not (occupant instanceof Wall) and not (occupant instanceof Stone)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
module.exports = WireStone
|
module.exports = WireStone
|
||||||
|
|
|
@ -423,11 +423,9 @@ class World extends Actor
|
||||||
# 0000000 0000000 0000000 00000000 0000000 000 0000000
|
# 0000000 0000000 0000000 00000000 0000000 000 0000000
|
||||||
|
|
||||||
getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss
|
getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss
|
||||||
getObjectsOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getObjectsOfType clss
|
getObjectsOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getObjectsOfType(clss) ? []
|
||||||
getObjectOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getRealObjectOfType clss
|
getObjectOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getRealObjectOfType(clss) ? []
|
||||||
getOccupantAtPos: (pos) ->
|
getOccupantAtPos: (pos) -> @getCellAtPos(pos)?.getOccupant()
|
||||||
# log "getOccupantAtPos cell? #{@getCellAtPos(pos)?}", pos
|
|
||||||
@getCellAtPos(pos)?.getOccupant()
|
|
||||||
getRealOccupantAtPos: (pos) ->
|
getRealOccupantAtPos: (pos) ->
|
||||||
occupant = @getOccupantAtPos pos
|
occupant = @getOccupantAtPos pos
|
||||||
if occupant and occupant instanceof TmpObject
|
if occupant and occupant instanceof TmpObject
|
||||||
|
@ -454,7 +452,6 @@ class World extends Actor
|
||||||
if not cell?
|
if not cell?
|
||||||
cellIndex = @posToIndex(pos)
|
cellIndex = @posToIndex(pos)
|
||||||
cell = new Cell()
|
cell = new Cell()
|
||||||
# log "created cell at index #{cellIndex}"
|
|
||||||
@cells[cellIndex] = cell
|
@cells[cellIndex] = cell
|
||||||
|
|
||||||
object.setPosition pos
|
object.setPosition pos
|
||||||
|
@ -462,11 +459,9 @@ class World extends Actor
|
||||||
|
|
||||||
unsetObject: (object) ->
|
unsetObject: (object) ->
|
||||||
pos = object.getPos()
|
pos = object.getPos()
|
||||||
# log "world.unsetObject #{object.name} pos:", pos
|
|
||||||
if cell = @getCellAtPos pos
|
if cell = @getCellAtPos pos
|
||||||
cell.removeObject object
|
cell.removeObject object
|
||||||
if cell.isEmpty()
|
if cell.isEmpty()
|
||||||
# log 'world.unsetObject remove cell empty cell', pos
|
|
||||||
@cells[@posToIndex(pos)] = null
|
@cells[@posToIndex(pos)] = null
|
||||||
else
|
else
|
||||||
log 'world.unsetObject [WARNING] no cell at pos:', pos
|
log 'world.unsetObject [WARNING] no cell at pos:', pos
|
||||||
|
@ -502,10 +497,7 @@ class World extends Actor
|
||||||
true
|
true
|
||||||
|
|
||||||
toggle: (objectName) ->
|
toggle: (objectName) ->
|
||||||
# toggles object with name objectName
|
|
||||||
object = @getObjectWithName objectName
|
object = @getObjectWithName objectName
|
||||||
log "world.toggle #{objectName} #{object?}"
|
|
||||||
# @startTimedAction object.getActionWithName "toggle"
|
|
||||||
object.getActionWithName("toggle").perform()
|
object.getActionWithName("toggle").perform()
|
||||||
|
|
||||||
# 0000000 00000000 000 00000000 000000000 00000000
|
# 0000000 00000000 000 00000000 000000000 00000000
|
||||||
|
@ -515,7 +507,6 @@ class World extends Actor
|
||||||
# 0000000 00000000 0000000 00000000 000 00000000
|
# 0000000 00000000 0000000 00000000 000 00000000
|
||||||
|
|
||||||
deleteObject: (object) ->
|
deleteObject: (object) ->
|
||||||
# log "world.deleteObject #{object.name}"
|
|
||||||
if not object?
|
if not object?
|
||||||
log "world.deleteObject [WARNING] no object?"
|
log "world.deleteObject [WARNING] no object?"
|
||||||
return
|
return
|
||||||
|
@ -524,7 +515,6 @@ class World extends Actor
|
||||||
|
|
||||||
deleteAllObjects: () ->
|
deleteAllObjects: () ->
|
||||||
# log 'world.deleteAllObjects'
|
# log 'world.deleteAllObjects'
|
||||||
|
|
||||||
Timer.removeAllActions()
|
Timer.removeAllActions()
|
||||||
|
|
||||||
if @player?
|
if @player?
|
||||||
|
@ -553,14 +543,14 @@ class World extends Actor
|
||||||
for o in @objects
|
for o in @objects
|
||||||
if objectName == o.name
|
if objectName == o.name
|
||||||
return o
|
return o
|
||||||
log "World.getObjectWithName :: no object found with name #{objectName}"
|
log "World.getObjectWithName [WARNING] no object with name #{objectName}"
|
||||||
null
|
null
|
||||||
|
|
||||||
setCameraMode: (mode) -> @camera_mode = clamp World.CAMERA_INSIDE, World.CAMERA_FOLLOW, mode
|
setCameraMode: (mode) -> @camera_mode = clamp World.CAMERA_INSIDE, World.CAMERA_FOLLOW, mode
|
||||||
|
|
||||||
changeCameraMode: () ->
|
changeCameraMode: () ->
|
||||||
@camera_mode = (@camera_mode+1) % (World.CAMERA_FOLLOW+1)
|
@camera_mode = (@camera_mode+1) % (World.CAMERA_FOLLOW+1)
|
||||||
log "world.changeCameraMode #{@camera_mode}"
|
# log "world.changeCameraMode #{@camera_mode}"
|
||||||
@camera_mode
|
@camera_mode
|
||||||
|
|
||||||
# 0000000 0000000 000 00 00 0000000 000 000 00000000
|
# 0000000 0000000 000 00 00 0000000 000 000 00000000
|
||||||
|
@ -597,16 +587,15 @@ class World extends Actor
|
||||||
log "world.objectWillMoveToPos [WARNING] #{object.name} already occupied:", targetPos
|
log "world.objectWillMoveToPos [WARNING] #{object.name} already occupied:", targetPos
|
||||||
|
|
||||||
if object.name != 'player'
|
if object.name != 'player'
|
||||||
# log "---------- tmpObjects not player? #{object.name}"
|
|
||||||
@unsetObject object # remove object from cell grid
|
@unsetObject object # remove object from cell grid
|
||||||
|
|
||||||
# log 'tmpObject at old pos', sourcePos
|
# log 'world.objectWillMoveToPos tmpObject at old pos', sourcePos
|
||||||
tmpObject = new TmpObject object # insert tmp object at old pos
|
tmpObject = new TmpObject object # insert tmp object at old pos
|
||||||
tmpObject.setPosition sourcePos
|
tmpObject.setPosition sourcePos
|
||||||
tmpObject.time = -duration
|
tmpObject.time = -duration
|
||||||
@addObjectAtPos tmpObject, sourcePos
|
@addObjectAtPos tmpObject, sourcePos
|
||||||
|
|
||||||
# log 'tmpObject at new pos', targetPos
|
# log 'world.objectWillMoveToPos tmpObject at new pos', targetPos
|
||||||
tmpObject = new TmpObject object # insert tmp object at new pos
|
tmpObject = new TmpObject object # insert tmp object at new pos
|
||||||
tmpObject.setPosition targetPos
|
tmpObject.setPosition targetPos
|
||||||
tmpObject.time = duration
|
tmpObject.time = duration
|
||||||
|
@ -634,24 +623,18 @@ class World extends Actor
|
||||||
if @isOccupiedPos targetPos
|
if @isOccupiedPos targetPos
|
||||||
log "World.objectMoved [WARNING] #{movedObject.name} occupied target pos:", targetPos
|
log "World.objectMoved [WARNING] #{movedObject.name} occupied target pos:", targetPos
|
||||||
|
|
||||||
# log 'World.objectMovedFromPos sourcePos:', sourcePos
|
|
||||||
# log 'World.objectMovedFromPos targetPos:', targetPos
|
|
||||||
|
|
||||||
if sourceCell?
|
if sourceCell?
|
||||||
sourceCell.removeObject movedObject
|
sourceCell.removeObject movedObject
|
||||||
if sourceCell.isEmpty()
|
if sourceCell.isEmpty()
|
||||||
# log 'world.objectMoved remove empty cell at pos:', sourcePos
|
|
||||||
@cells[@posToIndex(sourcePos)] = null
|
@cells[@posToIndex(sourcePos)] = null
|
||||||
|
|
||||||
targetCell = @getCellAtPos targetPos
|
targetCell = @getCellAtPos targetPos
|
||||||
if not targetCell?
|
if not targetCell?
|
||||||
cellIndex = @posToIndex targetPos
|
cellIndex = @posToIndex targetPos
|
||||||
targetCell = new Cell()
|
targetCell = new Cell()
|
||||||
# log "world.objectMoved created cell at index #{cellIndex}", targetPos
|
|
||||||
@cells[cellIndex] = targetCell
|
@cells[cellIndex] = targetCell
|
||||||
|
|
||||||
if targetCell?
|
if targetCell?
|
||||||
# log "add #{movedObject.name} to targetCell at pos", targetPos
|
|
||||||
targetCell.addObject movedObject
|
targetCell.addObject movedObject
|
||||||
else
|
else
|
||||||
log "world.objectMoved [WARNING] #{movedObject.name} no target cell?"
|
log "world.objectMoved [WARNING] #{movedObject.name} no target cell?"
|
||||||
|
|
|
@ -2,6 +2,7 @@ name kiki
|
||||||
main js/main.js
|
main js/main.js
|
||||||
dependencies
|
dependencies
|
||||||
coffee-script ^1.10.0
|
coffee-script ^1.10.0
|
||||||
|
howler ^2.0.0
|
||||||
lodash ^4.13.1
|
lodash ^4.13.1
|
||||||
noon >=1.0.12
|
noon >=1.0.12
|
||||||
performance-now ^0.2.0
|
performance-now ^0.2.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user