Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated SDK

  • Loading branch information...
commit 00b0f69e76a0cee38a8b3da87f282ba2749e4412 1 parent c0927fa
@lannymcnie lannymcnie authored
Showing with 700 additions and 331 deletions.
  1. +226 −0 scripts/BrowserDetect.js
  2. +1 −1  scripts/libs/atari/Atari.js
  3. +1 −1  scripts/libs/atari/Fonts.js
  4. +7 −6 scripts/libs/atari/GameBootstrap.js
  5. +35 −12 scripts/libs/atari/GameMediator.js
  6. +34 −16 scripts/libs/atari/GameShell.js
  7. +0 −83 scripts/libs/atari/HighScores.js
  8. +2 −2 scripts/libs/gamelibs/FPSMeter.js
  9. +1 −1  scripts/libs/gamelibs/GameDetails.js
  10. +1 −1  scripts/libs/gamelibs/GameLibs.js
  11. +114 −8 scripts/libs/gamelibs/GameUI.js
  12. +31 −5 scripts/libs/gamelibs/Math2.js
  13. +2 −2 scripts/libs/gamelibs/Parallax.js
  14. +1 −1  scripts/libs/gamelibs/ParticleEmitter.js
  15. +3 −1 scripts/libs/gamelibs/PerformanceMonitor.js
  16. +1 −1  scripts/libs/gamelibs/Point2.js
  17. +3 −1 scripts/libs/gamelibs/ScoreManager.js
  18. +2 −2 scripts/libs/gamelibs/SpriteSheetWrapper.js
  19. +1 −1  scripts/libs/gamelibs/StringUtils.js
  20. +1 −1  scripts/libs/gamelibs/TexturePackerUtils.js
  21. +4 −4 scripts/libs/gamelibs/input/ArcadeButton.js
  22. +2 −2 scripts/libs/gamelibs/input/GamePad.js
  23. +11 −9 scripts/libs/gamelibs/input/Joystick.js
  24. +13 −13 scripts/libs/gamelibs/input/Throttle.js
  25. +1 −1  scripts/libs/gamelibs/input/TouchBar.js
  26. +1 −1  scripts/libs/gamelibs/multiplayer/FramePacket.js
  27. +123 −4 scripts/libs/gamelibs/multiplayer/GameInfo.js
  28. +1 −1  scripts/libs/gamelibs/multiplayer/GamePacket.js
  29. +13 −8 scripts/libs/gamelibs/multiplayer/MultiPlayerGame.js
  30. +4 −4 scripts/libs/gamelibs/multiplayer/Player.js
  31. +3 −3 scripts/libs/gametemplate/manifest.json
  32. +0 −125 scripts/libs/gametemplate/src/scripts/Game-STUB.js
  33. +14 −6 scripts/libs/gametemplate/src/scripts/Game.js
  34. +1 −1  scripts/libs/gskinner/LocalStorage.js
  35. +1 −1  scripts/libs/gskinner/ProximityManager.js
  36. +1 −1  scripts/libs/gskinner/Rnd.js
  37. +1 −1  scripts/libs/gskinner/StringUtils.js
  38. +39 −0 scripts/libs/gskinner/VendorPrefixUtil.js
View
226 scripts/BrowserDetect.js
@@ -0,0 +1,226 @@
+(function(scope) {
+
+ /**
+ * BrowserDetect derived from http://www.quirksmode.org/js/detect.html
+ */
+ var s = {};
+
+// Public properties:
+
+ s.browser = null;
+ s.version = null;
+ s.os = null;
+
+ s.isIE = function () {
+ return s.browser == 'Explorer';
+ };
+
+ s.isVista = function() {
+ return navigator.userAgent.indexOf('Windows NT 6.0') != -1;
+ };
+
+ s.isXP = function() {
+ return navigator.userAgent.indexOf('Windows NT 5') != -1;
+ };
+
+ s.isWindows = function() {
+ return s.os == "Windows";
+ };
+
+ s.isWP8 = function () {
+ return navigator.userAgent.indexOf('Windows Phone 8') != -1;
+ };
+
+ s.isWP7 = function () {
+ return navigator.userAgent.indexOf('Windows Phone 7') != -1;
+ };
+
+ s.isAndroid = function() {
+ return navigator.userAgent.indexOf('Android') != -1;
+ };
+
+ s.isIE9 = function () {
+ return this.isIE() && this.getInternetExplorerVersion() == 9;
+ };
+
+ s.isMac = function() {
+ return s.os == "Mac" || s.isIOS();
+ };
+
+ s.isIOS = function() {
+ return s.os == "iPhone/iPod" || s.os == "iPad";
+ };
+
+ s.isIOSRetina = function () {
+ return s.isIOS() && window.devicePixelRatio > 1;
+ };
+
+ s.isMobileSafari = function() {
+ return s.isSafari() && s.isIOS();
+ };
+
+ s.isSafari = function() {
+ return s.browser == "Safari";
+ };
+
+ s.isChrome = function() {
+ return s.browser == "Chrome";
+ };
+
+ s.isFirefox = function() {
+ return s.browser == "Firefox" || s.browser == "Mozilla";
+ };
+
+ s.isOpera = function () {
+ return s.browser == "Opera";
+ };
+
+ s.getInternetExplorerVersion = function()
+ // Returns the version of Internet Explorer or a -1
+ // (indicating the use of another browser).
+ {
+ var rv = -1; // Return value assumes failure.
+ if (navigator.appName == 'Microsoft Internet Explorer')
+ {
+ var ua = navigator.userAgent;
+ var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+ if (re.exec(ua) != null)
+ rv = parseFloat( RegExp.$1 );
+ }
+ return rv;
+ }
+
+// Protected properties:
+
+ s._dataBrowser = [
+ {
+ string: navigator.userAgent,
+ subString: "Chrome",
+ identity: "Chrome"
+ },
+ { string: navigator.userAgent,
+ subString: "OmniWeb",
+ versionSearch: "OmniWeb/",
+ identity: "OmniWeb"
+ },
+ {
+ string: navigator.vendor,
+ subString: "Apple",
+ identity: "Safari",
+ versionSearch: "Version"
+ },
+ {
+ prop: window.opera,
+ identity: "Opera",
+ versionSearch: "Version"
+ },
+ {
+ string: navigator.vendor,
+ subString: "iCab",
+ identity: "iCab"
+ },
+ {
+ string: navigator.vendor,
+ subString: "KDE",
+ identity: "Konqueror"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "Firefox",
+ identity: "Firefox"
+ },
+ {
+ string: navigator.vendor,
+ subString: "Camino",
+ identity: "Camino"
+ },
+ { // for newer Netscapes (6+)
+ string: navigator.userAgent,
+ subString: "Netscape",
+ identity: "Netscape"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "MSIE",
+ identity: "Explorer",
+ versionSearch: "MSIE"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "Gecko",
+ identity: "Mozilla",
+ versionSearch: "rv"
+ },
+ { // for older Netscapes (4-)
+ string: navigator.userAgent,
+ subString: "Mozilla",
+ identity: "Netscape",
+ versionSearch: "Mozilla"
+ }
+ ];
+
+ s._dataOS = [
+ {
+ string: navigator.platform,
+ subString: "Win",
+ identity: "Windows"
+ },
+ {
+ string: navigator.platform,
+ subString: "Mac",
+ identity: "Mac"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "iPhone",
+ identity: "iPhone/iPod"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "iPad",
+ identity: "iPad"
+ },
+ {
+ string: navigator.platform,
+ subString: "Linux",
+ identity: "Linux"
+ }
+ ];
+
+ s._versionSearchString = null;
+
+// Public methods:
+
+ s.init = function () {
+ s.browser = s._searchString(s._dataBrowser) || "An unknown browser";
+ s.version = s._searchVersion(navigator.userAgent) || s._searchVersion(navigator.appVersion) || "An unknown version";
+ s.os = s._searchString(s._dataOS) || "An unknown OS";
+ };
+
+// Protected methods:
+
+ s._searchString = function (data) {
+ for (var i = 0, l = data.length; i < l; i++) {
+ var dataString = data[i].string;
+ var dataProp = data[i].prop;
+
+ s._versionSearchString = data[i].versionSearch || data[i].identity;
+ if (dataString) {
+ if (dataString.indexOf(data[i].subString) != -1) { return data[i].identity; }
+ } else if (dataProp) {
+ return data[i].identity;
+ }
+ }
+ };
+
+ s._searchVersion = function (dataString) {
+ var index = dataString.indexOf(s._versionSearchString);
+ if (index == -1) { return; }
+ return parseFloat(dataString.substring(index + s._versionSearchString.length + 1));
+ };
+
+scope.BrowserDetect = s;
+
+s.init(); // Auto init class.
+
+}(window.AtariSite!=null?window.AtariSite:window));
View
2  scripts/libs/atari/Atari.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/atari/Fonts.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
13 scripts/libs/atari/GameBootstrap.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -109,10 +109,10 @@
*/
s.initialize = function() {
// Selectively set the plugins
- /*createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
- if (AtariSite.BrowserDetect.isSafari()) {
+ createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
+ if (createjs.PreloadJS.BrowserDetect.isIOS) {
createjs.SoundJS.registerPlugin(createjs.FlashPlugin);
- }*/
+ }
}
/**
@@ -143,8 +143,9 @@
var manifest = s.manifest = this.owner.currentGameManifest;
s.canvas = canvas;
- canvas.width = manifest.width;
- canvas.height = manifest.height;
+ // LM: DEPRECATED FOR NOW
+ //canvas.width = manifest.width;
+ //canvas.height = manifest.height;
// Append base to each path
var assets = [];
View
47 scripts/libs/atari/GameMediator.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -51,6 +51,7 @@
s.RESTART_GAME = "restartGame";
s.DESTROY_GAME = "destroyGame";
s.REDUCE_FRAMERATE = "reduceFrameRate";
+ s.REMOVE_PLAYER = "removePlayer";
/**
* Defines the constant for a notify-level error, which can usually be ignored.
@@ -243,6 +244,11 @@
}
},
+ toggleVisibility: function(visible) {
+ // Consider throttling Tick...
+ GameLibs.GamePad.reset();
+ },
+
/**
* Register the game instance with the GameMediator. This ensures that all the game has all the
* required methods and event handlers defined, and adds handlers for events. Note that the
@@ -305,16 +311,20 @@
this.shell = shell;
this.multiPlayerGame = mpg;
+ // Scale the canvas to fit the GameInfo.
+ var canvas = this.stage.canvas;
+ var gameInfo = this.shell.gameInfo;
+
+ // Set the Canvas size
+ canvas.width = gameInfo.width;
+ canvas.height = gameInfo.height;
+
+ // On hi-resolution platforms, we need to counter-scale.
+ canvas.style.width = gameInfo.width * gameInfo.scaleFactor + "px";
+ canvas.style.height = gameInfo.height * gameInfo.scaleFactor + "px";
+
// Initialize the game itself.
- if (true || Atari.developerMode) {
- this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
- } else {
- try {
- this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
- } catch (error) {
- this.showError(error, "Unable to initialize game.");
- }
- }
+ this.gameInstance.initialize(this.currentAssets, this.stage, gameInfo);
},
/**
@@ -322,6 +332,8 @@
* @method startGame
*/
startGame: function() {
+ var gameInfo = this.shell.gameInfo;
+
var fps = this.shell.currentGameManifest.fps;
if (fps == null || isNaN(fps)) { fps = 30; }
createjs.Ticker.setFPS(fps);
@@ -329,10 +341,12 @@
this.targetFPS = fps;
this.targetMS = 1000 / fps;
- //Ticker.useRAF = true;
+ if (gameInfo.platform != GameLibs.GameInfo.PLATFORM_IPHONE) {
+ createjs.Ticker.useRAF = true;
+ }
createjs.Ticker.addListener(this, false);
- Atari.trace("[GameMediator] Staring game. Total players: " + this.shell.gameInfo.players.length);
+ Atari.trace("[GameMediator] Staring game. Total players: " + gameInfo.players.length);
this.gameInstance.startGame();
},
@@ -356,6 +370,9 @@
* @param {String} message A verbose message for the logs.
*/
logError: function(error, message) {
+ if(Atari.developerMode){
+ throw(error);
+ }
Atari.trace(error);
},
@@ -585,6 +602,12 @@
}
break;
+ case s.REMOVE_PLAYER:
+ if(game.removePlayer){
+ game.removePlayer(args);
+ }
+ break;
+
case s.CONTINUE_GAME:
createjs.Ticker.addListener(this, false);
if (dev) {
View
50 scripts/libs/atari/GameShell.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* Copyright Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -58,9 +58,8 @@
* The template path that will be loaded into an iframe, which bootstraps the game.
* @property templatePath
* @type {String}
- * @default templates/gameTemplate.html
*/
- s.templatePath = "templates/gameTemplate.html";
+ s.templatePath = null;
s.gameId = null;
s.baseUrl = null;
@@ -93,6 +92,8 @@
*/
s.onGameEvent = null;
+ s.defaultManifest = null;
+
/**
* The game is currently preloading.
* @event onGameProgress
@@ -119,8 +120,12 @@
};
s.baseUrl = baseUrl || "";
- // Load the core manifest
- s.loadFile([baseUrl + "games/GameManifest.json?no="+new Date().getTime()], s.handleGameList);
+ if (s.manifest == null) {
+ // Load the core manifest
+ s.loadFile([baseUrl + "games/GameManifest.json?no="+new Date().getTime()], s.handleGameList);
+ } else {
+ s.onManifestLoaded && s.onManifestLoaded(s.manifest);
+ }
}
/**
@@ -152,6 +157,15 @@
}
/**
+ * The site has been toggled. Usually when a tab changes. The site is responsible for this.
+ * @method toggleVisibility
+ * @param {Boolean} visible If the site is visible or not
+ */
+ s.toggleVisibility = function(visible) {
+ s.mediator.toggleVisibility(visible);
+ }
+
+ /**
* Setup a game instance. This method downloads the manifest, and preloads any
* assets needed to display the "start screen". Once complete, the <b>onGameSetup</b>
* callback is fired.
@@ -217,9 +231,6 @@
var manifest = this.currentGameManifest = Atari.parseJSON(event.result);
manifest.base = s.manifest[s.gameId].base;
- //TODO: Preload the start screen assets....
- var assets = manifest.startScreen;
-
if (s.onGameSetup) {
s.onGameSetup(manifest);
}
@@ -227,21 +238,16 @@
/**
* Create a game instance. This creates the container IFRAME, and initiates the
- * template injection. A game <b>Room</b> is created for multiplayer games, and returned
- * to the site, which contains the appropriate callbacks to monitor the room for a
- * ready state.
+ * template injection.
* @method createGame
* @param {DOMElement} Where on the document should the the iFrame should be placed.
* @static
*/
s.createGame = function(parent) {
- //s.gameInfo = gameInfo;
- var manifest = this.currentGameManifest;
-
var frame = s.frame = document.createElement("iframe");
frame.id = "gameFrame";
- frame.width = manifest.width;
- frame.height = manifest.height;
+ frame.width = 1024;
+ frame.height = 622;
frame.scrolling = "no";
frame.ALLOWTRANSPARENCY = true;
@@ -359,6 +365,9 @@
* @param {MultiPlayerGame} mpg The current multiplayer game.
*/
s.initializeGame = function(gameInfo, mpg) {
+ s.frame.width = gameInfo.width * gameInfo.scaleFactor;
+ s.frame.height = gameInfo.height * gameInfo.scaleFactor;
+
s.gameInfo = gameInfo;
s.multiPlayerGame = mpg;
s.mediator.initializeGame(s, mpg);
@@ -385,6 +394,15 @@
//s.window.postMessage({command:Atari.GameMediator.START_GAME});
}
+ /**
+ * A player has been disconnected from multiplayer, remove them from the game.
+ * @method removePlayer
+ * @static
+ */
+ s.removePlayer = function(playerId) {
+ s.mediator.command(Atari.GameMediator.REMOVE_PLAYER, playerId);
+ }
+
/**
* Utility method to load a file, and automatically scope the methods.
View
83 scripts/libs/atari/HighScores.js
@@ -1,83 +0,0 @@
-/*
-* Atari Arcade SDK
-* Developed by gskinner.com in partnership with Atari
-* Visit http://atari.com/arcade/developers for documentation, updates and examples.
-*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-*/
-
-/** @module Atari */
-(function(scope){
-
- /** @class HighScores */
- function HighScores() {}
-
- //TODO: Poll scoreboard for a new high score.
-
- // Save to local storage
- // TODO: will need an iOS workaround
- HighScores.saveLocalScore = function(game, score) {
- var oldScore = HighScores.getLocalScore(game);
- if(score > oldScore){
- localStorage.setItem(game + ".score", score);
- }
- }
-
- // Load from local storage
- // Note: will need an iOS workaround
- HighScores.getLocalScore = function(game) {
- var score = localStorage.getItem(game + ".score");
- return score || 0;
- }
-
- // Load display scores from server
- HighScores.loadScores = function(friendsOnly) {
- //TODO: Pass in current user token to get rank.
- //TODO: Optionally just load friends' scores.
-
- //LM: For now just return scores directly.
-
- // Temporary
- return [
- {
- name: "pong",
- scores: [
- {name:"LAN", score:1234, rank:1},
- {name:"SEB", score:321, rank:2},
- {name:"SDS", score:321, rank:3}
- ]
- },
- {
- name: "centipede",
- scores: [
- {name:"SBS", score:1234, rank:1},
- {name:"LAN", score:1245, rank:2, me:true},
- {name:"SEB", score:1222, rank:3}
- ]
- },
- {
- name: "breakout",
- scores: [
- {name:"SEB", score:1250, rank:300},
- {name:"LAN", score:1220, rank:301, me:true},
- {name:"SBS", score:12, rank:302}
- ]
- }
- ];
- }
-
- // Save to server
- // TODO: We will need to figure out how to do some obfuscation here.
- HighScores.submitScore = function(game, name, score) {
- // Send to server.
- // Get back result set
- }
-
- scope.HighScores = HighScores;
-
-}(window.Atari))
View
4 scripts/libs/gamelibs/FPSMeter.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -55,7 +55,7 @@
},
toString: function() {
- return "[FPSMeter]";
+ return "[GameLibs.FPSMeter]";
}
}
View
2  scripts/libs/gamelibs/GameDetails.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gamelibs/GameLibs.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
122 scripts/libs/gamelibs/GameUI.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -22,6 +22,29 @@
var s = GameUI;
s.background = null;
+ s.STRETCH = "stretch";
+ s.SCALE = "scale";
+ s.CROP = "crop";
+
+ //Align
+ s.CENTER = "C";
+ //Specifies that the CLIP is aligned at the center.
+ s.CENTER_TOP = "CT";
+ //Specifies that the CLIP is aligned at center-top.
+ s.CENTER_LEFT = "CL";
+ //Specifies that the CLIP is aligned at center-left corner.
+ s.CENTER_RIGHT = "CR";
+ //Specifies that the CLIP is aligned at center-right corner.
+ s.BOTTOM = "B";
+ //Specifies that the CLIP is aligned at the bottom.
+ s.BOTTOM_LEFT = "BL";
+ //Specifies that the CLIP is aligned in the bottom-left corner.
+ s.BOTTOM_RIGHT = "BR";
+ //Specifies that the CLIP is aligned in the bottom-right corner.
+ s.TOP_LEFT = "TL";
+ //Specifies that the CLIP is aligned in the top-left corner.
+ s.TOP_RIGHT = "TR";
+ //Specifies that the CLIP is aligned in the top-right corner.
/**
* Initializes the UI. This is called by the GameBootstrap before the game is instantiated.
@@ -45,8 +68,19 @@
* is no transition.
* @method changeBackground
* @param {HTMLImageElement|String} src The path or Image element to use as a background.
+ * @param {Number} width The width of the viewport.
+ * @param {Number} height The height of the viewport.
+ * @param {String} fit The mode to fit the image into the viewport.
+ * <ul>
+ * <li>stretch (default): Match the width and height of the viewport. This will augement the image
+ * if the ratios do not match.</li>
+ * <li>scale: Scale the image to fit in the viewport. Additional space may be visible on the outer
+ * edge of the image.</li>
+ * <li>crop: Scale the image to fill the viewport. Parts of the image will be cropped out.</li>
+ * </ul>
+ * @param {String} align The mode to align the image if it does not fit perfectly.
*/
- s.changeBackground = function(src) {
+ s.changeBackgroundOld = function(src) {
var path = src;
if (src == null) { return; }
if (typeof(src) == "string") {
@@ -56,9 +90,81 @@
}
s.background.style.backgroundImage = "url('"+path+"')";
}
+ s.changeBackground = function(src, width, height, fit, align) {
+ var bmp = new createjs.Bitmap(src);
+
+ var w = bmp.image.width;
+ var h = bmp.image.height;
+ var scale = 1;
+ // For now just stretch
+ if (fit == "stretch") {
+ bmp.scaleX = width/w;
+ bmp.scaleY = height/h;
+ } else if (fit == "scale") {
+ var ir = width/height;
+ var r = w/h;
+ if (ir < r) {
+ bmp.scaleX = bmp.scaleY = width/w;
+ //bmp.y = ?
+ } else {
+ bmp.scaleX = bmp.scaleY = height/h;
+ //bmp.x = ?
+ }
+ } else if (fit == "crop") {
+ var ir = width/height;
+ var r = w/h;
+ if (ir > r) {
+ bmp.scaleX = bmp.scaleY = width/w;
+
+ } else {
+ bmp.scaleX = bmp.scaleY = height/h;
+ }
+ scale = bmp.scaleX;
+ }
+ //Alignment types.
+ switch(align) {
+ case s.BOTTOM:
+ bmp.x = width - (w*scale)>>1;
+ bmp.y = height - h;
+ break;
+ case s.BOTTOM_LEFT:
+ bmp.x = 0;
+ bmp.y = height - h;
+ break;
+ case s.BOTTOM_RIGHT:
+ bmp.x = width - w*scale;
+ bmp.y = height - h;
+ break;
+ case s.CENTER_TOP:
+ bmp.x = width - (w*scale) >> 1;
+ bmp.y = 0;
+ break;
+ case s.CENTER_LEFT:
+ bmp.x = 0;
+ bmp.y = height - (h*scale)>>1;
+ break;
+ case s.CENTER_RIGHT:
+ bmp.x = width - w*scale;
+ bmp.y = height - (h*scale)>>1;
+ break;
+ case s.CENTER:
+ bmp.x = width - (w*scale) >> 1;
+ bmp.y = height - (h*scale) >> 1;
+ break;
+ case s.TOP_LEFT:
+ bmp.x = 0;
+ bmp.y = 0;
+ break;
+ case s.TOP_RIGHT:
+ bmp.x = width - w*scale;
+ bmp.y = 0;
+ break;
+ }
+ return bmp;
+ }
s.blur = function(stage) {
- var bg = new Container();
+ var bg = new createjs.Container();
var div = document.getElementById("background");
this.drawChild(div, bg);
@@ -74,7 +180,7 @@
stage.addChildAt(bg, 0);
stage.update();
- var bbf = new BoxBlurFilter(10,10, 1);
+ var bbf = new createjs.BoxBlurFilter(10,10, 1);
bbf.applyFilter(stage.canvas.getContext('2d'), 0,0,this.width,this.height);
stage.removeChild(bg);
}
@@ -95,8 +201,8 @@
var top = match ? match[1] : 0;
}
}
- var bmp = new Bitmap(url);
- bmp.sourceRect = new Rectangle(-left,-top,this.width,this.height);
+ var bmp = new createjs.Bitmap(url);
+ bmp.sourceRect = new createjs.Rectangle(-left,-top,this.width,this.height);
container.addChild(bmp);
}
@@ -106,7 +212,7 @@
* @method startDrag
*/
s.startDrag = function() {
- Atari.gameMediator.handleGameEvent(Atari.GameMediator.START_DRAG);
+ //Atari.gameMediator.handleGameEvent(Atari.GameMediator.START_DRAG);
}
/**
@@ -115,7 +221,7 @@
* @method stopDrag
*/
s.stopDrag = function() {
- Atari.gameMediator.handleGameEvent(Atari.GameMediator.STOP_DRAG);
+ //Atari.gameMediator.handleGameEvent(Atari.GameMediator.STOP_DRAG);
}
scope.GameUI = GameUI;
View
36 scripts/libs/gamelibs/Math2.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -178,10 +178,10 @@
* @static
*/
s.lineToBox = function(p1, p2, rect, checkIntersect) {
- var lowerLeft = new Point(rect.x, rect.y+rect.height);
- var upperRight = new Point(rect.x+rect.width, rect.y);
- var upperLeft = new Point( rect.x, rect.y );
- var lowerRight= new Point( rect.x+rect.width, rect.y+rect.height);
+ var lowerLeft = new createjs.Point(rect.x, rect.y+rect.height);
+ var upperRight = new createjs.Point(rect.x+rect.width, rect.y);
+ var upperLeft = new createjs.Point( rect.x, rect.y );
+ var lowerRight= new createjs.Point( rect.x+rect.width, rect.y+rect.height);
// check if it is inside
if (p1.x > lowerLeft.x && p1.x < upperRight.x && p1.y < lowerLeft.y && p1.y > upperRight.y &&
@@ -309,10 +309,36 @@
return true;
}
+ /**
+ * Determine if a number is inside of a range.
+ * @param {Number} value The value to check.
+ * @param {Number} low The low end of the range
+ * @param {Number} high The high end of the range
+ * @return {Boolean}
+ */
s.isBetween = function (value, low, high) {
return value >= low && value <= high;
}
+ /**
+ * Interpolate between two numbers. This helps find a point between two numbers. For example:
+ * <ul><li>Interpolating between 10 and 20 with 0.5 would result in 15.</li>
+ * <li>Interpolating between 10 and 20 with 0.25 would result in 12.5.</li>
+ * <li>Interpolating between 10 and 20 with 2 would result in 30.</li>
+ * <li>Interpolating between 10 and 20 with -0.5 would result in 5.</li>
+ * </ul>
+ * @param {Number} val1 The first number. It can be higher or lower than the second.
+ * @param {Number} val2 The second number.
+ * @param {Number} amount A percentage between the two numbers. The default is 0.5.
+ * A lower number will fall closer to the second value. You can optionally pass
+ * a number greater than one or less than zero to find values outside of the range.
+ * @return {Number} The derived value between the two points.
+ */
+ s.interpolate = function(val1, val2, amount) {
+ if (amount == null) { amount = 0.5; }
+ return (val2 - val1) * amount + val1;
+ }
+
scope.Math2 = Math2;
}(window.GameLibs))
View
4 scripts/libs/gamelibs/Parallax.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -90,7 +90,7 @@
}
this.setPosition(0.5, true);
- Ticker.addListener(this);
+ createjs.Ticker.addListener(this);
},
/**
View
2  scripts/libs/gamelibs/ParticleEmitter.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
4 scripts/libs/gamelibs/PerformanceMonitor.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -116,7 +116,9 @@
if(deltaT < 200 && deltaT > this.maxMs){
this.timeOnLow += deltaT;
if(this.timeOnLow > this.threshold) {
+ /*
Atari.trace("*** Low Quality Mode toggled.")
+ */
this.lowQualityMode = true;
this.callback(true);
createjs.Ticker.setFPS(30);
View
2  scripts/libs/gamelibs/Point2.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
4 scripts/libs/gamelibs/ScoreManager.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -33,6 +33,7 @@
* The current score.
* @property score
* @type Number
+ * @default 0
*/
score: 0,
@@ -40,6 +41,7 @@
* The score currently displayed.
* @property displayScore
* @type Number
+ * @default 0
* @protected
*/
displayScore: 0,
View
4 scripts/libs/gamelibs/SpriteSheetWrapper.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -29,7 +29,7 @@
Atari.trace("Error: Null object passed to SpriteSheetWrapper.");
return null;
}
- if (data.affected) { return new SpriteSheet(data); }
+ if (data.affected) { return new createjs.SpriteSheet(data); }
suffix = suffix || "";
var baseUrl = Atari.GameBootstrap.baseUrl + Atari.GameBootstrap.manifest.base + "src/" + suffix;
var images = data.images;
View
2  scripts/libs/gamelibs/StringUtils.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gamelibs/TexturePackerUtils.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
8 scripts/libs/gamelibs/input/ArcadeButton.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -102,7 +102,7 @@
}
if (image != null && image instanceof SpriteSheet) {
- this.buttonSprite = new BitmapAnimation(image);
+ this.buttonSprite = new createjs.BitmapAnimation(image);
this.buttonSprite.gotoAndStop(name);
var animations = image.getAnimations();
if (animations.indexOf(name+this.hoverSuffix)>-1) {
@@ -113,12 +113,12 @@
}
} else if (image != null) {
- this.buttonSprite = new Bitmap(image.src);
+ this.buttonSprite = new createjs.Bitmap(image.src);
this.buttonSprite.regX = image.regX;
this.buttonSprite.regY = image.regY;
}
- this.sprite = new Container();
+ this.sprite = new createjs.Container();
var hs = this.sprite;
if (hitArea != null) {
hs = new createjs.Shape();
View
4 scripts/libs/gamelibs/input/GamePad.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -434,7 +434,7 @@
*/
setButtonDown: function(code) {
if (this.downButtons[code] != true) {
- if (this.onButtonDown && !Ticker.isPaused) { this.onButtonDown(code); }
+ if (this.onButtonDown && !createjs.Ticker.isPaused) { this.onButtonDown(code); }
}
this.downButtons[code] = true;
},
View
20 scripts/libs/gamelibs/input/Joystick.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -166,7 +166,7 @@
}
img = images.thumb;
if (img) {
- this.thumb = new Bitmap(img.src);
+ this.thumb = new createjs.Bitmap(img.src);
this.thumb.regX = img.regX;
this.thumb.regY = img.regY;
}
@@ -193,7 +193,7 @@
},
draw: function() {
- var joystick = this.joystick = new Container();
+ var joystick = this.joystick = new createjs.Container();
if (this.autoHide || this.autoMove) {
joystick.alpha = 0.5;
@@ -205,7 +205,7 @@
// Draw images
var pad = this.pad;
if (pad == null) {
- var pad = new Shape();
+ var pad = new createjs.Shape();
var r = this.radius;
pad.graphics.f("#666").drawRoundRect(-r,-r,r*2,r*2,10).ef();
pad.graphics.f("#333").dc(0,0,15);
@@ -218,14 +218,14 @@
}
if (this.showStick) {
- this.stick = new Shape();
+ this.stick = new createjs.Shape();
joystick.addChild(this.stick);
}
var thumb = this.thumb;
if (thumb == null) {
- this.thumb = new Shape(
- new Graphics().f("f00").dc(0,0,30).ef()
+ this.thumb = new createjs.Shape(
+ new createjs.Graphics().f("f00").dc(0,0,30).ef()
);
}
joystick.addChild(this.thumb);
@@ -363,14 +363,16 @@
if (this.autoHide) { this.joystick.visible = false; }
this.setState(0,0);
this.currentDistance *= 0.5; // Reduce elastic
- Tween.get(this).to({currentDistance:0}, 500, Ease.getElasticOut(1,0.1)).call(this.handleTweenComplete, null, this);
+ createjs.Tween.get(this)
+ .to({currentDistance:0}, 500, createjs.Ease.getElasticOut(1,0.1))
+ .call(this.handleTweenComplete, null, this);
createjs.Ticker.addListener(this);
GameLibs.GameUI.stopDrag();
},
handleTweenComplete: function() {
- Ticker.removeListener(this);
+ createjs.Ticker.removeListener(this);
},
tick: function() {
View
26 scripts/libs/gamelibs/input/Throttle.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -123,41 +123,41 @@
if (params.mininumDistance != null) { this.minimumDistance = params.minimumDistance; }
this.isVertical = (direction == s.VERTICAL);
- this.dragProps = new Point();
+ this.dragProps = new createjs.Point();
// Images
- if (images != null && images instanceof SpriteSheet) {
+ if (images != null && images instanceof createjs.SpriteSheet) {
this.spritesheet = images;
var suffix = params.suffix || "";
var names = this.spritesheet.getAnimations();
if (names.indexOf("pad"+suffix) > -1) {
- this.pad = new BitmapAnimation(this.spritesheet);
+ this.pad = new createjs.BitmapAnimation(this.spritesheet);
this.pad.gotoAndStop("pad"+suffix);
}
if (names.indexOf("thumb"+suffix) > -1) {
- this.thumb = new BitmapAnimation(this.spritesheet);
+ this.thumb = new createjs.BitmapAnimation(this.spritesheet);
this.thumb.gotoAndStop("thumb"+suffix);
}
} else if (images != null) {
var img = images.pad;
if (img) {
- this.pad = new Bitmap(img.src);
+ this.pad = new createjs.Bitmap(img.src);
this.pad.regX = img.regX;
this.pad.regY = img.regY;
}
img = images.thumb;
if (img) {
- this.thumb = new Bitmap(img.src);
+ this.thumb = new createjs.Bitmap(img.src);
this.thumb.regX = img.regX;
this.thumb.regY = img.regY;
}
}
- this.sprite = new Container();
+ this.sprite = new createjs.Container();
var hs = this.sprite;
if (this.autoHide) {
var hs = new createjs.Shape();
- var ha = this.hitArea = new Shape(new Graphics().f("#000000").dr(hitArea.x, hitArea.y, hitArea.width, hitArea.height));
+ var ha = this.hitArea = new createjs.Shape(new createjs.Graphics().f("#000000").dr(hitArea.x, hitArea.y, hitArea.width, hitArea.height));
hs.hitArea = ha;
this.sprite.addChild(hs);
}
@@ -166,7 +166,7 @@
},
draw: function() {
- var throttle = this.throttle = new Container();
+ var throttle = this.throttle = new createjs.Container();
if (this.autoHide) {
throttle.visible = false;
throttle.alpha = 0.5; //TODO: Make this a param.
@@ -174,14 +174,14 @@
var pad = this.pad;
if (pad == null) {
- var pad = new Shape(new Graphics().f("#666").dr(-50,-50,100,100).f("#000").dr(-10,-45, 20, 90));
+ var pad = new createjs.Shape(new createjs.Graphics().f("#666").dr(-50,-50,100,100).f("#000").dr(-10,-45, 20, 90));
if (!this.isVertical) { pad.rotation = 90; }
}
throttle.addChild(pad);
var thumb = this.thumb;
if (thumb == null) {
- var thumb = this.thumb = new Shape(new Graphics().f("#f00").dc(0,0,30));
+ var thumb = this.thumb = new createjs.Shape(new createjs.Graphics().f("#f00").dc(0,0,30));
}
throttle.addChild(thumb);
@@ -254,7 +254,7 @@
this.sprite.visible = false;
this.thumb.x = this.thumb.y = 0;
} else {
- Tween.get(this.thumb).to({x:0, y:0}, 300, Ease.bounceOut);
+ createjs.Tween.get(this.thumb).to({x:0, y:0}, 300, createjs.Ease.bounceOut);
}
var pad = GameLibs.GamePad;
View
2  scripts/libs/gamelibs/input/TouchBar.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gamelibs/multiplayer/FramePacket.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
127 scripts/libs/gamelibs/multiplayer/GameInfo.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -17,9 +17,10 @@
/**
* The GameInfo class provides information about the current single or multiplayer game.
* @class MultiPlayer
+ * @constructor
*/
- function GameInfo(gameId, mode, roomName, players, multiplayer, gameModes) {
- this.initialize(gameId, mode, roomName, players, multiplayer, gameModes);
+ function GameInfo(gameId, mode, roomName, players, multiplayer, gameModes, platform, width, height) {
+ this.initialize(gameId, mode, roomName, players, multiplayer, gameModes, platform, width, height);
}
var s = GameInfo;
@@ -42,6 +43,20 @@
s.MULTI_PLAYER = "multiPlayer";
+
+ // Platform ENUMs
+ s.PLATFORM_DESKTOP = "desktop";
+ s.PLATFORM_WP7 = "wp7";
+ s.PLATFORM_WP8 = "wp8"; // Might be fine to use WP
+ s.PLATFORM_IPHONE = "iPhone";
+ s.PLATFORM_IPHONE3 = "iPhone3";
+ s.PLATFORM_IPHONE_PINNED = "iPhonePinned";
+ s.PLATFORM_IPHONE3_PINNED = "iPhone3Pinned";
+
+ s.QUALITY_NORMAL = 0;
+ s.QUALITY_HIGH = 1;
+ s.QUALITY_LOW = 2;
+
var p = GameInfo.prototype = {
/**
@@ -111,8 +126,56 @@
*/
selectedGameMode: 0,
+ /**
+ * The width of the game in pixels. This is set by the game shell.
+ * @property width
+ * @type Number
+ * @default 1024
+ */
+ width: 1024,
+
+ /**
+ * The height of the game in pixels. This is set by the game shell.
+ * @property height
+ * @type Number
+ * @default 622
+ */
+ height: 622,
+
+ /**
+ * The amount the viewport is scaled to accommodated different pixel densities on devices. For example,
+ * the iPhone 4+ needs to be scaled to 0.5 to run properly.
+ * @property scaleFactor
+ * @type Number
+ * @default 1
+ */
+ scaleFactor: 1,
- initialize: function(gameId, mode, roomName, players, multiPlayerGame, gameModes) {
+ /**
+ * The platform the game is running on. This is detected by the game framework, and injected.
+ * @property platform
+ * @type Number
+ * @default null
+ */
+ platform: null,
+
+ /**
+ * The game quality is determined by the rough resolution and platform, which provides an
+ * idea on how much to scale assets in a game to be reasonable.
+ * <ul>
+ * <li>Normal (0): This is the default, and what is shown on the desktop (1024x622)</li>
+ * <li>High (1): A device with high resolution, it is recommended to draw assets a little larger (1.5x or so).
+ * Devices with high resolution include the iPhone 4+, and Windows Phone 8 devices with 720p resolution.
+ * <li>Low (2): A device with low resolution, it is recommended to draw assets a little smaller (0.75x).
+ * Devices with low resolution include Windows Phone 7 & 8 (WVGA), and iPhone 3GS and lower.
+ * </ul>
+ * @property quality
+ * @type Number
+ * @default QUALITY_NORMAL (0)
+ */
+ quality: s.QUALITY_NORMAL,
+
+ initialize: function(gameId, mode, roomName, players, multiPlayerGame, gameModes, platform, width, height) {
this.gameId = gameId;
this.mode = mode || s.SINGLE_PLAYER;
this.roomName = roomName;
@@ -122,6 +185,62 @@
this.maxPlayers = multiPlayerGame.maxPlayers;
}
this.gameModes = gameModes;
+
+ // Set the size if it was passed in.
+ if (width != null) { this.width = width; }
+ if (height != null) { this.height = height; }
+
+ //TODO: Platform will have to be determined by the system.
+ this.platform = platform;
+ switch (platform) {
+ case s.PLATFORM_DESKTOP:
+ this.width = 1024;
+ this.height = 622;
+ break;
+
+ case s.PLATFORM_WP7:
+ this.width = 800;
+ this.height = 410;
+ this.scaleFactor = 0.6;
+ this.quality = s.QUALITY_LOW;
+ break;
+
+ case s.PLATFORM_WP8:
+ //TODO: Might have WVGA resolution as well, which is low-res
+ this.width = 1280;
+ this.height = 700;
+ this.scaleFactor = 0.6;
+ this.quality = s.QUALITY_HIGH;
+ break;
+
+ /* Mobile with browser chrome
+ case s.PLATFORM_IPHONE:
+ this.width = 960;
+ this.height = 396;
+ this.scaleFactor = 0.5;
+ this.quality = s.QUALITY_HIGH;
+ break;
+
+ case s.PLATFORM_IPHONE3:
+ this.width = 480;
+ this.height = 196;
+ this.quality = s.QUALITY_LOW;
+ break;
+ case s.PLATFORM_IPHONE3_PINNED:
+ this.width = 480;
+ this.height = 320;
+ this.quality = s.QUALITY_LOW;
+ break;
+ */
+
+ case s.PLATFORM_IPHONE:
+ this.width = 960;
+ this.height = 640;
+ this.scaleFactor = 0.5;
+ this.quality = s.QUALITY_HIGH;
+ break;
+
+ }
},
/**
View
2  scripts/libs/gamelibs/multiplayer/GamePacket.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
21 scripts/libs/gamelibs/multiplayer/MultiPlayerGame.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -145,11 +145,10 @@
var isConnected = (s.socket != null);
if(!isConnected){
try {
- s.socket = io.connect(s.SOCKET_URL);
+ s.socket = io.connect(s.SOCKET_URL, {"force new connection": true});
} catch(e){
Atari.trace("ERROR: Unable to connect to multiplayer server.");
if (this.onConnectionError) { this.onConnectionError(e); }
-
return;
}
} else {
@@ -191,6 +190,7 @@
},
cleanupSocket: function() {
+ if (!s.socket) { return; }
s.socket.removeAllListeners("connect");
s.socket.removeAllListeners("startCountDown");
s.socket.removeAllListeners("gameReady");
@@ -203,6 +203,7 @@
s.socket.removeAllListeners("broadcast");
s.socket.removeAllListeners("sync");
s.socket.removeAllListeners("error");
+ s.socket = null;
},
@@ -219,7 +220,7 @@
//[SB] If no currentPlayer is defined, we'll inject one.
// This is primarily a debugging hook so that the development site will work without a logged in user, should not be needed in production code.
if(!player){
- var id = "Guest" + (Math.random() * 10000 |0);
+ var id = "Guest" + (Math.random() * 10000 | 0);
var player = new GameLibs.Player(id, id);
player.isMe = true;
this.gameInfo.players = [player];
@@ -227,7 +228,7 @@
//Ask server to setup a game, it will create a room if one is needed, or add us to an existing room if possible.
s.socket.emit("join", {
gameType: this.gameInfo.gameId,
- roomName: this.gameInfo.roomName,
+ roomName: this.gameInfo.roomName, //Atari.developerMode ? "A84" : this.gameInfo.roomName,
userId:player.id,
nickname:player.name,
picture:player.getAvatar()
@@ -300,8 +301,11 @@
},
destroy: function() {
+ if (!s.socket) { return; }
Atari.trace("[MultiplayerGame] Destroy");
s.socket.emit("leave");
+ s.socket.emit("disconnect");
+ this.cleanupSocket();
},
/*************************************************
@@ -399,13 +403,14 @@
*/
handlePlayerLeave: function(data) {
for(var i = 0, l = this.gameInfo.players.length; i < l; i++){
- if(this.gameInfo.players[i].id == data.nickname){
+ if(this.gameInfo.players[i].id == data.userId){
this.gameInfo.players.splice(i, 1);
Atari.trace("[MultiplayerGame] PlayerLeave: Player '"+data.nickname+"' Exited Room");
break;
}
}
- if (this.onPlayersChanged) { this.onPlayersChanged(this.gameInfo.players); }
+ if (this.onPlayerLeave) { this.onPlayerLeave(data.userId); }
+
},
/**
@@ -416,7 +421,7 @@
*/
handleGameCanceled: function() {
if (this.onGameCanceled) { this.onGameCanceled(); }
- s.socket.emit("leave");
+ if(s.socket){ s.socket.emit("leave"); }
Atari.trace("[MultiplayerGame] Game Canceled - Leaving Room");
},
View
8 scripts/libs/gamelibs/multiplayer/Player.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -38,7 +38,7 @@
"http://graph.facebook.com/grant.skinner/picture?type=square",
"http://graph.facebook.com/bhendel1/picture?type=square"
];
- s.DEFAULT_AVATAR = "http://images.sodahead.com/profiles/002085491/silhouette_man_square.gif";
+ s.DEFAULT_AVATAR = "/sites/all/themes/atari_arcade/static/images/avatar-computer.jpg";
var p = Player.prototype = {
@@ -111,8 +111,8 @@
getAvatar: function() {
if (this.avatar != null && this.avatar != "") {
return this.avatar;
- } else if (Atari.developerMode) {
- return s.DEVELOPER_AVATARS[Math.random() * s.DEVELOPER_AVATARS.length | 0];
+ //} else if (Atari.developerMode) {
+ // return s.DEVELOPER_AVATARS[Math.random() * s.DEVELOPER_AVATARS.length | 0];
} else {
return s.DEFAULT_AVATAR;
}
View
6 scripts/libs/gametemplate/manifest.json
@@ -16,9 +16,9 @@
"src/Game.js"
],
- "assets": [
+ "assets": [
{"id":"assetId", "src":"data/data.json"},
- {"id":"audio", "src":"audio/background.mp3", "data":3}
- "img/background.jpg",
+ {"id":"audio", "src":"audio/background.mp3", "data":3},
+ "img/background.jpg"
]
}
View
125 scripts/libs/gametemplate/src/scripts/Game-STUB.js
@@ -1,125 +0,0 @@
-/*
-* Atari Arcade SDK
-* Developed by gskinner.com in partnership with Atari
-* Visit http://atari.com/arcade/developers for documentation, updates and examples.
-*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-*/
-
-(function(scope) {
-
- function Game() {}
-
- var s = Game;
- s.assets;
- s.width;
- s.height;
-
- var p = Game.prototype = {
- // props
- assets: null,
- stage: null,
- gameInfo: null,
-
-/*************************************************
- * CORE ENGINE
- **************************************************/
-
- initialize: function(assets, stage, gameInfo) {
- this.assets = Game.assets = assets;
- this.stage = stage;
- this.gameInfo = gameInfo;
-
- Game.width = stage.canvas.width;
- Game.height = stage.canvas.height;
-
- new GameLibs.FPSMeter(stage);
- },
-
- startGame: function() {
- // Just do it!
- },
-
- tick: function() {
- this.camera.tick();
- this.tank.tick();
- },
-
-/*************************************************
- * MULTIPLAYER
- **************************************************/
-
- //Apply full game state to all players including yourself.
- sync: function(packet) {
-
- },
-
- //Get syncPacket (Full State) for the entire game. This may never return null.
- getGamePacket: function() {
-
- },
-
-
- //Apply framePackets to other players
- updatePlayers: function(packets) {
-
- },
-
- //Get framePacket for yourself. This may frequently return null.
- getFramePacket: function() {
-
- },
-
-
-
-/*************************************************
- * Public API for Framework
- **************************************************/
- pause: function(paused) {
-
- },
-
- continueGame: function() {
-
- },
-
- restart: function() {
-
- },
-
- destroy: function() {
-
- },
-
- getScore: function() {
- return null;
- },
-
-
-/*************************************************
- * Framework Callbacks (these will all be injected for you)
- **************************************************/
-
- onGameOver: null,
-
- onLevelComplete: null,
-
- onGameComplete: null,
-
- onLifeLost: null,
-
- onGameAchievement: null,
-
- onGameError: null,
-
- onGameNotification: null
-
- }
- scope.Game = Game;
-
-}(window.Atari.currentGame))
View
20 scripts/libs/gametemplate/src/scripts/Game.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -96,6 +96,16 @@
},
/**
+ * The game has instructed the game to either reduce the experience due to bad FPS, or resume the high=
+ * quality experience as framerate has returned to normal.
+ * @method reduceFrameRate
+ * @param {Boolean} reduce If the game should reduce the experience (true), or resume it (false).
+ */
+ reduceFrameRate: function(reduce) {
+
+ },
+
+ /**
* The game is getting cleaned up, in preparation for a new game. Do any tasks
* that need to happen (stop audio, timers, etc). <b>This method is required.</b>
* @method destroy
@@ -236,12 +246,10 @@
},
/**
- * The game has instructed the game to either reduce the experience due to bad FPS, or resume the high=
- * quality experience as framerate has returned to normal.
- * @method reduceFrameRate
- * @param {Boolean} reduce If the game should reduce the experience (true), or resume it (false).
+ * A player has been disconnected from the current multiplayer game.
+ * @method playerDisconnected
*/
- reduceFrameRate: function(reduce) {
+ removePlayer: function(playerId) {
}
View
2  scripts/libs/gskinner/LocalStorage.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gskinner/ProximityManager.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gskinner/Rnd.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
2  scripts/libs/gskinner/StringUtils.js
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
View
39 scripts/libs/gskinner/VendorPrefixUtil.js
@@ -0,0 +1,39 @@
+(function (scope) {
+
+ var VendorPrefixUtil = function () { };
+
+ var p = VendorPrefixUtil.prototype;
+ var s = VendorPrefixUtil;
+ var cache = {};
+
+ var prefexs = ["webkit", "Moz", "ms", "O"];
+
+ var style = document.createElement('div').style;
+
+ s.getName = function(prop) {
+ var startProp = prop;
+ prop = prop.substr(0, 1).toUpperCase() + prop.substr(1);
+
+ if (cache[prop]) { return cache[prop]; }
+
+ for (var i= 0,l=prefexs.length;i<l;i++) {
+ var newProp = null;
+ var prefex = prefexs[i];
+ if (prefex + prop in style) {
+ newProp = prefex + prop;
+ break;
+ }
+ }
+
+ //We never found a prop. so return what was passed in.
+ if (!newProp) {
+ newProp = startProp;
+ }
+
+ cache[prop] = newProp;
+ return newProp;
+ };
+
+ scope.VendorPrefixUtil = VendorPrefixUtil;
+
+}(window));

0 comments on commit 00b0f69

Please sign in to comment.
Something went wrong with that request. Please try again.