From dc06cab69f9e871aa8f7f519c964cf632d2217ea Mon Sep 17 00:00:00 2001 From: Jules Date: Thu, 10 Nov 2016 15:34:53 -0500 Subject: meatheadz --- beach.png | Bin 0 -> 7057 bytes breaststroke3.gif | Bin 0 -> 26789 bytes breaststroke3.png | Bin 0 -> 25902 bytes cannonball.gif | Bin 0 -> 7811 bytes etc/manjumping.png | Bin 0 -> 51799 bytes etc/manrunning.png | Bin 0 -> 35352 bytes etc/manrunningsprite.png | Bin 0 -> 43462 bytes etc/manrunningsprite_left.png | Bin 0 -> 44258 bytes etc/manstandingsprite.png | Bin 0 -> 276454 bytes etc/manstandingsprite_left.png | Bin 0 -> 296104 bytes float3.gif | Bin 0 -> 35506 bytes float3.png | Bin 0 -> 29261 bytes fonts/Commodore-64-v6.3.TTF | Bin 0 -> 51008 bytes fonts/Commodore-Angled-v1.2.ttf | Bin 0 -> 19660 bytes fonts/Commodore-Rounded-v1.2.ttf | Bin 0 -> 20084 bytes geometry.html | 502 +++++++ geometry2.html | 671 ++++++++++ geometry3.html | 957 ++++++++++++++ geometry4.html | 1158 ++++++++++++++++ geometry5.html | 1392 +++++++++++++++++++ geometry6.html | 1393 ++++++++++++++++++++ guru.gif | Bin 0 -> 736302 bytes guru2.gif | Bin 0 -> 269271 bytes index.html | 1393 ++++++++++++++++++++ jquery.gamequery-0.5.1.js | 1164 ++++++++++++++++ landscape/abovewaterislandbg.png | Bin 0 -> 3103 bytes landscape/abovewaterislandcorner.png | Bin 0 -> 833 bytes landscape/bush.png | Bin 0 -> 1038 bytes landscape/island1bg.png | Bin 0 -> 11927 bytes landscape/island1fg.png | Bin 0 -> 8827 bytes landscape/island_bush.png | Bin 0 -> 3687 bytes landscape/palmtree.png | Bin 0 -> 2484 bytes landscape/scotch.gif | Bin 0 -> 1073 bytes landscape/underwaterislandbg.png | Bin 0 -> 3154 bytes landscape/underwaterislandcorner.png | Bin 0 -> 1020 bytes landscape/watercorner.png | Bin 0 -> 1323 bytes manrunning.gif | Bin 0 -> 38238 bytes manrunning2.gif | Bin 0 -> 39286 bytes manstanding.gif | Bin 0 -> 96794 bytes manstanding2.gif | Bin 0 -> 96467 bytes particle.html | 109 ++ possible/.htaccess | 1 + ...pepper-1298436051425-dumpfm-pepper-chevre_1.png | Bin 0 -> 198177 bytes .../1298590356231-dumpfm-pepper-fingercheese.png | Bin 0 -> 62725 bytes ...0591584954-dumpfm-pepper-nantucket_paradigm.png | Bin 0 -> 473270 bytes .../1301351326112-dumpfm-pepper-glitter_wom2.gif | Bin 0 -> 26055 bytes ...2286721060-dumpfm-pepper-cell_phone_glitter.gif | Bin 0 -> 192883 bytes possible/plasmus5.gif | Bin 0 -> 4770 bytes possible/plasmusuk.gif | Bin 0 -> 9221 bytes sand.png | Bin 0 -> 16415 bytes sea.png | Bin 0 -> 16413 bytes sky.png | Bin 0 -> 16415 bytes splash.gif | Bin 0 -> 8623 bytes sprites/.htaccess | 1 + sprites/breaststroke.gif | Bin 0 -> 22092 bytes sprites/breaststroke1.png | Bin 0 -> 17789 bytes sprites/breaststroke2.png | Bin 0 -> 22166 bytes sprites/breaststroke3.png | Bin 0 -> 24502 bytes sprites/cannonball.png | Bin 0 -> 7935 bytes sprites/cannonball2.png | Bin 0 -> 15809 bytes sprites/diving1.png | Bin 0 -> 24887 bytes sprites/diving2.gif | Bin 0 -> 22901 bytes sprites/diving2.png | Bin 0 -> 20356 bytes sprites/float.gif | Bin 0 -> 31839 bytes sprites/float1.png | Bin 0 -> 28688 bytes sprites/float2.png | Bin 0 -> 27392 bytes sprites/float3.png | Bin 0 -> 25589 bytes sprites/jumping.png | Bin 0 -> 51799 bytes sprites/jumping2.png | Bin 0 -> 25301 bytes sprites/mandiving1.gif | Bin 0 -> 22901 bytes sprites/manrunningsprite.png | Bin 0 -> 57391 bytes sprites/manrunningsprite_left.png | Bin 0 -> 58053 bytes sprites/manstandingsprite.png | Bin 0 -> 80808 bytes sprites/manstandingsprite_brown.png | Bin 0 -> 48270 bytes sprites/manstandingsprite_left.png | Bin 0 -> 80890 bytes sprites/orig/manrunning.png | Bin 0 -> 35352 bytes sprites/orig/manrunningsprite.png | Bin 0 -> 43462 bytes sprites/orig/manrunningsprite_left.png | Bin 0 -> 44258 bytes sprites/orig/manstandingsprite.png | Bin 0 -> 276454 bytes sprites/orig/manstandingsprite_left.png | Bin 0 -> 296104 bytes sprites/orig/sand.png | Bin 0 -> 16415 bytes sprites/orig/sky.png | Bin 0 -> 16415 bytes sprites/running2.gif | Bin 0 -> 39286 bytes sprites/splash.png | Bin 0 -> 9418 bytes sprites/splash2.png | Bin 0 -> 20453 bytes sprites/standing2.gif | Bin 0 -> 96467 bytes sprites/swimming1.gif | Bin 0 -> 22195 bytes sprites/swimming1.png | Bin 0 -> 16883 bytes sprites/swimming2.png | Bin 0 -> 20921 bytes sprites/swimtrans.png | Bin 0 -> 9156 bytes swimtrans.gif | Bin 0 -> 9399 bytes swimtrans.png | Bin 0 -> 8335 bytes v1.html | 230 ++++ v2.html | 420 ++++++ v3.html | 501 +++++++ v4.html | 629 +++++++++ v5.html | 632 +++++++++ v6.html | 736 +++++++++++ 98 files changed, 11889 insertions(+) create mode 100755 beach.png create mode 100755 breaststroke3.gif create mode 100755 breaststroke3.png create mode 100755 cannonball.gif create mode 100755 etc/manjumping.png create mode 100755 etc/manrunning.png create mode 100755 etc/manrunningsprite.png create mode 100755 etc/manrunningsprite_left.png create mode 100755 etc/manstandingsprite.png create mode 100755 etc/manstandingsprite_left.png create mode 100755 float3.gif create mode 100755 float3.png create mode 100755 fonts/Commodore-64-v6.3.TTF create mode 100755 fonts/Commodore-Angled-v1.2.ttf create mode 100755 fonts/Commodore-Rounded-v1.2.ttf create mode 100755 geometry.html create mode 100755 geometry2.html create mode 100755 geometry3.html create mode 100755 geometry4.html create mode 100755 geometry5.html create mode 100755 geometry6.html create mode 100755 guru.gif create mode 100755 guru2.gif create mode 100755 index.html create mode 100755 jquery.gamequery-0.5.1.js create mode 100755 landscape/abovewaterislandbg.png create mode 100755 landscape/abovewaterislandcorner.png create mode 100755 landscape/bush.png create mode 100755 landscape/island1bg.png create mode 100755 landscape/island1fg.png create mode 100755 landscape/island_bush.png create mode 100755 landscape/palmtree.png create mode 100755 landscape/scotch.gif create mode 100755 landscape/underwaterislandbg.png create mode 100755 landscape/underwaterislandcorner.png create mode 100755 landscape/watercorner.png create mode 100755 manrunning.gif create mode 100755 manrunning2.gif create mode 100755 manstanding.gif create mode 100755 manstanding2.gif create mode 100755 particle.html create mode 100755 possible/.htaccess create mode 100755 possible/1298527286040-dumpfm-pepper-1298436051425-dumpfm-pepper-chevre_1.png create mode 100755 possible/1298590356231-dumpfm-pepper-fingercheese.png create mode 100755 possible/1300591584954-dumpfm-pepper-nantucket_paradigm.png create mode 100755 possible/1301351326112-dumpfm-pepper-glitter_wom2.gif create mode 100755 possible/1302286721060-dumpfm-pepper-cell_phone_glitter.gif create mode 100755 possible/plasmus5.gif create mode 100755 possible/plasmusuk.gif create mode 100755 sand.png create mode 100755 sea.png create mode 100755 sky.png create mode 100755 splash.gif create mode 100755 sprites/.htaccess create mode 100755 sprites/breaststroke.gif create mode 100755 sprites/breaststroke1.png create mode 100755 sprites/breaststroke2.png create mode 100755 sprites/breaststroke3.png create mode 100755 sprites/cannonball.png create mode 100755 sprites/cannonball2.png create mode 100755 sprites/diving1.png create mode 100755 sprites/diving2.gif create mode 100755 sprites/diving2.png create mode 100755 sprites/float.gif create mode 100755 sprites/float1.png create mode 100755 sprites/float2.png create mode 100755 sprites/float3.png create mode 100755 sprites/jumping.png create mode 100755 sprites/jumping2.png create mode 100755 sprites/mandiving1.gif create mode 100755 sprites/manrunningsprite.png create mode 100755 sprites/manrunningsprite_left.png create mode 100755 sprites/manstandingsprite.png create mode 100755 sprites/manstandingsprite_brown.png create mode 100755 sprites/manstandingsprite_left.png create mode 100755 sprites/orig/manrunning.png create mode 100755 sprites/orig/manrunningsprite.png create mode 100755 sprites/orig/manrunningsprite_left.png create mode 100755 sprites/orig/manstandingsprite.png create mode 100755 sprites/orig/manstandingsprite_left.png create mode 100755 sprites/orig/sand.png create mode 100755 sprites/orig/sky.png create mode 100755 sprites/running2.gif create mode 100755 sprites/splash.png create mode 100755 sprites/splash2.png create mode 100755 sprites/standing2.gif create mode 100755 sprites/swimming1.gif create mode 100755 sprites/swimming1.png create mode 100755 sprites/swimming2.png create mode 100755 sprites/swimtrans.png create mode 100755 swimtrans.gif create mode 100755 swimtrans.png create mode 100755 v1.html create mode 100755 v2.html create mode 100755 v3.html create mode 100755 v4.html create mode 100755 v5.html create mode 100755 v6.html diff --git a/beach.png b/beach.png new file mode 100755 index 0000000..5654de7 Binary files /dev/null and b/beach.png differ diff --git a/breaststroke3.gif b/breaststroke3.gif new file mode 100755 index 0000000..08512d0 Binary files /dev/null and b/breaststroke3.gif differ diff --git a/breaststroke3.png b/breaststroke3.png new file mode 100755 index 0000000..2323195 Binary files /dev/null and b/breaststroke3.png differ diff --git a/cannonball.gif b/cannonball.gif new file mode 100755 index 0000000..b8bf1f0 Binary files /dev/null and b/cannonball.gif differ diff --git a/etc/manjumping.png b/etc/manjumping.png new file mode 100755 index 0000000..834df7f Binary files /dev/null and b/etc/manjumping.png differ diff --git a/etc/manrunning.png b/etc/manrunning.png new file mode 100755 index 0000000..7827444 Binary files /dev/null and b/etc/manrunning.png differ diff --git a/etc/manrunningsprite.png b/etc/manrunningsprite.png new file mode 100755 index 0000000..82b9ba1 Binary files /dev/null and b/etc/manrunningsprite.png differ diff --git a/etc/manrunningsprite_left.png b/etc/manrunningsprite_left.png new file mode 100755 index 0000000..dd29c7b Binary files /dev/null and b/etc/manrunningsprite_left.png differ diff --git a/etc/manstandingsprite.png b/etc/manstandingsprite.png new file mode 100755 index 0000000..ff41388 Binary files /dev/null and b/etc/manstandingsprite.png differ diff --git a/etc/manstandingsprite_left.png b/etc/manstandingsprite_left.png new file mode 100755 index 0000000..083cf70 Binary files /dev/null and b/etc/manstandingsprite_left.png differ diff --git a/float3.gif b/float3.gif new file mode 100755 index 0000000..e428263 Binary files /dev/null and b/float3.gif differ diff --git a/float3.png b/float3.png new file mode 100755 index 0000000..77cc5ff Binary files /dev/null and b/float3.png differ diff --git a/fonts/Commodore-64-v6.3.TTF b/fonts/Commodore-64-v6.3.TTF new file mode 100755 index 0000000..5ce242d Binary files /dev/null and b/fonts/Commodore-64-v6.3.TTF differ diff --git a/fonts/Commodore-Angled-v1.2.ttf b/fonts/Commodore-Angled-v1.2.ttf new file mode 100755 index 0000000..a9f5d41 Binary files /dev/null and b/fonts/Commodore-Angled-v1.2.ttf differ diff --git a/fonts/Commodore-Rounded-v1.2.ttf b/fonts/Commodore-Rounded-v1.2.ttf new file mode 100755 index 0000000..eee50a3 Binary files /dev/null and b/fonts/Commodore-Rounded-v1.2.ttf differ diff --git a/geometry.html b/geometry.html new file mode 100755 index 0000000..e496483 --- /dev/null +++ b/geometry.html @@ -0,0 +1,502 @@ + + +GEOMETRY + + + + + + + + + + diff --git a/geometry2.html b/geometry2.html new file mode 100755 index 0000000..15927c0 --- /dev/null +++ b/geometry2.html @@ -0,0 +1,671 @@ + + +GEOMETRY + + + + + + + + + + diff --git a/geometry3.html b/geometry3.html new file mode 100755 index 0000000..ec262f9 --- /dev/null +++ b/geometry3.html @@ -0,0 +1,957 @@ + + +GEOMETRY + + + + + + + + + + diff --git a/geometry4.html b/geometry4.html new file mode 100755 index 0000000..5af7fc7 --- /dev/null +++ b/geometry4.html @@ -0,0 +1,1158 @@ + + +GEOMETRY + + + + + + + + + diff --git a/geometry5.html b/geometry5.html new file mode 100755 index 0000000..95e9c68 --- /dev/null +++ b/geometry5.html @@ -0,0 +1,1392 @@ + + +GEOMETRY + + + + + + + + + diff --git a/geometry6.html b/geometry6.html new file mode 100755 index 0000000..52a3fe8 --- /dev/null +++ b/geometry6.html @@ -0,0 +1,1393 @@ + + +GEOMETRY + + + + + + + + + diff --git a/guru.gif b/guru.gif new file mode 100755 index 0000000..1800002 Binary files /dev/null and b/guru.gif differ diff --git a/guru2.gif b/guru2.gif new file mode 100755 index 0000000..b1caf81 Binary files /dev/null and b/guru2.gif differ diff --git a/index.html b/index.html new file mode 100755 index 0000000..739ee18 --- /dev/null +++ b/index.html @@ -0,0 +1,1393 @@ + + +MEATHEADZ + + + + + + + + + diff --git a/jquery.gamequery-0.5.1.js b/jquery.gamequery-0.5.1.js new file mode 100755 index 0000000..07b81ee --- /dev/null +++ b/jquery.gamequery-0.5.1.js @@ -0,0 +1,1164 @@ +/* + * gameQuery rev. 0.5.1 + * + * Copyright (c) 2008 Selim Arsever (gamequery.onaluf.org) + * licensed under the MIT (MIT-LICENSE.txt) + */ +// this allow to used the convenient $ notation in a plugins +(function($) { + + $.extend({ gameQuery: { + /** + * This is the Animation Object + */ + Animation: function (options) { + // private default values + var defaults = { + imageURL: "", + numberOfFrame: 1, + delta: 0, + rate: 30, + type: 0, + distance: 0, + offsetx: 0, + offsety: 0 + }; + + // options extends defaults + options = $.extend(defaults, options); + + //"public" attributes: + this.imageURL = options.imageURL; // The url of the image to be used as an animation or sprite + this.numberOfFrame = options.numberOfFrame;// The number of frame to be displayed when playing the animation + this.delta = options.delta; // The the distance in pixels between two frame + this.rate = options.rate; // The rate at which the frame must be played in miliseconds + this.type = options.type; // The type of the animation.This is bitwise OR of the properties. + this.distance = options.distance; // The the distance in pixels between two animation + this.offsetx = options.offsetx; // The x coordinate where the first sprite begin + this.offsety = options.offsety; // The y coordinate where the first sprite begin + + //Whenever a new animation is created we add it to the ResourceManager animation list + $.gameQuery.resourceManager.addAnimation(this); + + return true; + }, + + // "constants" for the different type of an animation + ANIMATION_VERTICAL: 1, // genertated by a verical offset of the background + ANIMATION_HORIZONTAL: 2, // genertated by a horizontal offset of the background + ANIMATION_ONCE: 4, // played only once (else looping indefinitly) + ANIMATION_CALLBACK: 8, // A callack is exectued at the end of a cycle + ANIMATION_MULTI: 16, // The image file contains many animations + + // "constants" for the different type of geometry for a sprite + GEOMETRY_RECTANGLE: 1, + GEOMETRY_DISC: 2, + + // basic values + refreshRate: 30, + + /** + * An object to manages the resources loading + **/ + resourceManager: { + animations: [], // List of animation / images used in the game + sounds: [], // List of sounds used in the game + callbacks: [], // List of the functions called at each refresh + running: false, // State of the game, + + /** + * This function the covers things to load befor to start the game. + **/ + preload: function() { + //Start loading the images + for (var i = this.animations.length-1 ; i >= 0; i --){ + this.animations[i].domO = new Image(); + this.animations[i].domO.src = this.animations[i].imageURL; + } + + //Start loading the sounds + for (var i = this.sounds.length-1 ; i >= 0; i --){ + this.sounds[i].load(); + } + + $.gameQuery.resourceManager.waitForResources(); + }, + + /** + * This function the waits for all the resources called for in preload() to finish loading. + **/ + waitForResources: function() { + var loadbarEnabled = ($.gameQuery.loadbar != undefined); + if(loadbarEnabled){ + $($.gameQuery.loadbar.id).width(0); + var loadBarIncremant = $.gameQuery.loadbar.width / (this.animations.length + this.sounds.length); + } + //check the images + var imageCount = 0; + for(var i=0; i < this.animations.length; i++){ + if(this.animations[i].domO.complete){ + imageCount++; + } + } + //check the sounds + var soundCount = 0; + for(var i=0; i < this.sounds.length; i++){ + var temp = this.sounds[i].ready(); + if(temp){ + soundCount++; + } + } + //update the loading bar + if(loadbarEnabled){ + $("#"+$.gameQuery.loadbar.id).width((imageCount+soundCount)*loadBarIncremant); + if($.gameQuery.loadbar.callback){ + $.gameQuery.loadbar.callback((imageCount+soundCount)/(this.animations.length + this.sounds.length)*100); + } + } + if($.gameQuery.resourceManager.loadCallback){ + var percent = (imageCount+soundCount)/(this.animations.length + this.sounds.length)*100; + $.gameQuery.resourceManager.loadCallback(percent); + } + if(imageCount + soundCount < (this.animations.length + this.sounds.length)){ + imgWait=setTimeout(function () { + $.gameQuery.resourceManager.waitForResources(); + }, 100); + } else { + // all the resources are loaded! + // We can associate the animation's images to their coresponding sprites + $.gameQuery.sceengraph.children().each(function(){ + // recursive call on the children: + $(this).children().each(arguments.callee); + // add the image as a background + if(this.gameQuery && this.gameQuery.animation){ + $(this).css("background-image", "url("+this.gameQuery.animation.imageURL+")"); + // we set the correct kind of repeat + if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL) { + $(this).css("background-repeat", "repeat-x"); + } else if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) { + $(this).css("background-repeat", "repeat-y"); + } else { + $(this).css("background-repeat", "no-repeat"); + } + } + }); + + // And launch the refresh loop + $.gameQuery.resourceManager.running = true; + setInterval(function () { + $.gameQuery.resourceManager.refresh(); + },($.gameQuery.refreshRate)); + if($.gameQuery.startCallback){ + $.gameQuery.startCallback(); + } + //make the sceengraph visible + $.gameQuery.sceengraph.css("visibility","visible"); + } + }, + + /** + * This function refresh a unique sprite here 'this' represent a dom object + **/ + refreshSprite: function() { + //Call this function on all the children: + // is 'this' a sprite ? + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + // does 'this' has an animation ? + if(gameQuery.animation){ + //Do we have anything to do? + if(gameQuery.idleCounter == gameQuery.animation.rate-1){ + // does 'this' loops? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_ONCE){ + if(gameQuery.currentFrame < gameQuery.animation.numberOfFrame-2){ + gameQuery.currentFrame++; + } else if(gameQuery.currentFrame == gameQuery.animation.numberOfFrame-2) { + gameQuery.currentFrame++; + // does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + } + } + } + } else { + gameQuery.currentFrame = (gameQuery.currentFrame+1)%gameQuery.animation.numberOfFrame; + if(gameQuery.currentFrame == 0){ + // does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + } + } + } + } + // update the background: + if(gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL){ + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.multi)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } + } else if(gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) { + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety-gameQuery.multi)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety)+"px"); + } + } + } + gameQuery.idleCounter = (gameQuery.idleCounter+1)%gameQuery.animation.rate; + } + } + return true; + }, + + /** + * This function refresh a unique tile-map here 'this' represent a dom object + **/ + refreshTilemap: function() { + //Call this function on all the children: + // is 'this' a sprite ? + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + if($.isArray(gameQuery.frameTracker)){ + for(var i=0; i= 0; i--){ + if(this.callbacks[i].idleCounter == this.callbacks[i].rate-1){ + var returnedValue = this.callbacks[i].fn(); + if(typeof returnedValue == 'boolean'){ + // if we have a boolean: 'true' means 'no more execution', 'false' means 'execute once more' + if(returnedValue){ + deadCallback.push(i); + } + } else if(typeof returnedValue == 'number') { + // if we have a number it re-defines the time to the nex call + this.callbacks[i].rate = Math.round(returnedValue/$.gameQuery.refreshRate); + this.callbacks[i].idleCounter = 0; + } + } + this.callbacks[i].idleCounter = (this.callbacks[i].idleCounter+1)%this.callbacks[i].rate; + } + for(var i = deadCallback.length-1; i >= 0; i--){ + this.callbacks.splice(deadCallback[i],1); + } + }, + + addAnimation: function(animation) { + if($.inArray(animation,this.animations)<0){ + //normalize the animationRate: + animation.rate = Math.round(animation.rate/$.gameQuery.refreshRate); + if(animation.rate==0){ + animation.rate = 1; + } + this.animations.push(animation); + } + }, + + addSound: function(sound){ + if($.inArray(sound,this.sounds)<0){ + this.sounds.push(sound); + } + }, + + + registerCallback: function(fn, rate){ + rate = Math.round(rate/$.gameQuery.refreshRate); + if(rate==0){ + rate = 1; + } + this.callbacks.push({fn: fn, rate: rate, idleCounter: 0}); + } + }, + + // This is a single place to update the underlying data of sprites/groups/tiles + update: function(descriptor, transformation) { + // Did we really recieve a descriptor or a jQuery object instead? + if(!$.isPlainObject(descriptor)){ + // Then we must get real descriptor + if(descriptor.length > 0){ + var gameQuery = descriptor[0].gameQuery; + } else { + var gameQuery = descriptor.gameQuery; + } + } else { + var gameQuery = descriptor; + } + // If we couldn't find one we return + if(!gameQuery) return; + if(gameQuery.tileSet === true){ + //then we have a tilemap! + descriptor = $(descriptor); + // find the tilemap offset relatif to the playground: + var playgroundOffset = $.gameQuery.playground.offset(); + var tileSetOffset = descriptor.offset(); + tileSetOffset = {top: tileSetOffset.top - playgroundOffset.top, left: tileSetOffset.left - playgroundOffset.left}; + // test what kind of transformation we have and react accordingly: + // Update the descriptor + for(property in transformation){ + switch(property){ + case "left": + //Do we need to activate/desactive the first/last column + var left = parseFloat(transformation.left); + //Get the tileSet offset (relatif to the playground) + var playgroundOffset = $.gameQuery.playground.offset(); + var tileSetOffset = descriptor.parent().offset(); + tileSetOffset = {top: tileSetOffset.top - playgroundOffset.top, left: tileSetOffset.left + left - playgroundOffset.left}; + + //actvates the visible tiles + var firstColumn = Math.max(Math.min(Math.floor(-tileSetOffset.left/gameQuery.width), gameQuery.sizex),0); + var lastColumn = Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].width-tileSetOffset.left)/gameQuery.width), gameQuery.sizex),0); + + for(var i = gameQuery.firstRow; i < gameQuery.lastRow; i++){ + // if old first col < new first col + // deactivate the newly invisible tiles + for(var j = gameQuery.firstColumn; j < firstColumn ; j++) { + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).removeClass("active"); + } + //and activate the newly visible tiles + for(var j = gameQuery.lastColumn; j < lastColumn ; j++) { + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).addClass("active"); + } + + // if old first col > new first col + // deactivate the newly invisible tiles + for(var j = lastColumn; j < gameQuery.lastColumn ; j++) { + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).removeClass("active"); + } + //activate the newly visible tiles + for(var j = firstColumn; j < gameQuery.firstColumn ; j++) { + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).addClass("active"); + } + } + + gameQuery.firstColumn = firstColumn; + gameQuery.lastColumn = lastColumn; + break; + case "top": + //Do we need to activate/desactive the first/last row + var top = parseFloat(transformation.top); + //Get the tileSet offset (relatif to the playground) + var playgroundOffset = $.gameQuery.playground.offset(); + var tileSetOffset = descriptor.parent().offset(); + tileSetOffset = {top: tileSetOffset.top + top - playgroundOffset.top, left: tileSetOffset.left - playgroundOffset.left}; + + //actvates the visible tiles + var firstRow = Math.max(Math.min(Math.floor(-tileSetOffset.top/gameQuery.height), gameQuery.sizey), 0); + var lastRow = Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].height-tileSetOffset.top)/gameQuery.height), gameQuery.sizey), 0); + + + for(var j = gameQuery.firstColumn; j < gameQuery.lastColumn ; j++) { + // if old first row < new first row + // deactivate the newly invisible tiles + for(var i = gameQuery.firstRow; i < firstRow; i++){ + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).removeClass("active"); + } + //and activate the newly visible tiles + for(var i = gameQuery.lastRow; i < lastRow; i++){ + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).addClass("active"); + } + + // if old first row < new first row + // deactivate the newly invisible tiles + for(var i = lastRow; i < gameQuery.lastRow; i++){ + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).removeClass("active"); + } + //and activate the newly visible tiles + for(var i = firstRow; i < gameQuery.firstRow; i++){ + $("#tile_"+descriptor.attr("id")+"_"+i+"_"+j).addClass("active"); + } + } + + gameQuery.firstRow = firstRow; + gameQuery.lastRow = lastRow; + + break; + case "angle": //(in degree) + //TODO + break; + case "factor": + //TODO + break; + } + } + + } else { + var refreshBoundingCircle = $.gameQuery.playground && !$.gameQuery.playground.disableCollision; + + // Update the descriptor + for(property in transformation){ + switch(property){ + case "left": + gameQuery.posx = parseFloat(transformation.left); + if(refreshBoundingCircle){ + gameQuery.boundingCircle.x = gameQuery.posx+gameQuery.width/2; + } + break; + case "top": + gameQuery.posy = parseFloat(transformation.top); + if(refreshBoundingCircle){ + gameQuery.boundingCircle.y = gameQuery.posy+gameQuery.height/2; + } + break; + case "width": + gameQuery.width = parseFloat(transformation.width); + break; + case "height": + gameQuery.height = parseFloat(transformation.height); + break; + case "angle": //(in degree) + gameQuery.angle = parseFloat(transformation.angle); + break; + case "factor": + gameQuery.factor = parseFloat(transformation.factor); + if(refreshBoundingCircle){ + gameQuery.boundingCircle.radius = gameQuery.factor*gameQuery.boundingCircle.originalRadius; + } + break; + } + } + } + }, + + // This is a utility function that returns the radius for a geometry + proj: function (elem, angle) { + switch (elem.geometry){ + case $.gameQuery.GEOMETRY_RECTANGLE : + var b = angle*Math.PI*2/360; + var Rx = Math.abs(Math.cos(b)*elem.width/2*elem.factor)+Math.abs(Math.sin(b)*elem.height/2*elem.factor); + var Ry = Math.abs(Math.cos(b)*elem.height/2*elem.factor)+Math.abs(Math.sin(b)*elem.width/2*elem.factor); + + return {x: Rx, y: Ry}; + } + }, + + // This is a utility function for collision of two object + collide: function(elem1, offset1, elem2, offset2) { + // test real collision (only for two rectangle...) + if((elem1.geometry == $.gameQuery.GEOMETRY_RECTANGLE && elem2.geometry == $.gameQuery.GEOMETRY_RECTANGLE)){ + + var dx = offset2.x + elem2.boundingCircle.x - elem1.boundingCircle.x - offset1.x; + var dy = offset2.y + elem2.boundingCircle.y - elem1.boundingCircle.y - offset1.y; + var a = Math.atan(dy/dx); + + var Dx = Math.abs(Math.cos(a-elem1.angle*Math.PI*2/360)/Math.cos(a)*dx); + var Dy = Math.abs(Math.sin(a-elem1.angle*Math.PI*2/360)/Math.sin(a)*dy); + + var R = $.gameQuery.proj(elem2, elem2.angle-elem1.angle); + + if((elem1.width/2*elem1.factor+R.x <= Dx) || (elem1.height/2*elem1.factor+R.y <= Dy)) { + return false; + } else { + var Dx = Math.abs(Math.cos(a-elem2.angle*Math.PI*2/360)/Math.cos(a)*-dx); + var Dy = Math.abs(Math.sin(a-elem2.angle*Math.PI*2/360)/Math.sin(a)*-dy); + + var R = $.gameQuery.proj(elem1, elem1.angle-elem2.angle); + + if((elem2.width/2*elem2.factor+R.x <= Dx) || (elem2.height/2*elem2.factor+R.y <= Dy)) { + return false; + } else { + return true; + } + } + } else { + return false; + } + } + // This function mute (or unmute) all the sounds. + }, muteSound: function(muted){ + for (var i = $.gameQuery.resourceManager.sounds.length-1 ; i >= 0; i --) { + $.gameQuery.resourceManager.sounds[i].muted(muted); + } + }, playground: function() { + return $.gameQuery.playground + // This function define a callback that will be called upon during the + // loading of the game's resources. The function will recieve as unique + // parameter a number representing the progess percentage. + }, loadCallback: function(callback){ + $.gameQuery.resourceManager.loadCallback = callback; + }}); + + $.fn.extend({ + /** + * Define the div to use for the display the game and initailize it. + * This could be called on any node it doesn't matter. + * The returned node is the playground node. + * This IS a desrtuctive call + **/ + playground: function(options) { + if(this.length == 1){ + if(this[0] == document){ // Old usage check + throw "Old playground usage, use $.playground() to retreive the playground and $('mydiv').playground(options) to set the div!"; + } + options = $.extend({ + height: 320, + width: 480, + refreshRate: 30, + position: "absolute", + keyTracker: false, + disableCollision: false + }, options); + //We save the playground node and set some variable for this node: + $.gameQuery.playground = this; + $.gameQuery.refreshRate = options.refreshRate; + $.gameQuery.playground[0].height = options.height; + $.gameQuery.playground[0].width = options.width; + + // We initialize the apearance of the div + $.gameQuery.playground.css({ + position: options.position, + display: "block", + overflow: "hidden", + height: options.height+"px", + width: options.width+"px" + }) + .append("