This commit is contained in:
monsterkodi 2016-08-10 01:25:54 +02:00
parent 66253c51e1
commit 24315c0ed2
19 changed files with 246 additions and 143 deletions

View File

@ -7,7 +7,7 @@
class Cell
constructor: () ->
constructor: () -> @objects = []
getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss
getObjectOfType: (clss) -> _.find @objects, (o) -> o instanceof clss

View File

@ -5,8 +5,23 @@
# 000 000 000 000 0 000
# 000 000 00000000 000 000
log = require '/Users/kodi/s/ko/js/tools/log'
class Item
constructor: ->
isSpaceEgoistic: -> true
setPosition: (p) ->
@position = @current_position = p
if @mesh?
log 'setPosition', @mesh.position
# @mesh.position = new THREE.Vector3 @position.x, @position.y, @position.z
# @mesh.matrixWorldNeedsUpdate = true
# @mesh.updateMatrix()
# @mesh.updateMatrixWorld true
@mesh.translateX @position.x
@mesh.translateY @position.y
@mesh.translateZ @position.z
log 'setPosition', p, @mesh.position
module.exports = Item

View File

@ -25,6 +25,6 @@ module.exports =
position: [0,2,0]
],
create: ->
world.addObjectAtPos KikiBomb(), world.decenter 0,-4,2
world.addObjectAtPos KikiBomb(), world.decenter 0,-4,-2
world.addObjectAtPos KikiBomb(), world.decenter -3,-2,0
world.addObjectAtPos 'KikiBomb', world.decenter 0,-4,2
world.addObjectAtPos 'KikiBomb', world.decenter 0,-4,-2
world.addObjectAtPos 'KikiBomb', world.decenter -3,-2,0

View File

@ -26,7 +26,7 @@ module.exports =
position: [0,0,0]
]
create: ->
world.addObjectAtPos KikiLight(), KikiPos 7,7,7
world.addObjectAtPos 'KikiLight', KikiPos 7,7,7
for i in [0...150]
world.setObjectRandom KikiMutant()

View File

@ -40,9 +40,9 @@ module.exports =
world.addObjectLine "KikiWire (KikiFace.PZ, KikiWire.VERTICAL)", KikiPos(s.x/2, 0, 0), KikiPos s.x/2, s.y, 0
world.addObjectLine "KikiWire (KikiFace.NZ, KikiWire.VERTICAL)", KikiPos(s.x/2, 0, s.z-1), KikiPos s.x/2, s.y, s.z-1
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2+3, 0, s.z/2
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2-3, 0, s.z/2
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2+2, 1, s.z/2
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2-2, 1, s.z/2
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2+1, 2, s.z/2
world.addObjectAtPos KikiWireStone(), KikiPos s.x/2-1, 2, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+3, 0, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-3, 0, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+2, 1, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-2, 1, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2+1, 2, s.z/2
world.addObjectAtPos 'KikiWireStone', KikiPos s.x/2-1, 2, s.z/2

View File

@ -25,19 +25,19 @@ module.exports =
create: ->
s = world.size
world.addObjectLine("KikiWireStone()", KikiPos(0, 0, 0), KikiPos(0, s.y-2, 0))
world.addObjectLine("KikiWireStone()", KikiPos(s.x-1, 0, 0), KikiPos(s.x-1, s.y-2, 0))
world.addObjectLine("KikiWireStone()", KikiPos(s.x-1, 0, s.z-1), KikiPos(s.x-1, s.y-2, s.z-1))
world.addObjectLine("KikiWireStone()", KikiPos(0, 0, s.z-1), KikiPos(0, s.y-2, s.z-1))
world.addObjectLine('KikiWireStone', KikiPos(0, 0, 0), KikiPos(0, s.y-2, 0))
world.addObjectLine('KikiWireStone', KikiPos(s.x-1, 0, 0), KikiPos(s.x-1, s.y-2, 0))
world.addObjectLine('KikiWireStone', KikiPos(s.x-1, 0, s.z-1), KikiPos(s.x-1, s.y-2, s.z-1))
world.addObjectLine('KikiWireStone', KikiPos(0, 0, s.z-1), KikiPos(0, s.y-2, s.z-1))
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2, s.y-2, s.z/2))
world.addObjectAtPos('KikiBomb', KikiPos(s.x/2, s.y-2, s.z/2))
world.addObjectAtPos(KikiGenerator(KikiFace.PY), KikiPos(s.x/2, s.y/2, s.z/2))
world.addObjectAtPos(KikiWireStone(), KikiPos(1, s.y-2, 1))
world.addObjectAtPos(KikiWireStone(), KikiPos(s.x-2, s.y-2, 1))
world.addObjectAtPos(KikiWireStone(), KikiPos(1, s.y-2, s.z-2))
world.addObjectAtPos(KikiWireStone(), KikiPos(s.x-2, s.y-2, s.z-2))
world.addObjectAtPos(KikiWireStone(), KikiPos(s.x/2, s.y-1, s.z/2))
world.addObjectAtPos('KikiWireStone', KikiPos(1, s.y-2, 1))
world.addObjectAtPos('KikiWireStone', KikiPos(s.x-2, s.y-2, 1))
world.addObjectAtPos('KikiWireStone', KikiPos(1, s.y-2, s.z-2))
world.addObjectAtPos('KikiWireStone', KikiPos(s.x-2, s.y-2, s.z-2))
world.addObjectAtPos('KikiWireStone', KikiPos(s.x/2, s.y-1, s.z/2))
world.addObjectAtPos(KikiMotorGear(KikiFace.PY), KikiPos(s.x/2, 0, 0))
world.addObjectAtPos(KikiMotorCylinder(KikiFace.PY), KikiPos(s.x/2, 1, 0))

View File

@ -1,3 +1,10 @@
# 00000000 000 00000000 0000000 000000000 00000000 0000000
# 000 000 000 000 000 000 000 000 000
# 0000000 000 0000000 000 000 0000000 000 000
# 000 000 000 000 000 000 000 000 000
# 00000000 0000000 00000000 0000000 000 000 000 0000000
module.exports =
name: "electro"
scheme: "metal_scheme"
@ -26,10 +33,10 @@ module.exports =
s = world.size
d = 2
world.addObjectLine(KikiWireStone, world.decenter(-d, s.y/2, 0), world.decenter(-d, 0, 0))
world.addObjectLine(KikiWireStone, world.decenter( d, s.y/2, 0), world.decenter( d, 0, 0))
world.addObjectLine(KikiWireStone, world.decenter( d, 0, 0), world.decenter( 0, 0, 0))
world.addObjectLine(KikiWireStone, world.decenter(-d, 0, 0), world.decenter( 0, 0, 0))
world.addObjectLine('KikiWireStone', world.decenter(-d, s.y/2, 0), world.decenter(-d, 0, 0))
world.addObjectLine('KikiWireStone', world.decenter( d, s.y/2, 0), world.decenter( d, 0, 0))
world.addObjectLine('KikiWireStone', world.decenter( d, 0, 0), world.decenter( 0, 0, 0))
world.addObjectLine('KikiWireStone', world.decenter(-d, 0, 0), world.decenter( 0, 0, 0))
world.addObjectAtPos(KikiGear(KikiFace.PY), KikiPos(s.x/2-1, 0, s.z/2-1))
@ -38,24 +45,24 @@ module.exports =
world.addObjectAtPos(KikiMotorGear(KikiFace.PY), KikiPos(s.x/2, 0, s.z/2))
# floor wire square
world.addObjectLine("KikiWire(KikiFace.PY, 10)", KikiPos(s.x/2-d+1, 0, s.z/2-d), KikiPos(s.x/2+d, 0, s.z/2-d))
world.addObjectLine("KikiWire(KikiFace.PY, 10)", KikiPos(s.x/2-d+1, 0, s.z/2+d), KikiPos(s.x/2+d, 0, s.z/2+d))
world.addObjectLine("KikiWire(KikiFace.PY, 5)", KikiPos(s.x/2-d, 0, s.z/2-d+1), KikiPos(s.x/2-d, 0, s.z/2+d))
world.addObjectLine("KikiWire(KikiFace.PY, 5)", KikiPos(s.x/2+d, 0, s.z/2-d+1), KikiPos(s.x/2+d, 0, s.z/2+d))
world.addObjectLine(KikiWire(KikiFace.PY, 10), KikiPos(s.x/2-d+1, 0, s.z/2-d), KikiPos(s.x/2+d, 0, s.z/2-d))
world.addObjectLine(KikiWire(KikiFace.PY, 10), KikiPos(s.x/2-d+1, 0, s.z/2+d), KikiPos(s.x/2+d, 0, s.z/2+d))
world.addObjectLine(KikiWire(KikiFace.PY, 5), KikiPos(s.x/2-d, 0, s.z/2-d+1), KikiPos(s.x/2-d, 0, s.z/2+d))
world.addObjectLine(KikiWire(KikiFace.PY, 5), KikiPos(s.x/2+d, 0, s.z/2-d+1), KikiPos(s.x/2+d, 0, s.z/2+d))
# corners of wire square
world.addObjectAtPos(KikiWire(KikiFace.PY, 6), KikiPos(s.x/2-d, 0, s.z/2-d))
world.addObjectAtPos(KikiWire(KikiFace.PY, 3), KikiPos(s.x/2-d, 0, s.z/2+d))
world.addObjectAtPos(KikiWire(KikiFace.PY, 9), KikiPos(s.x/2+d, 0, s.z/2+d))
world.addObjectAtPos(KikiWire(KikiFace.PY, 12), KikiPos(s.x/2+d, 0, s.z/2-d))
world.addObjectLine("KikiWire(KikiFace.PX, 5)", KikiPos( 0, 0, s.z/2), KikiPos( 0, s.y, s.z/2))
world.addObjectLine("KikiWire(KikiFace.NX, 5)", KikiPos(s.x-1, 0, s.z/2), KikiPos(s.x-1, s.y, s.z/2))
world.addObjectLine("KikiWire(KikiFace.NY, 10)", KikiPos(0, s.y-1, s.z/2), KikiPos(s.x/2-d, s.y-1, s.z/2))
world.addObjectLine("KikiWire(KikiFace.NY, 10)", KikiPos(s.x-d, s.y-1, s.z/2), KikiPos(s.x, s.y-1, s.z/2))
world.addObjectLine("KikiWire(KikiFace.PY, 10)", KikiPos(0, 0, s.z/2), KikiPos(s.x/2-d, 0, s.z/2))
world.addObjectLine("KikiWire(KikiFace.PY, 10)", KikiPos(s.x-d, 0, s.z/2), KikiPos(s.x, 0, s.z/2))
world.addObjectLine(KikiWire(KikiFace.PX, 5), KikiPos( 0, 0, s.z/2), KikiPos( 0, s.y, s.z/2))
world.addObjectLine(KikiWire(KikiFace.NX, 5), KikiPos(s.x-1, 0, s.z/2), KikiPos(s.x-1, s.y, s.z/2))
world.addObjectLine(KikiWire(KikiFace.NY, 10), KikiPos(0, s.y-1, s.z/2), KikiPos(s.x/2-d, s.y-1, s.z/2))
world.addObjectLine(KikiWire(KikiFace.NY, 10), KikiPos(s.x-d, s.y-1, s.z/2), KikiPos(s.x, s.y-1, s.z/2))
world.addObjectLine(KikiWire(KikiFace.PY, 10), KikiPos(0, 0, s.z/2), KikiPos(s.x/2-d, 0, s.z/2))
world.addObjectLine(KikiWire(KikiFace.PY, 10), KikiPos(s.x-d, 0, s.z/2), KikiPos(s.x, 0, s.z/2))
world.addObjectAtPos(KikiWire(KikiFace.PY, 13), KikiPos(s.x/2-d, 0, s.z/2))
world.addObjectAtPos(KikiWire(KikiFace.PY, 7), KikiPos(s.x/2+d, 0, s.z/2))

View File

@ -28,22 +28,22 @@ module.exports =
s = world.size
world.addObjectAtPos(KikiMotorGear(KikiFace.NY), KikiPos(s.x/2-3, s.y-1, s.z/2))
world.addObjectAtPos(KikiMotorCylinder(KikiFace.NY), KikiPos(s.x/2-3, s.y-2, s.z/2))
world.addObjectAtPos(KikiGenerator (KikiFace.NY), KikiPos(s.x/2+2, 1, s.z/2-1))
world.addObjectAtPos(KikiGear(KikiFace.NY), KikiPos(s.x/2+1, 1, s.z/2+1))
world.addObjectAtPos(KikiGear(KikiFace.NY), KikiPos(s.x/2, 1, s.z/2-1))
world.addObjectAtPos(KikiGear(KikiFace.NY), KikiPos(s.x/2-1, 1, s.z/2+1))
world.addObjectAtPos(KikiGear(KikiFace.NY), KikiPos(s.x/2-2, 1, s.z/2-1))
world.addObjectAtPos(KikiMotorGear(KikiFace.NY), s.x/2-3, s.y-1, s.z/2)
world.addObjectAtPos(KikiMotorCylinder(KikiFace.NY), s.x/2-3, s.y-2, s.z/2)
world.addObjectAtPos(KikiGenerator (KikiFace.NY), s.x/2+2, 1, s.z/2-1)
world.addObjectAtPos(KikiGear(KikiFace.NY), s.x/2+1, 1, s.z/2+1)
world.addObjectAtPos(KikiGear(KikiFace.NY), s.x/2, 1, s.z/2-1)
world.addObjectAtPos(KikiGear(KikiFace.NY), s.x/2-1, 1, s.z/2+1)
world.addObjectAtPos(KikiGear(KikiFace.NY), s.x/2-2, 1, s.z/2-1)
world.addObjectLine("KikiWire (KikiFace.NY, KikiWire.VERTICAL)", KikiPos(s.x/2+2, s.y-1, 0), KikiPos(s.x/2+2, s.y-1, s.z))
world.addObjectLine("KikiWire (KikiFace.PY, KikiWire.VERTICAL)", KikiPos(s.x/2+2, 0, 0), KikiPos(s.x/2+2, 0, s.z))
world.addObjectLine("KikiWire (KikiFace.PZ, KikiWire.VERTICAL)", KikiPos(s.x/2+2, 0, 0), KikiPos(s.x/2+2, s.y, 0))
world.addObjectLine("KikiWire (KikiFace.NZ, KikiWire.VERTICAL)", KikiPos(s.x/2+2, 0, s.z-1), KikiPos(s.x/2+2, s.y, s.z-1))
world.addObjectLine(KikiWire(KikiFace.NY, KikiWire.VERTICAL), s.x/2+2, s.y-1, 0, s.x/2+2, s.y-1, s.z)
world.addObjectLine(KikiWire(KikiFace.PY, KikiWire.VERTICAL), s.x/2+2, 0, 0, s.x/2+2, 0, s.z)
world.addObjectLine(KikiWire(KikiFace.PZ, KikiWire.VERTICAL), s.x/2+2, 0, 0, s.x/2+2, s.y, 0)
world.addObjectLine(KikiWire(KikiFace.NZ, KikiWire.VERTICAL), s.x/2+2, 0, s.z-1, s.x/2+2, s.y, s.z-1)
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2+2, 0, s.z/2-1))
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2+1, 0, s.z/2+1))
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2, 0, s.z/2-1))
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2-1, 0, s.z/2+1))
world.addObjectAtPos(KikiBomb(), KikiPos(s.x/2-2, 0, s.z/2-1))
world.addObjectAtPos(KikiBomb(), s.x/2+2, 0, s.z/2-1)
world.addObjectAtPos(KikiBomb(), s.x/2+1, 0, s.z/2+1)
world.addObjectAtPos(KikiBomb(), s.x/2, 0, s.z/2-1)
world.addObjectAtPos(KikiBomb(), s.x/2-1, 0, s.z/2+1)
world.addObjectAtPos(KikiBomb(), s.x/2-2, 0, s.z/2-1)

View File

@ -22,18 +22,18 @@ module.exports =
s = world.size
world.addObjectLine(KikiWall, [0, s.y/2, s.z/2], [s.x, s.y/2, s.z/2])
world.addObjectLine(KikiWall, [s.x/2, s.y/2, 0], [s.x/2, s.y/2, s.z])
world.addObjectLine('KikiWall', [0, s.y/2, s.z/2], [s.x, s.y/2, s.z/2])
world.addObjectLine('KikiWall', [s.x/2, s.y/2, 0], [s.x/2, s.y/2, s.z])
world.deleteObject(world.getOccupantAtPos(world.decenter(0,0,0)))
world.addObjectAtPos(KikiWall(), world.decenter(0, 3, 0))
world.addObjectAtPos(KikiWall(), world.decenter(0, 6, 0))
world.addObjectAtPos('KikiWall', world.decenter(0, 3, 0))
world.addObjectAtPos('KikiWall', world.decenter(0, 6, 0))
world.addObjectAtPos(KikiWall(), world.decenter(0, -4, 0))
world.addObjectAtPos(KikiWall(), world.decenter( 2,-5, 1))
world.addObjectAtPos(KikiWall(), world.decenter(-1,-5, 2))
world.addObjectAtPos(KikiWall(), world.decenter(-2,-5,-1))
world.addObjectAtPos(KikiWall(), world.decenter( 1,-5,-2))
world.addObjectAtPos('KikiWall', world.decenter(0, -4, 0))
world.addObjectAtPos('KikiWall', world.decenter( 2,-5, 1))
world.addObjectAtPos('KikiWall', world.decenter(-1,-5, 2))
world.addObjectAtPos('KikiWall', world.decenter(-2,-5,-1))
world.addObjectAtPos('KikiWall', world.decenter( 1,-5,-2))
world.addObjectAtPos(KikiMutant(), world.decenter( 2,-5, 2))
world.addObjectAtPos(KikiMutant(), world.decenter(-2,-5,-2))

View File

@ -18,7 +18,7 @@ module.exports =
]
create: ->
s = world.size
for y in range(-s.y/2+3, s.y/2, 2)
for x in range(-s.x/2+1, s.x/2+1)
for z in range(-s.z/2+1, s.z/2+1)
world.addObjectAtPos(KikiStone(), world.decenter(x, y, z))
for y in [2,4,6,8]
for x in [0...3]
for z in [0...3]
world.addObjectAtPos('KikiStone', x, y, z)

View File

@ -1,3 +1,10 @@
# 00 00 0000000 000 000 00000000
# 000 000 000 000 000 000 000
# 000000000 000 000 000 000 0000000
# 000 0 000 000 000 000 000
# 000 000 0000000 0 00000000
module.exports =
name: "move"
scheme: "red_scheme"
@ -24,17 +31,17 @@ module.exports =
s = world.size
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2-1, s.y/2+1, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2+1, s.y/2+1, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2+1, s.y/2-1, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2-1, s.y/2-1, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2-1, s.y/2, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2+1, s.y/2, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2, s.y/2-1, 0))
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2, s.y/2+1, 0))
world.addObjectAtPos('KikiStone', s.x/2-1, s.y/2+1, 0)
world.addObjectAtPos('KikiStone', s.x/2+1, s.y/2+1, 0)
world.addObjectAtPos('KikiStone', s.x/2+1, s.y/2-1, 0)
world.addObjectAtPos('KikiStone', s.x/2-1, s.y/2-1, 0)
world.addObjectAtPos('KikiStone', s.x/2-1, s.y/2, 0)
world.addObjectAtPos('KikiStone', s.x/2+1, s.y/2, 0)
world.addObjectAtPos('KikiStone', s.x/2, s.y/2-1, 0)
world.addObjectAtPos('KikiStone', s.x/2, s.y/2+1, 0)
world.addObjectAtPos(KikiStone(), KikiPos(s.x/2, s.y/2, 1))
world.addObjectAtPos('KikiStone', s.x/2, s.y/2, 1)
exit_switch = KikiSwitch()
exit_switch.getEventWithName("switched").addAction(continuous(()-> world.toggle("exit")))
world.addObjectAtPos(exit_switch, KikiPos(s.x/2, s.y/2, 0))
# exit_switch = KikiSwitch()
# exit_switch.getEventWithName("switched").addAction(continuous(()-> world.toggle("exit")))
# world.addObjectAtPos(exit_switch, KikiPos(s.x/2, s.y/2, 0))

View File

@ -1,3 +1,10 @@
# 0000000 000000000 0000000 00000000 000000000
# 000 000 000 000 000 000 000
# 0000000 000 000000000 0000000 000
# 000 000 000 000 000 000 000
# 0000000 000 000 000 000 000 000
module.exports =
name: "start"
scheme: "default_scheme"

View File

@ -1,3 +1,10 @@
# 0000000 000000000 00000000 00000000 0000000
# 000 000 000 000 000 000
# 0000000 000 0000000 00000000 0000000
# 000 000 000 000 000
# 0000000 000 00000000 000 0000000
module.exports =
name: "steps"
scheme: "blue_scheme"
@ -23,8 +30,8 @@ module.exports =
]
create: ->
world.addObjectAtPos(KikiWall(), world.decenter(0,0,3))
world.addObjectAtPos(KikiWall(), world.decenter(0,-1,1))
world.addObjectAtPos(KikiWall(), world.decenter(0,-2,-1))
world.addObjectAtPos(KikiWall(), world.decenter(0,-3,-3))
world.addObjectAtPos('KikiWall', world.decenter(0,0,3))
world.addObjectAtPos('KikiWall', world.decenter(0,-1,1))
world.addObjectAtPos('KikiWall', world.decenter(0,-2,-1))
world.addObjectAtPos('KikiWall', world.decenter(0,-3,-3))

View File

@ -26,7 +26,7 @@ module.exports =
position: [0,0,0]
]
create: ->
world.addObjectAtPos( KikiWall(), world.decenter(-2,0,2))
world.addObjectAtPos( KikiStone(), world.decenter(0,1,3))
world.addObjectAtPos( KikiStone(), world.decenter(0,-1,3))
world.addObjectAtPos('KikiWall', world.decenter(-2,0,2))
world.addObjectAtPos('KikiStone', world.decenter(0,1,3))
world.addObjectAtPos('KikiStone', world.decenter(0,-1,3))

46
coffee/light.coffee Normal file
View File

@ -0,0 +1,46 @@
# 000 000 0000000 000 000 000000000
# 000 000 000 000 000 000
# 000 000 000 0000 000000000 000
# 000 000 000 000 000 000 000
# 0000000 000 0000000 000 000 000
Item = require './item'
class Light extends Item
constructor: (pos, radius) ->
@radius = radius ? 4.0
@setPosition pos if pos?
@setup()
# Controller.world->addObject @ if pos?
setup: ->
@halo_radius = 1.0
@quadratic_attenuation = 1.0/(@radius*@radius)
# @ambient_color = colors[KikiLight_base_color]
# @diffuse_color = colors[KikiLight_diffuse_color]
# @specular_color = colors[KikiLight_specular_color]
@initialize()
setPosition: (pos) ->
# KLight::setPosition (KVector(pos[X], pos[Y], pos[Z], 1.0))
super pos
display: () ->
# if (light_number == 0) return
#
# KLight::setPosition (KVector(position[X], position[Y], position[Z], 1.0));
#
# glDepthMask (false);
# glPushMatrix();
# colors[KikiLight_halo_color].glColor();
# position.glTranslate();
#
# KikiBillBoard::displayTextureWithSize
# (Controller.world->getTextureId (KikiWorld::TEXTURE_GRADIENT), 1.0);
# glPopMatrix();
# glDepthMask (true);
module.exports = Light

View File

@ -49,10 +49,6 @@ class Kiki extends Stage
@elem.style.display = 'none'
@pause()
resized: (w,h) ->
@aspect = w/h
@camera?.aspect = @aspect
@camera?.updateProjectionMatrix()
@renderer?.setSize w,h
resized: (w,h) -> @world.resized w, h
module.exports = Kiki

20
coffee/stone.coffee Normal file
View File

@ -0,0 +1,20 @@
# 0000000 000000000 0000000 000 000 00000000
# 000 000 000 000 0000 000 000
# 0000000 000 000 000 000 0 000 0000000
# 000 000 000 000 000 0000 000
# 0000000 000 0000000 000 000 00000000
Item = require './item'
class Stone extends Item
constructor: ->
@geom = new THREE.BoxGeometry 1,1,1
@mat = new THREE.MeshBasicMaterial color: 0x0000ff
@mesh = new THREE.Mesh @geom, @mat
world.scene.add @mesh
@mesh.matrixAutoUpdate = true
super
module.exports = Stone

View File

@ -12,12 +12,15 @@ class Wall extends Item
constructor: ->
@geom = new THREE.BoxGeometry 1,1,1
@mat = new THREE.MeshBasicMaterial color: 0x00ff00
@mat = new THREE.MeshBasicMaterial color: 0xff0000
@mesh = new THREE.Mesh @geom, @mat
world.scene.add @mesh
@mesh.matrixAutoUpdate = true
s = 0.45
d = 0.5
super
# glDisable(GL_LIGHTING);
# colors[KikiWall_base_color].glColor();
@ -29,42 +32,6 @@ class Wall extends Item
# glEnable(GL_LIGHTING);
# glBegin(GL_QUADS);
#
# glNormal3f (0.0, 0.0, 1.0);
# glVertex3f ( s, -s, d);
# glVertex3f ( s, s, d);
# glVertex3f (-s, s, d);
# glVertex3f (-s, -s, d);
# glNormal3f (0.0, 0.0, -1.0);
# glVertex3f (-s, -s, -d);
# glVertex3f (-s, s, -d);
# glVertex3f ( s, s, -d);
# glVertex3f ( s, -s, -d);
#
# glNormal3f (0.0, 1.0, 0.0);
# glVertex3f (-s, d, -s);
# glVertex3f (-s, d, s);
# glVertex3f ( s, d, s);
# glVertex3f ( s, d, -s);
# glNormal3f (0.0, -1.0, 0.0);
# glVertex3f ( s, -d, -s);
# glVertex3f ( s, -d, s);
# glVertex3f (-s, -d, s);
# glVertex3f (-s, -d, -s);
# glNormal3f (1.0, 0.0, 0.0);
# glVertex3f (d, s, -s);
# glVertex3f (d, s, s);
# glVertex3f (d, -s, s);
# glVertex3f (d, -s, -s);
# glNormal3f (-1.0, 0.0, 0.0);
# glVertex3f (-d, -s, -s);
# glVertex3f (-d, -s, s);
# glVertex3f (-d, s, s);
# glVertex3f (-d, s, -s);
# glEnd();
module.exports = Wall

View File

@ -9,6 +9,9 @@ first,
last
} = require "/Users/kodi/s/ko/js/tools/tools"
log = require "/Users/kodi/s/ko/js/tools/log"
Pos = require './lib/pos'
KikiCell = require './cell'
KikiLight = require './light'
KQuaternion = require './lib/quaternion'
KVector = require './lib/vector'
Pos = require './lib/pos'
@ -42,10 +45,10 @@ class KikiWorld
# 0000000 000 000 000 000 00000000 000 000 000 000
@fov = 60
@near = 10
@near = 0.1
@far = 1000
@aspect = @view.offsetWidth / @view.offsetHeight
@dist = 20
@dist = 10
@camera = new THREE.PerspectiveCamera @fov, @aspect, @near, @far
@camera.position.z = @dist
@ -132,9 +135,18 @@ class KikiWorld
global.rotx180 = KQuaternion.rotationAroundVector(180, KVector(1,0,0))
global.rotx90 = KQuaternion.rotationAroundVector(90, KVector(1,0,0))
# 000 00000000 000 000 00000000 000 0000000
# 000 000 000 000 000 000 000
# 000 0000000 000 000 0000000 000 0000000
# 000 000 000 000 000 000
# 0000000 00000000 0 00000000 0000000 0000000
@levelList = [
# intro
"start", "steps", "move", "electro", "elevate", "throw",
# "start",
#"steps",
#"move", "electro", "elevate",
# "throw",
# easy
"gold", "jump", "escape", "gears",
# "gamma",
@ -355,7 +367,13 @@ class KikiWorld
isValidPos: (pos) -> pos.x >= 0 and pos.x < @size.x and pos.y >= 0 and pos.y < @size.y and pos.z >= 0 and pos.z < @size.z
isInvalidPos: (pos) -> not @isValidPos pos
addObjectLine: (object, start, end) ->
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]
@ -519,6 +537,7 @@ class KikiWorld
return
cell = @getCellAtPos pos
log "world.setObjectAtPos", cell
if object.isSpaceEgoistic() and cell and cell.getOccupant()
objectAtNewPos = cell.getOccupant()
@ -532,10 +551,10 @@ class KikiWorld
objectAtNewPos.del() # temporary object at new pos will vanish anyway . delete it
cell = @getCellAtPos pos
if not cell?
cell = new KikiCell()
@cells[@posToIndex(pos)] = cell
log "world.setObjectAtPos new cell", cell
object.setPosition pos
cell.addObject object
@ -549,8 +568,8 @@ class KikiWorld
@cells[posToIndex(pos)] = null
newObject: (object) ->
log "newObject:", object
if _.isString object
log "newObject:", object
if object.startsWith 'Kiki'
return new (require "./#{object.slice(4).toLowerCase()}")()
object
@ -558,19 +577,21 @@ class KikiWorld
addObject: (object) ->
object = @newObject object
if object instanceof KikiLight
lights.push object # if lights.indexOf(object) < 0
@lights.push object # if lights.indexOf(object) < 0
else
objects.push object # if objects.indexOf(object) < 0
@objects.push object # if objects.indexOf(object) < 0
addObjectAtPos: (object, pos) ->
addObjectAtPos: (object, x, y, z) ->
pos = new Pos x, y, z
log "world.addObjectAtPos", pos
object = @newObject object
@setObjectAtPos object, pos
@addObject object
removeObject: (object) ->
@unsetObject object
_.pull lights, object
_.pull objects, object
_.pull @lights, object
_.pull @objects, object
moveObjectToPos: (object, pos) ->
return false if @isInvalidPos(pos) or @isOccupiedPos(pos)
@ -757,12 +778,22 @@ class KikiWorld
# 0000000 000 00000000 000
step: (step) ->
quat = @camera.quaternion.clone()
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(1,0,0), step.dsecs*0.2)
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(0,1,0), step.dsecs*0.1)
@camera.position.set(0,0,@dist).applyQuaternion quat
@camera.quaternion.copy quat
if true
quat = @camera.quaternion.clone()
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(1,0,0), step.dsecs*0.2)
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(0,1,0), step.dsecs*0.1)
center = @decenter 0,0,0
@camera.position.set(center.x,center.y,center.z+@dist).applyQuaternion quat
@camera.quaternion.copy quat
@sun.position.copy @camera.position
@renderer.render @scene, @camera
resized: (w,h) ->
# log "world.resized w:#{w} h:#{h}"
@aspect = w/h
@camera?.aspect = @aspect
@camera?.updateProjectionMatrix()
@renderer?.setSize w,h
module.exports = KikiWorld