From c5e105e9eeddd9ee69b4c7e64b9de3f464f65343 Mon Sep 17 00:00:00 2001 From: monsterkodi Date: Tue, 9 Aug 2016 01:23:44 +0200 Subject: [PATCH] world --- .gitignore | 2 + coffee/cell.coffee | 28 +++ coffee/lib/KQuaternion.h | 148 --------------- coffee/lib/class.coffee | 12 -- coffee/lib/pos.coffee | 42 +++++ coffee/main.coffee | 2 +- coffee/world.coffee | 387 +++++++++++++++++++++++++++++++++++---- package.noon | 9 + 8 files changed, 430 insertions(+), 200 deletions(-) create mode 100644 coffee/cell.coffee delete mode 100755 coffee/lib/KQuaternion.h delete mode 100644 coffee/lib/class.coffee create mode 100644 coffee/lib/pos.coffee create mode 100644 package.noon diff --git a/.gitignore b/.gitignore index 7b4dcb5..5fad1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ js +node_modules +package.json diff --git a/coffee/cell.coffee b/coffee/cell.coffee new file mode 100644 index 0000000..6011a38 --- /dev/null +++ b/coffee/cell.coffee @@ -0,0 +1,28 @@ + +# 0000000 00000000 000 000 +# 000 000 000 000 +# 000 0000000 000 000 +# 000 000 000 000 +# 0000000 00000000 0000000 0000000 + +class Cell + + constructor: () -> + + getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss + getObjectOfType: (clss) -> _.find @objects, (o) -> o instanceof clss + + getRealObjectOfType: (clss) -> _.find @objects, (o) -> o instanceof clss or o instanceof KikiTmpObject and o.object instanceof clss + getOccupant: -> _.find @objects, (o) -> o.isSpaceEgoistic() + + removeObject: (object) -> + for o in @objects + o.cellMateLeft object if o != object + _.pull @objects, object + + addObject: (object) -> + for o in @objects + o.newCellMate object + @objects.push object + +module.exports = Cell \ No newline at end of file diff --git a/coffee/lib/KQuaternion.h b/coffee/lib/KQuaternion.h deleted file mode 100755 index 51f4506..0000000 --- a/coffee/lib/KQuaternion.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * KQuaternion.h - * kodisein - */ - -#ifndef __KQuaternion -#define __KQuaternion - -#include "KVector.h" -#include "KMatrix.h" - -#include - -// -------------------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------------------- -class KQuaternion -{ - public: - - float w, x, y, z; - - KQuaternion ( float _w = 1.0, float _x = 0.0, float _y = 0.0, float _z = 0.0 ) - { - w = _w; x = _x; y = _y; z = _z; - } - - KQuaternion ( const KQuaternion & q ) { w = q.w; x = q.x; y = q.y; z = q.z; } - KQuaternion ( const KVector & v ) { w = 0.0; x = v[X]; y = v[Y]; z = v[Z]; } - - static KQuaternion rotationAroundVector ( float theta, const KVector & vector ) - { - KVector v(vector); - v.normalize(); - float t = DEG2RAD(theta)/2.0; - float s = sin(t); - return KQuaternion(cos(t), v[X]*s, v[Y]*s, v[Z]*s).normalize(); - } - - KVector rotate ( const KVector & v ) const - { - KQuaternion result = (*this) * KQuaternion(v) * this->getConjugate(); - return KVector(result.x, result.y, result.z); - } - - KQuaternion & normalize () - { - float l = sqrt(w*w + x*x + y*y + z*z); - if (l != 0.0) - { - w /= l; x /= l; y /= l; z /= l; - } - return (*this); - } - - KQuaternion & invert () - { - float l = sqrt(w*w + x*x + y*y + z*z); - if (l != 0.0) - { - w /= l; x = -x/l; y = -y/l; z = -z/l; - } - return (*this); - } - - void reset () { w=1.0; x=y=z=0.0; } - KQuaternion & conjugate () { x = -x; y = -y; z = -z; return (*this); } - KQuaternion getNormal () const { return KQuaternion(*this).normalize(); } - KQuaternion getConjugate () const { return KQuaternion(*this).conjugate(); } - KQuaternion getInverse () const { return KQuaternion(*this).invert(); } - float length () const { return sqrt(w*w + x*x + y*y + z*z); } - void glRotate () const { KMatrix(*this).glMultMatrix(); } - - KQuaternion slerp ( const KQuaternion & quat, float t ) const; - - operator KVector() const { return KVector(x, y, z); } - KQuaternion & operator += ( float f ) { w += f; return(*this); } - KQuaternion & operator -= ( float f ) { w -= f; return(*this); } - KQuaternion & operator *= ( float f ) { w *= f; x *= f; y *= f; z *= f; return(*this); } - KQuaternion & operator /= ( float f ) { w /= f; x /= f; y /= f; z /= f; return(*this); } - - KQuaternion & operator += ( const KQuaternion & quat ) - { - w += quat.w; x += quat.x; y += quat.y; z += quat.z; - return (*this); - } - - KQuaternion & operator -= ( const KQuaternion & quat ) - { - w -= quat.w; x -= quat.x; y -= quat.y; z -= quat.z; - return (*this); - } - - KQuaternion & operator *= ( const KQuaternion & quat ) - { - float A, B, C, D, E, F, G, H; - - A = (w + x)*(quat.w + quat.x); - B = (z - y)*(quat.y - quat.z); - C = (w - x)*(quat.y + quat.z); - D = (y + z)*(quat.w - quat.x); - E = (x + z)*(quat.x + quat.y); - F = (x - z)*(quat.x - quat.y); - G = (w + y)*(quat.w - quat.z); - H = (w - y)*(quat.w + quat.z); - - w = B +(-E - F + G + H)/2; - x = A - (E + F + G + H)/2; - y = C + (E - F + G - H)/2; - z = D + (E - F - G + H)/2; - - return (*this); - } - - KQuaternion operator * ( const KQuaternion & quat ) const - { - return (KQuaternion(*this) *= quat); - } -}; - -// -------------------------------------------------------------------------------------------------------- -inline KQuaternion operator - (const KQuaternion & q) -{ - return KQuaternion(-q.w,-q.x,-q.y,-q.z); -} - -// -------------------------------------------------------------------------------------------------------- -inline KQuaternion operator * ( float f, const KQuaternion & quat ) -{ - KQuaternion result(quat); - result *= f; - return result; -} - -// -------------------------------------------------------------------------------------------------------- -inline bool operator == (const KQuaternion & lquat, const KQuaternion & rquat) -{ - return ((rquat.w == lquat.w) && (rquat.x == lquat.x) && - (rquat.y == lquat.y) && (rquat.z == lquat.z)); -} - -// -------------------------------------------------------------------------------------------------------- -inline bool operator != (const KQuaternion & lquat, const KQuaternion & rquat) -{ - return(!(lquat == rquat)); -} - -#endif - diff --git a/coffee/lib/class.coffee b/coffee/lib/class.coffee deleted file mode 100644 index 207ba64..0000000 --- a/coffee/lib/class.coffee +++ /dev/null @@ -1,12 +0,0 @@ -# 0000000 000 0000000 0000000 0000000 -# 000 000 000 000 000 000 -# 000 000 000000000 0000000 0000000 -# 000 000 000 000 000 000 -# 0000000 0000000 000 000 0000000 0000000 - -class Class - - constructor: () -> - - -module.exports = Class diff --git a/coffee/lib/pos.coffee b/coffee/lib/pos.coffee new file mode 100644 index 0000000..da3ebd8 --- /dev/null +++ b/coffee/lib/pos.coffee @@ -0,0 +1,42 @@ + +# 00000000 0000000 0000000 +# 000 000 000 000 000 +# 00000000 000 000 0000000 +# 000 000 000 000 +# 000 0000000 0000000 + +Vector = require './vector' + +class Pos + + constructor: (x=0, y=0, z=0) -> + + if x instanceof Vector or x instanceof Pos + @x = parseInt x.x + @y = parseInt x.y + @z = parseInt x.z + else if Array.isArray x + [@x, @y, @z] = x + else + @x = parseInt x + @y = parseInt y + @z = parseInt z + + vector: () -> new Vector(x, y, z) + minus: (p) -> new Pos @x-px, @y-py, @z-p.z + plus: (p) -> new Pos @x+px, @y+py, @z+p.z + eql: (p) -> @x==p.x and @y==p.y and @z==p.z + + add: (p) -> + @x += p.x + @y += p.y + @z += p.z + @ + + sub: (p) -> + @x -= p.x + @y -= p.y + @z -= p.z + @ + +module.exports = Pos diff --git a/coffee/main.coffee b/coffee/main.coffee index 7315946..b4ad327 100644 --- a/coffee/main.coffee +++ b/coffee/main.coffee @@ -83,7 +83,7 @@ class Kiki extends Stage # @mesh = new THREE.Mesh @geom, @material # @scene.add @mesh - world = new KikiWorld() + world = KikiWorld.init() log 'hello world' @animate() diff --git a/coffee/world.coffee b/coffee/world.coffee index c1c21f4..9fcb5c6 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -1,20 +1,69 @@ +# 000 000 0000000 00000000 000 0000000 +# 000 0 000 000 000 000 000 000 000 000 +# 000000000 000 000 0000000 000 000 000 +# 000 000 000 000 000 000 000 000 000 +# 00 00 0000000 000 000 0000000 0000000 +{ +first, +last +} = require "/Users/kodi/s/ko/js/tools/tools" log = require "/Users/kodi/s/ko/js/tools/log" KQuaternion = require './lib/quaternion' KVector = require './lib/vector' +Pos = require './lib/pos' +_ = require 'lodash' + +world = null class KikiWorld + + @CAMERA_INSIDE = 0 + @CAMERA_BEHIND = 1 + @CAMERA_FOLLOW = 2 + + @levelList = [] + @levelDict = [] constructor: -> + @preview = false - # execfile(kikipy_path + "colors.py") - # execfile(kikipy_path + "action.py") - # execfile(kikipy_path + "lang.py") - # execfile (kikipy_path + "config.py") - # execfile (kikipy_path + "setup.py") - # execfile (kikipy_path + "levelselection.py") - # execfile (kikipy_path + "highscore.py") - # execfile (kikipy_path + "intro.py") + @display_list = 0 + @objects = [] + @lights = [] + @moved_objects = [] + @cells = [] + @size = new Pos() + @depth = -Number.MAX_SAFE_INTEGER + @camera_mode = KikiWorld.CAMERA_BEHIND + @edit_projection = null + @edit_mode = false + @debug_camera = false + @debug_cells = false + + # flags[KDL_PICKHANDLER_FLAG_MOVING_ENABLED] = true + # flags[KDL_PICKHANDLER_FLAG_PROJECTION_ENABLED] = true + + # flags.resize(WORLD_END) + # flags[DISPLAY_BORDER] = true + # flags[DISPLAY_DOTS] = false + # flags[DISPLAY_RASTER] = true + # flags[DISPLAY_SHADOWS] = false + + @raster_size = 0.1 + + # KEventHandler::notification_center.addReceiverCallback((KPickHandler*)this, + # (KCallbackPtr)&KikiWorld::reinit, + # KDL_NOTIFICATION_TYPE_VIDEO_MODE_CHANGED) +# + # KEventHandler::notification_center.addReceiverCallback((KPickHandler*)this, + # (KCallbackPtr)&KikiWorld::reinit, + # KDL_NOTIFICATION_TYPE_WINDOW_SIZE_CHANGED) + + # initializeTextures () + + @init: -> + return if world? global.rot0 = new KQuaternion() global.rotz180 = KQuaternion.rotationAroundVector(180, KVector(0,0,1)) @@ -63,7 +112,10 @@ class KikiWorld @levelDict[levelName] = require "./levels/#{levelName}" log 'levelDict', @levelDict - @preview = false + + world = new KikiWorld() + world.create first @levelList + world # 0000000 00000000 00000000 0000000 000000000 00000000 # 000 000 000 000 000 000 000 000 @@ -77,27 +129,27 @@ class KikiWorld if worldDict if _.isString worldDict - world.level_index = levelList.index worldDict + world.level_index = KikiWorld.levelList.indexOf worldDict world.level_name = worldDict - @dict = levelDict[worldDict] + @dict = KikiWorld.levelDict[worldDict] else @dict = worldDict # ............................................................ appearance - world.setSize @dict["size"] + @setSize @dict["size"] if "scheme" in @dict - applyColorScheme eval(@dict["scheme"]) + @applyColorScheme eval(@dict["scheme"]) else - applyColorScheme default_scheme + @applyColorScheme default_scheme if "border" in @dict border = @dict["border"] else border = 1 - world.setDisplayBorder border + @setDisplayBorder border # ............................................................ intro text if "intro" in @dict @@ -105,19 +157,19 @@ class KikiWorld intro_text = KikiScreenText() intro_text.addText @dict["intro"] intro_text.show() - world.setName @dict["intro"] + @setName @dict["intro"] else - world.setName "noname" + @setName "noname" if @preview - world.getProjection().setViewport(0.0, 0.4, 1.0, 0.6) + @getProjection().setViewport(0.0, 0.4, 1.0, 0.6) else - world.getProjection().setViewport(0.0, 0.0, 1.0, 1.0) + @getProjection().setViewport(0.0, 0.0, 1.0, 1.0) # ............................................................ escape - escape_event = Controller.getEventWithName ("escape") - escape_event.removeAllActions() - escape_event.addAction(continuous(@escape, "escape")) + # escape_event = Controller.getEventWithName ("escape") + # escape_event.removeAllActions() + # escape_event.addAction(continuous(@escape, "escape")) # ............................................................ exits @@ -136,10 +188,10 @@ class KikiWorld delay_action = once (lambda a = exit_action: Controller.timer_event.addAction (a)) exit_gate.getEventWithName ("enter").addAction (delay_action) if "position" in entry - pos = world.decenter (entry["position"]) + pos = @decenter (entry["position"]) else if "coordinates" in entry - pos = KikiPos entry["coordinates"] - world.addObjectAtPos exit_gate, pos + pos = new Pos entry["coordinates"] + @addObjectAtPos exit_gate, pos exit_id += 1 # ............................................................ creation @@ -162,10 +214,10 @@ class KikiWorld player.setOrientation (roty90) if "position" in player_dict - world.addObjectAtPos player, world.decenter(player_dict["position"]) + @addObjectAtPos player, @decenter(player_dict["position"]) else if "coordinates" in player_dict pos = player_dict["coordinates"] - world.addObjectAtPos player, KikiPos(pos[0], pos[1], pos[2]) + @addObjectAtPos player, Pos(pos[0], pos[1], pos[2]) if "nostatus" in player_dict if player_dict["nostatus"] or @preview @@ -178,13 +230,13 @@ class KikiWorld else Controller.player_status.show() - world.getProjection().setPosition (KVector()) + @getProjection().setPosition(KVector()) - Controller.player.getStatus().setMinMoves (highscore.levelParMoves (world.level_name)) + Controller.player.getStatus().setMinMoves (highscore.levelParMoves (@level_name)) Controller.player.getStatus().setMoves (0) # ............................................................ init - world.init() # tell the world that we are finished + @init() # tell the world that we are finished restart: (self) -> # restores the player status and restarts the current level @@ -245,14 +297,14 @@ class KikiWorld else if len(args) == 1 [x, y, z] = args[0] - return KikiPos(x+s.x/2, y+s.y/2, z+s.z/2) + new Pos x+s.x/2, y+s.y/2, z+s.z/2 addObjectLine: (object, start, end) -> - # adds a line of objects of type to the world. start and end should be 3-tuples or KikiPos objects - if start instanceof KikiPos + # 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 isinstance KikiPos + if end instanceof Pos end = [end.x, end.y, end.z] [ex, ey, ez] = end @@ -260,8 +312,8 @@ class KikiWorld maxdiff = _.max diff.map Math.abs deltas = diff.map (a) -> a/maxdiff for i in [0...maxdiff] - # pos = apply(KikiPos, (map (lambda a, b: int(a+i*b), start, deltas))) - pos = KikiPos (start[j]+i*deltas[j] for j in [0..2]) + # 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 @@ -269,7 +321,7 @@ class KikiWorld @addObjectAtPos object(), pos addObjectPoly: (object, points, close=1) -> - # adds a polygon of objects of type to the world. points should be 3-tuples or KikiPos objects + # 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)) @@ -288,7 +340,7 @@ class KikiWorld size = @getSize() object_set = 0 while not object_set # hack alert! - random_pos = KikiPos random.randrange(size.x), + random_pos = Pos random.randrange(size.x), random.randrange(size.y), random.randrange(size.z) if not object.isSpaceEgoistic() or @isUnoccupiedPos(random_pos) @@ -375,5 +427,262 @@ class KikiWorld menu.addItem(Controller.getLocalizedString("setup"), once(quickSetup)) menu.addItem(Controller.getLocalizedString("about"), once(display_about)) menu.addItem(Controller.getLocalizedString("quit"), once(Controller.quit)) - + + setSize: (x, y, z) -> + @deleteAllObjects() + @deleteDisplayList() + @cells = [] + + @size.x = x + @size.y = y + @size.z = z + + @cells.resize x*y*z, 0 + + # .......................................... calcuate max distance (for position relative sound) + @max_distance = Math.Max(x, Math.Max(y, z)) # ............................. heuristic of a heuristic :-) + + getCellAtPos: (pos) -> return @cells[@posToIndex(pos)] if @isValidPos pos + getBotAtPos: (pos) -> @getObjectOfTypeAtPos KikiBot, pos + + getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss + getObjectsOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getObjectsOfType clss + getObjectOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getRealObjectOfType clss + getOccupantAtPos: (pos) -> @getCellAtPos(pos)?.getOccupant() + getRealOccupantAtPos: (pos) -> + occupant = @getOccupantAtPos pos + if occupant and occupant instanceof KikiTmpObject + occupant.object + else + occupant + + setObjectAtPos: (object, pos) -> + if @isInvalidPos pos + log "KikiWorld.setObjectAtPos invalid pos:", pos + return + + cell = @getCellAtPos pos + + if object.isSpaceEgoistic() and cell and cell.getOccupant() + objectAtNewPos = cell.getOccupant() + if objectAtNewPos instanceof KikiTmpObject + if objectAtNewPos.time > 0 + log "WARNING KikiWorld.setObject already occupied pos:", pos + # "already occupied by %s with time %d!", + # object.getClassName(), pos.x, pos.y, pos.z, + # cell.getOccupant().getClassName(), + # ((KikiTmpObject*)objectAtNewPos).time) + 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 + + object.setPosition pos + cell.addObject object + + unsetObject: (object) -> + pos = object.getPos() + if cell = @getCellAtPos pos + cell.removeObject object + if cell.isEmpty() + # delete cell + @cells[posToIndex(pos)] = null + + addObject: (object) -> + if object instanceof KikiLight + lights.push object # if lights.indexOf(object) < 0 + else + objects.push object # if objects.indexOf(object) < 0 + + addObjectAtPos: (object, pos) -> + @setObjectAtPos object, pos + @addObject object + + removeObject: (object) -> + @unsetObject object + _.pull lights, object + _.pull objects, object + + moveObjectToPos: (object, pos) -> + return false if @isInvalidPos(pos) or @isOccupiedPos(pos) + + @unsetObject object + @setObjectAtPos object, pos + + # Controller.sound.playSound(KikiSound::BOT_LAND) + + true + + deleteObject: (object) -> + if not object? + log "WARNING: KikiWorld.deleteObject null" + return + @removeObject object + object.del() + + deleteAllObjects: () -> + @picked_pickable = null + @moved_objects = [] + + # if Controller.player + # Controller.player.finishRotateAction() + # @removeObject (Controller.player) # remove the player first, to keep it's state + # Controller.timer_event.removeAllActions () + # Controller.removeKeyHandler (Controller.player) # prevent keyboard input while building world + # Controller.player.reset () + + while @lights.length + oldSize = @lights.length + last(@lights).del() # destructor will call remove object + if oldSize == @lights.length + log "WARNING KikiWorld.deleteAllObjects light no auto remove" + @lights.pop() + + while @objects.length + oldSize = @objects.length + last(@objects).del() # destructor will call remove object + if oldSize == @objects.length + log "WARNING KikiWorld.deleteAllObjects object no auto remove" + @objects.pop() + + deleteObjectsWithClassName: (className) -> + for o in _.clone @objects + if className == o.getClassName() + o.del() + + getObjectWithName: (objectName) -> + for o in @objects + if objectName == o.getName() + return o + log "KikiWorld.getObjectWithName :: no object found with name #{objectName}" + null + + setEditMode: (editMode) -> + @edit_mode = editMode + + if @edit_mode and @edit_projection == null + edit_projection = new KLightingProjection() + + @edit_projection.focusOn KVector(@size).mul 2.0 + @edit_projection.setEyeDistance @max_distance*1.5 + + # focusOnPickedPickable: ( bool zoom ) -> + # if (edit_mode and picked_pickable) + # projection.focusOn (((KikiObject*)picked_pickable).getPosition()) + + setCameraMode: (mode) -> @camera_mode = clamp CAMERA_INSIDE, CAMERA_FOLLOW, mode + + changeCameraMode: () -> @camera_mode = (@camera_mode+1) % (CAMERA_FOLLOW+1) + + # shouldPick: () -> @edit_mode +# + # picked: () -> # reset drag deltas and start pos + # @deltas.x = @deltas.y = 0 + # if @picked_pickable + # @drag_start_pos = ((KikiObject*)picked_pickable).position +# + # moved: ( const KMouseEvent & mouseEvent ) -> + # object = (KikiObject*)picked_pickable +# + # if (object == null) return +# + # KVector newPosition = drag_start_pos +# + # deltas = deltas + mouseEvent.delta +# + # getProjection().moveObjectRelativeToWindow(deltas, newPosition) +# + # # round to next integer positions and make a valid pos + # Pos newPos = getNearestValidPos(newPosition) +# + # if (getOccupantAtPos(newPos) == null and (newPos != object.getPos())) + # empty position != old position . move object + # moveObjectToPos(object, newPos) + + objectMovedFromPos: (object, pos) -> + + if cell = @getCellAtPos(pos) + if tmpObject = cell.getObjectOfType KikiTmpObject + if tmpObject.object == object + tmpObject.del() + @moved_objects.push object + + objectWillMoveToPos: (object, pos, duration) -> + cell = @getCellAtPos pos + + if @isInvalidPos pos + log "KikiWorld::objectWillMoveToPos invalid pos:", pos + + if object.getPos() == pos + log "WARNING KikiWorld::objectWillMoveToPos equal pos:", pos + return + + if cell + if objectAtNewPos = cell.getOccupant() + if objectAtNewPos instanceof KikiTmpObject + tmpObject = objectAtNewPos + + if (objectAtNewPos.time < 0 and -objectAtNewPos.time <= duration) + # temporary object at new pos will vanish before object will arrive . delete it + objectAtNewPos.del() + else + log "KikiWorld.objectWillMoveToPos timing conflict at pos:", pos + else + log "KikiWorld.objectWillMoveToPos already occupied:", pos + + @unsetObject object # remove object from cell grid + + tmpObject = new KikiTmpObject object # insert temporary objects at new pos + tmpObject.setPosition pos + tmpObject.time = duration + @addObjectAtPos tmpObject, pos + + tmpObject = new KikiTmpObject object # insert temporary objects at old pos + tmpObject.setPosition object.getPosition() + tmpObject.time = -duration + @addObjectAtPos tmpObject, object.getPos() + + # -------------------------------------------------------------------------------------------------------- + updateStatus: () -> + # glClearColor(colors[KikiWorld_base_color][R], colors[KikiWorld_base_color][G], + # colors[KikiWorld_base_color][B], colors[KikiWorld_base_color][A]) + + while @moved_objects.length + movedObject = last @moved_objects + pos = new Pos movedObject.position + + if @isInvalidPos pos + log "KikiWorld.updateStatus invalid new pos" + return + + if tmpObject = @getObjectOfTypeAtPos KikiTmpObject, pos + if tmpObject.object == movedObject + tmpObject.del() + else + log "KikiWorld.updateStatus wrong tmp object at pos:", pos + else if @isOccupiedPos pos + log "KikiWorld.updateStatus object moved to occupied pos:", pos + + @setObjectAtPos movedObject, pos + @moved_objects.pop() + + deleteDisplayList: () -> + if @display_list + glDeleteLists(@display_list, 1) + @display_list = 0 + + setObjectColor: (color_name, color) -> + if color_name == 'base' + # KikiWall::setObjectColor "base", color + @colors[0] = color + else if color_name == 'plate' + # KikiWall::setObjectColor "plate", color + @colors[1] = color + + # Controller.world.deleteDisplayList () + + module.exports = KikiWorld diff --git a/package.noon b/package.noon new file mode 100644 index 0000000..855e594 --- /dev/null +++ b/package.noon @@ -0,0 +1,9 @@ +name kiki +main js/main.js +dependencies + coffee-script ^1.10.0 + lodash ^4.13.1 + noon >=1.0.12 + performance-now ^0.2.0 + sprintf-js ^1.0.3 + underscore.string ^3.3.4 \ No newline at end of file