From 1bca591dcf164f2895344b177662dd0bce8768e6 Mon Sep 17 00:00:00 2001 From: monsterkodi Date: Wed, 24 Aug 2016 02:12:32 +0200 Subject: [PATCH] levels --- coffee/camera.coffee | 2 +- coffee/cell.coffee | 4 +- coffee/item.coffee | 4 +- coffee/levels.coffee | 51 ++++++++++++------------- coffee/levels/blocks.coffee | 3 +- coffee/levels/bombs.coffee | 4 +- coffee/levels/edge.coffee | 11 ++++-- coffee/levels/electro.coffee | 4 +- coffee/levels/elevate.coffee | 4 +- coffee/levels/entropy.coffee | 2 +- coffee/levels/escape.coffee | 4 +- coffee/levels/gold.coffee | 4 +- coffee/levels/jump.coffee | 4 +- coffee/levels/love.coffee | 4 +- coffee/levels/move.coffee | 2 +- coffee/levels/plate.coffee | 9 ++--- coffee/levels/random.coffee | 6 +-- coffee/levels/switch.coffee | 10 ++--- coffee/lib/quaternion.coffee | 73 +++++++++++++++++------------------- coffee/scheme.coffee | 24 ++++++------ coffee/world.coffee | 14 ++++--- 21 files changed, 124 insertions(+), 119 deletions(-) diff --git a/coffee/camera.coffee b/coffee/camera.coffee index 117aa2e..149e74c 100644 --- a/coffee/camera.coffee +++ b/coffee/camera.coffee @@ -22,7 +22,7 @@ class Camera extends Matrix @fov = opt?.fov ? 90 @near = opt?.near ? 0.01 @eye_distance = @near - @far = opt?.far ? 20 + @far = opt?.far ? 30 @mode = Camera.BEHIND @aspect = opt.aspect ? -1 @dist = 10 diff --git a/coffee/cell.coffee b/coffee/cell.coffee index 9c00204..08ac773 100644 --- a/coffee/cell.coffee +++ b/coffee/cell.coffee @@ -23,14 +23,14 @@ class Cell removeObject: (object) -> # log "cell.removeObject #{object.name}", @objects.length for o in @objects - o.cellMateLeft object if o != object + o?.cellMateLeft object if o != object _.remove @objects, (o) -> o == object or o.object == object # log "cell.removeObject #{object.name}", @objects.length addObject: (object) -> # log "cell.addObject #{object.name}" for o in @objects - o.newCellMate object + o?.newCellMate object @objects.push object module.exports = Cell \ No newline at end of file diff --git a/coffee/item.coffee b/coffee/item.coffee index 32538d0..4d13be5 100644 --- a/coffee/item.coffee +++ b/coffee/item.coffee @@ -46,8 +46,8 @@ class Item extends Actor getPos: -> new Pos @current_position setPos: (x,y,z) -> - log "item.setPos #{@name} #{x} #{y} #{z}" - @setPosition newPos x,y,z + # log "item.setPos #{@name} #{x} #{y} #{z}" + @setPosition new Pos x,y,z setOrientation: (q) -> @current_orientation = @orientation = new Quaternion q diff --git a/coffee/levels.coffee b/coffee/levels.coffee index a102725..c2e2175 100644 --- a/coffee/levels.coffee +++ b/coffee/levels.coffee @@ -10,34 +10,33 @@ class Levels @dict = {} @list = [ # "test", - "start", # --- introduction - "steps", - "start", - "blocks", - "move", - "electro", - "elevate", - "throw", - # --- easy - "gold", - "jump", - "escape", - "gears", - "gamma", - "cube", - "switch", - "borg", - "mini", - "bombs", - "sandbox", - "energy", - "maze", - "love", + # "steps", + # "start", + # "blocks", + # "move", + # "electro", + # "elevate", + # "throw", + # # --- easy + # "gold", + # "jump", + # "escape", + # "gears", + # "gamma", + # "cube", + # "switch", + # # "borg", + # "mini", + # "bombs", + # "sandbox", + # "energy", + # "maze", + # "love", # --- medium - "towers", - "edge", - "random", + # "towers", + # "edge", + # "random", "plate", "nice", "entropy", diff --git a/coffee/levels/blocks.coffee b/coffee/levels/blocks.coffee index b98caf1..c40f49c 100644 --- a/coffee/levels/blocks.coffee +++ b/coffee/levels/blocks.coffee @@ -21,7 +21,8 @@ module.exports = the color of a stone has no meaning. """ player: - coordinates: [1,6,2] + coordinates: [4,4,0] + orientation: minusXupZ exits: [ name: "exit" active: 1 diff --git a/coffee/levels/bombs.coffee b/coffee/levels/bombs.coffee index e5894bb..9af12d7 100644 --- a/coffee/levels/bombs.coffee +++ b/coffee/levels/bombs.coffee @@ -16,7 +16,9 @@ module.exports = to get to the exit, use the bombs """ - player: position: [0,-4,0] + player: + coordinates: [4,0,4] + orientation: XupY exits: [ name: "exit" diff --git a/coffee/levels/edge.coffee b/coffee/levels/edge.coffee index 89cc3f6..2e35978 100644 --- a/coffee/levels/edge.coffee +++ b/coffee/levels/edge.coffee @@ -1,7 +1,13 @@ -# level design by Michael Abel + +# 00000000 0000000 0000000 00000000 +# 000 000 000 000 000 +# 0000000 000 000 000 0000 0000000 +# 000 000 000 000 000 000 +# 00000000 0000000 0000000 00000000 module.exports = name: "edge" + design: "Michael Abel" scheme: "candy" size: [7,7,7] help: "$scale(1.5)mission:\nget to the exit!" @@ -16,8 +22,7 @@ module.exports = ] create: -> s=world.size - Stone = require './stone' - # for (i,j,l) in [ (m,n,o) for m in range(3) for n in range(3) for o in range(3)] + {Stone} = require '../items' for i in [0...3] for j in [0...3] for l in [0...3] diff --git a/coffee/levels/electro.coffee b/coffee/levels/electro.coffee index d64d3bd..294356a 100644 --- a/coffee/levels/electro.coffee +++ b/coffee/levels/electro.coffee @@ -20,8 +20,8 @@ module.exports = with the motor """ player: - coordinates: [2,0,4] - orientation: rotz180 + coordinates: [2,3,5] + orientation: minusXupZ nostatus: 0 exits: [ name: "exit" diff --git a/coffee/levels/elevate.coffee b/coffee/levels/elevate.coffee index 73ee076..d1bdb49 100644 --- a/coffee/levels/elevate.coffee +++ b/coffee/levels/elevate.coffee @@ -24,7 +24,9 @@ module.exports = the bombs will detonate if you shoot them """ - player: position: [3,-2,0] + player: + coordinates: [8,0,3] + orientation: XupY exits: [ name: "exit" active: 0 diff --git a/coffee/levels/entropy.coffee b/coffee/levels/entropy.coffee index c4ef071..f2b4f4b 100644 --- a/coffee/levels/entropy.coffee +++ b/coffee/levels/entropy.coffee @@ -32,7 +32,7 @@ module.exports = # for (i,j,l) in [ (m,n,o) for m in range(s.x) for n in range(s.y) for o in range(s.z)] for i in [0...s.x] for j in [0...s.y] - for o in [0...s.z] + for l in [0...s.z] if Math.pow(-1, i+j+l)==1 and not (d<=i<=s.x-d-1 and d<=j<=s.y-d-1 and d<=l<=s.z-d-1) world.addObjectAtPos(new Stone(color:[0,0.8,0.2],opacity:0.8, slippery:true), i,j,l) diff --git a/coffee/levels/escape.coffee b/coffee/levels/escape.coffee index 73ac7eb..4e57164 100644 --- a/coffee/levels/escape.coffee +++ b/coffee/levels/escape.coffee @@ -24,8 +24,8 @@ module.exports = move the stones """ player: - position: [0,0,0] - orientation: rotx180 + coordinates: [3,8,4] + orientation: YupX exits: [ name: "exit" active: 0 diff --git a/coffee/levels/gold.coffee b/coffee/levels/gold.coffee index 74028e5..9c1017f 100644 --- a/coffee/levels/gold.coffee +++ b/coffee/levels/gold.coffee @@ -16,7 +16,9 @@ module.exports = move the stones to reach it """ player: - position: [0,-4,0] + coordinates: [1,0,0] + orientation: minusYupZ + exits: [ name: "exit" active: 1 diff --git a/coffee/levels/jump.coffee b/coffee/levels/jump.coffee index 458d973..847246e 100644 --- a/coffee/levels/jump.coffee +++ b/coffee/levels/jump.coffee @@ -19,8 +19,8 @@ module.exports = if you move into its direction """ player: - position: [0,0,5] - orientation: rotx270 + coordinates: [3,6,4] + orientation: minusZdownY exits: [ name: "exit" active: 1 diff --git a/coffee/levels/love.coffee b/coffee/levels/love.coffee index 60334d9..fd1780b 100644 --- a/coffee/levels/love.coffee +++ b/coffee/levels/love.coffee @@ -4,8 +4,8 @@ module.exports = size: [13,13,13] help: "$scale(1.5)mission:\nget to the exit!" player: - position: [0,1,-4] - orientation: rot0 + coordinates: [6,4,2] + orientation: minusZupY exits: [ name: "peace" active: 1 diff --git a/coffee/levels/move.coffee b/coffee/levels/move.coffee index e1f876c..1ade2ff 100644 --- a/coffee/levels/move.coffee +++ b/coffee/levels/move.coffee @@ -18,7 +18,7 @@ module.exports = to shoot, press "$key(shoot)" """ player: - coordinates: [3,3,5] + coordinates: [3,3,2] orientation: rotx90 nostatus: 0 exits: [ diff --git a/coffee/levels/plate.coffee b/coffee/levels/plate.coffee index ebfec94..3fda556 100644 --- a/coffee/levels/plate.coffee +++ b/coffee/levels/plate.coffee @@ -23,13 +23,12 @@ module.exports = ] create: -> - world.addObjectAtPos 'new Stone(color:[0.8,0.8,0.3],slippery:true', world.decenter(0,0,0) - - world.addObjectPoly 'new Stone(color:[0.6,0.6,0.6],slippery:true)', [world.decenter(1,1,0),world.decenter(1,-1,0), world.decenter(-1,-1,0),world.decenter(-1,1,0)], 1 - + {Stone} = require '../items' + world.addObjectAtPos new Stone(color:[0.8,0.8,0.3], slippery:true), world.decenter 0,0,0 + world.addObjectPoly 'new Stone({color:[0.6,0.6,0.6], slippery:true})', [world.decenter(1,1,0), world.decenter(1,-1,0), world.decenter(-1,-1,0), world.decenter(-1,1,0)] +# 'new Stone(color:[0.6,0.6,0.6], slippery:true)' world.addObjectAtPos 'Bomb', world.decenter 0,1,-4 world.addObjectAtPos 'Bomb', world.decenter 0,-1,-4 world.addObjectAtPos 'Bomb', world.decenter 1,0,-4 world.addObjectAtPos 'Bomb', world.decenter -1,0,-4 - world.addObjectAtPos 'Bomb', world.decenter 0,0,-2 diff --git a/coffee/levels/random.coffee b/coffee/levels/random.coffee index 9dd40d1..a1cd1fe 100644 --- a/coffee/levels/random.coffee +++ b/coffee/levels/random.coffee @@ -17,8 +17,8 @@ module.exports = jump and try """ player: - coordinates: [1,3,2] - nostatus: 0 + coordinates: [0,10,1] + orientation: minusZupX exits: [ name: "exit" active: 1 @@ -34,8 +34,6 @@ module.exports = world.addObjectAtPos('Wall', 19,18,2) world.addObjectAtPos('Wall', 19,2,18) world.addObjectAtPos('Wall', 19,18,18) - world.addObjectAtPos('Light', 0,0,0) - world.addObjectAtPos('Light', 20,20,20) world.addObjectAtPos('Stone', 3,2,6) world.addObjectAtPos('Stone', 5,2,6) world.addObjectAtPos('Stone', 12,4,6) diff --git a/coffee/levels/switch.coffee b/coffee/levels/switch.coffee index d3099aa..053285e 100644 --- a/coffee/levels/switch.coffee +++ b/coffee/levels/switch.coffee @@ -27,12 +27,12 @@ module.exports = the bomb will detonate if you shoot it """ player: - coordinates: [3,0,3] - nostatus: 0 + coordinates: [3,4,3] + orientation: minusZdownY exits: [ - name: "exit" - active: 0 - position: [0,-1,0] + name: "exit" + active: 0 + position: [0,-1,0] ] create: -> diff --git a/coffee/lib/quaternion.coffee b/coffee/lib/quaternion.coffee index 08d0e3b..8b3d913 100644 --- a/coffee/lib/quaternion.coffee +++ b/coffee/lib/quaternion.coffee @@ -150,11 +150,6 @@ class Quaternion length: -> Math.sqrt @w*@w + @x*@x + @y*@y + @z*@z eql: (q) -> @w==q.w and @x=q.x and @y==q.y and @z==q.z - # Quaternion & operator += ( float f ) { w += f; return(*this); } - # Quaternion & operator -= ( float f ) { w -= f; return(*this); } - # Quaternion & operator *= ( float f ) { w *= f; x *= f; y *= f; z *= f; return(*this); } - # Quaternion & operator /= ( float f ) { w /= f; x /= f; y /= f; z /= f; return(*this); } - mul: (quatOrScalar) -> if quatOrScalar instanceof Quaternion quat = quatOrScalar @@ -263,40 +258,40 @@ class Quaternion @minusZdownX = @rot_90_Z @minusZdownY = @rot_180_Z - @rot_0.name = '@rot_0' - @rot_90_X.name = '@rot_90_X' - @rot_90_Y.name = '@rot_90_Y' - @rot_90_Z.name = '@rot_90_Z' - @rot_180_X.name = '@rot_180_X' - @rot_180_Y.name = '@rot_180_Y' - @rot_180_Z.name = '@rot_180_Z' - @rot_270_X.name = '@rot_270_X' - @rot_270_Y.name = '@rot_270_Y' - @rot_270_Z.name = '@rot_270_Z' + @rot_0.name = 'rot_0' + @rot_90_X.name = 'rot_90_X' + @rot_90_Y.name = 'rot_90_Y' + @rot_90_Z.name = 'rot_90_Z' + @rot_180_X.name = 'rot_180_X' + @rot_180_Y.name = 'rot_180_Y' + @rot_180_Z.name = 'rot_180_Z' + @rot_270_X.name = 'rot_270_X' + @rot_270_Y.name = 'rot_270_Y' + @rot_270_Z.name = 'rot_270_Z' - @XupY.name = '@XupY' - @XupZ.name = '@XupZ' - @XdownY.name = '@XdownY' - @XdownZ.name = '@XdownZ' - @YupX.name = '@YupX' - @YupZ.name = '@YupZ' - @YdownX.name = '@YdownX' - @YdownZ.name = '@YdownZ' - @ZupX.name = '@ZupX' - @ZupY.name = '@ZupY' - @ZdownX.name = '@ZdownX' - @ZdownY.name = '@ZdownY' - @minusXupY.name = '@minusXupY' - @minusXupZ.name = '@minusXupZ' - @minusXdownY.name = '@minusXdownY' - @minusXdownZ.name = '@minusXdownZ' - @minusYupX.name = '@minusYupX' - @minusYupZ.name = '@minusYupZ' - @minusYdownX.name = '@minusYdownX' - @minusYdownZ.name = '@minusYdownZ' - @minusZupX.name = '@minusZupX' - @minusZupY.name = '@minusZupY' - @minusZdownX.name = '@minusZdownX' - @minusZdownY.name = '@minusZdownY' + @XupY.name = 'XupY' + @XupZ.name = 'XupZ' + @XdownY.name = 'XdownY' + @XdownZ.name = 'XdownZ' + @YupX.name = 'YupX' + @YupZ.name = 'YupZ' + @YdownX.name = 'YdownX' + @YdownZ.name = 'YdownZ' + @ZupX.name = 'ZupX' + @ZupY.name = 'ZupY' + @ZdownX.name = 'ZdownX' + @ZdownY.name = 'ZdownY' + @minusXupY.name = 'minusXupY' + @minusXupZ.name = 'minusXupZ' + @minusXdownY.name = 'minusXdownY' + @minusXdownZ.name = 'minusXdownZ' + @minusYupX.name = 'minusYupX' + @minusYupZ.name = 'minusYupZ' + @minusYdownX.name = 'minusYdownX' + @minusYdownZ.name = 'minusYdownZ' + @minusZupX.name = 'minusZupX' + @minusZupY.name = 'minusZupY' + @minusZdownX.name = 'minusZdownX' + @minusZdownY.name = 'minusZdownY' module.exports = Quaternion \ No newline at end of file diff --git a/coffee/scheme.coffee b/coffee/scheme.coffee index 5ccaf25..3b94423 100644 --- a/coffee/scheme.coffee +++ b/coffee/scheme.coffee @@ -175,8 +175,8 @@ module.exports = candy: plate: color: rgb 0.8, 0, 0.9 - bulb: - color: rgb 0, 0, 0 + bulb: + color: rgb 1, 1, 1 text: color: rgb 0.7, 0, 0.7 bright: rgb 1, 0, 1 @@ -294,7 +294,7 @@ module.exports = plate: color: rgb 0.1, 0.1, 0.6 bulb: - color: rgb 0.1, 0.1, 0.1 + color: rgb 0.6, 0.6, 1 stone: color: rgb 0, 0, 0.5 opacity: 0.6 @@ -334,16 +334,18 @@ module.exports = plate: color: rgb 0.9, 0.9, 0 bulb: - color: rgb 0, 0, 0 + color: rgb 1, 1, 1 + glow: + color: rgb 1, 1, 1 bomb: color: rgb 0.75, 0.75, 0 stone: color: rgb 0.8, 0.85, 0 - opacity: 0.6 + opacity: 0.6 switch: color: rgb 0.8, 0.8, 0 gate: - color: rgb 1, 1, 0, 0.8 + color: rgb 1, 1, 0 player: color: rgb 0.7, 0.7, 0 tire: @@ -356,8 +358,6 @@ module.exports = color: rgb 0.7, 0.5, 0 wire: color: rgb 1, 1, 0 - glow: - color: rgb 0, 0, 1 text: color: rgb 0.7, 0.7, 0 bright: rgb 1, 1, 0 @@ -373,7 +373,7 @@ module.exports = plate: color: rgb 0.1, 0.6, 0.1 bulb: - color: rgb 0, 0, 0 + color: rgb 0.3, 1, 0.3 stone: color: rgb 0, 0.5, 0 switch: @@ -448,12 +448,12 @@ module.exports = crazy: raster: - color: rgb 0.84, 0.22, 0.20 + color: rgb 0.84, 0.22, 0.20 bulb: color: rgb 0, 0, 0 stone: color: rgb 1, 1, 1 - stone: 0.2 + stone: 0.2 switch: color: rgb 0.9, 1, 0.9 gate: @@ -490,7 +490,7 @@ module.exports = plate: color: rgb 0.36, 0.45, 0.30 bulb: - color: rgb 0, 0, 0 + color: rgb 0.8, 0.8, 0.8 stone: color: rgb 0.36, 0.45, 0.30 opacity: 0.7 diff --git a/coffee/world.coffee b/coffee/world.coffee index 90a6ce7..41ab89d 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -37,6 +37,7 @@ now = require 'performance-now' { Wire, Gear, +Stone, MotorGear, MotorCylinder, Face} = require './items' @@ -173,7 +174,6 @@ class World extends Actor # 0000000 000 000 00000000 000 000 000 00000000 create: (worldDict={}) -> # creates the world from a level name or a dictionary - # log "world.create", worldDict if worldDict @@ -185,10 +185,10 @@ class World extends Actor @dict = worldDict @level_index = World.levels.list.indexOf @level_name - log "World.create #{@level_index} #{@level_name}" + log "World.create #{@level_index} ---------------------- #{@level_name}" + + @creating = true - # ............................................................ appearance - @setSize @dict["size"] # this removes all objects @applyScheme @dict.scheme ? 'default' @@ -250,7 +250,9 @@ class World extends Actor else if @dict.player.coordinates? @addObjectAtPos @player, new Pos @dict.player.coordinates - @player.camera.setPosition new Vector 0,0,0 + # @player.camera.setPosition new Vector 0,0,0 + @player.camera.setPosition @player.currentPos() + @creating = false restart: () -> @create @dict @@ -878,7 +880,7 @@ class World extends Actor for light in @lights lignt.display() - playSound: (sound, pos, time) -> Sound.play sound, pos, time + playSound: (sound, pos, time) -> Sound.play sound, pos, time if not @creating # 000 000 00000000 000 000 # 000 000 000 000 000