Skip to content
Browse files

Improve UI of editor - provide picture previews for each tool, put to…

…ols in collapsbile categories
  • Loading branch information...
1 parent b9af3dd commit fc5a3845f7113c3af5ef81ba277432b3fcb5e458 Jono Xia committed
Showing with 254 additions and 75 deletions.
  1. +1 −1 offline_level.js
  2. +65 −0 playoffline.html
  3. +12 −2 strings.json
  4. +21 −4 templates/design.html
  5. +6 −6 webclient_utils.js
  6. +97 −24 webrunner-edit.js
  7. +14 −11 webrunner-mobs.js
  8. +3 −3 webrunner-play.js
  9. +35 −24 webrunner-world.js
View
2 offline_level.js
@@ -1,2 +1,2 @@
-var offlineLevelData = '{"worldData":[{"x":668,"y":22,"width":89,"height":26,"type":"semiplatform"},{"x":272,"y":201,"width":105,"height":25,"type":"semiplatform"},{"x":1383,"y":150,"width":32,"height":32,"type":"trinket"},{"x":1737,"y":240,"width":32,"height":32,"type":"trinket"},{"x":1346,"y":189,"width":90,"height":28,"type":"semiplatform"},{"x":1537,"y":345,"width":79,"height":20,"type":"semiplatform"},{"x":1721,"y":278,"width":73,"height":22,"type":"semiplatform"},{"x":1542,"y":217,"width":73,"height":26,"type":"semiplatform"},{"x":1309,"y":378,"width":105,"height":99,"type":"platform"},{"x":870,"y":408,"width":39,"height":39,"type":"platform"},{"x":880,"y":449,"width":427,"height":14,"type":"platform"},{"x":1096,"y":384,"width":91,"height":49,"type":"shrimp"},{"x":1170,"y":315,"width":0,"height":0,"type":"platform"},{"x":837,"y":-28,"width":781,"height":9,"type":"platform"},{"x":658,"y":108,"width":106,"height":207,"type":"platform"},{"x":5,"y":220,"width":23,"height":237,"type":"platform"},{"x":30,"y":448,"width":848,"height":10,"type":"platform"},{"x":58,"y":198,"width":32,"height":32,"type":"trinket"},{"x":58,"y":156,"width":32,"height":32,"type":"trinket"},{"x":59,"y":236,"width":32,"height":32,"type":"trinket"},{"x":804,"y":-63,"width":53,"height":32,"type":"platform"},{"x":517,"y":160,"width":100,"height":13,"type":"magic_carpet"},{"x":1598,"y":-65,"width":51,"height":33,"type":"platform"},{"x":1323,"y":-68,"width":32,"height":32,"type":"trinket"},{"x":1218,"y":-82,"width":91,"height":49,"type":"shrimp"},{"x":911,"y":-70,"width":32,"height":32,"type":"trinket"},{"x":1110,"y":-68,"width":32,"height":32,"type":"trinket"},{"x":1564,"y":181,"width":32,"height":32,"type":"trinket"},{"x":1326,"y":338,"width":32,"height":32,"type":"trinket"},{"x":1375,"y":345,"width":32,"height":32,"type":"trinket"},{"x":1561,"y":304,"width":32,"height":32,"type":"trinket"},{"x":1015,"y":147,"width":87,"height":29,"type":"semiplatform"},{"x":1049,"y":105,"width":32,"height":32,"type":"trinket"},{"x":263,"y":359,"width":90,"height":25,"type":"semiplatform"},{"x":412,"y":285,"width":99,"height":27,"type":"semiplatform"},{"x":1520,"y":-99,"width":64,"height":64,"type":"goal"}],"startX":45,"startY":379,"bgUrl":"","tilesetUrl":"http://evilbrainjono.net/platformer/tileset.png","musicUrl":"http://evilbrainjono.net/platformer/sfx/Bach.ogg","goalUrl":"http://www.leehansen.com/clipart/Themes/Pirates/images/treasure-chest.gif"}';
+var offlineLevelData = '{"worldData":[{"x":668,"y":22,"width":89,"height":26,"type":"semiplatform"},{"x":272,"y":201,"width":105,"height":25,"type":"semiplatform"},{"x":1383,"y":150,"width":32,"height":32,"type":"trinket"},{"x":1737,"y":240,"width":32,"height":32,"type":"trinket"},{"x":1346,"y":189,"width":90,"height":28,"type":"semiplatform"},{"x":1537,"y":345,"width":79,"height":20,"type":"semiplatform"},{"x":1721,"y":278,"width":73,"height":22,"type":"semiplatform"},{"x":1542,"y":217,"width":73,"height":26,"type":"semiplatform"},{"x":1309,"y":378,"width":105,"height":99,"type":"platform"},{"x":870,"y":408,"width":39,"height":39,"type":"platform"},{"x":880,"y":449,"width":427,"height":14,"type":"platform"},{"x":1096,"y":384,"width":91,"height":49,"type":"shrimp"},{"x":1170,"y":315,"width":0,"height":0,"type":"platform"},{"x":837,"y":-28,"width":781,"height":9,"type":"platform"},{"x":658,"y":108,"width":106,"height":207,"type":"platform"},{"x":5,"y":220,"width":23,"height":237,"type":"platform"},{"x":30,"y":448,"width":848,"height":10,"type":"platform"},{"x":58,"y":198,"width":32,"height":32,"type":"trinket"},{"x":58,"y":156,"width":32,"height":32,"type":"trinket"},{"x":59,"y":236,"width":32,"height":32,"type":"trinket"},{"x":804,"y":-63,"width":53,"height":32,"type":"platform"},{"x":517,"y":160,"width":100,"height":13,"type":"magic_carpet"},{"x":1598,"y":-65,"width":51,"height":33,"type":"platform"},{"x":1323,"y":-68,"width":32,"height":32,"type":"trinket"},{"x":1218,"y":-82,"width":91,"height":49,"type":"shrimp"},{"x":911,"y":-70,"width":32,"height":32,"type":"trinket"},{"x":1110,"y":-68,"width":32,"height":32,"type":"trinket"},{"x":1564,"y":181,"width":32,"height":32,"type":"trinket"},{"x":1326,"y":338,"width":32,"height":32,"type":"trinket"},{"x":1375,"y":345,"width":32,"height":32,"type":"trinket"},{"x":1561,"y":304,"width":32,"height":32,"type":"trinket"},{"x":1015,"y":147,"width":87,"height":29,"type":"semiplatform"},{"x":1049,"y":105,"width":32,"height":32,"type":"trinket"},{"x":263,"y":359,"width":90,"height":25,"type":"semiplatform"},{"x":412,"y":285,"width":99,"height":27,"type":"semiplatform"},{"x":1520,"y":-99,"width":64,"height":64,"type":"goal"}],"startX":45,"startY":379,"bgUrl":"","tilesetUrl":"","musicUrl":"","goalUrl":""}';
View
65 playoffline.html
@@ -24,6 +24,71 @@
<audio id="crunch-sfx" preload="auto" autobuffer="true" src="sfx/crunch.ogg"></audio>
<audio id="kaching-sfx" preload="auto" autobuffer="true" src="sfx/kaching.ogg"></audio>
+ <span id="localized_strings" style="display:none">
+ {
+ "_runjumpbuild": "ラン・ジャンプ・ビルド",
+ "_all_levels": "全てのゲーム",
+ "_welcome": "ようこそ",
+ "_published_levels": "公開されているステージ",
+ "_title": "タイトル",
+ "_last_modified": "更新日時",
+ "_creator": "作者",
+ "_your_time": "あなたのベストタイム",
+ "_best_time": "ベストタイム",
+ "_your_levels": "あなたの状況",
+ "_published": "公開",
+ "_new_level_name": "新しいステージ",
+ "_create_level": "ステージを作る",
+ "_your_player_data": "プレイヤーのデータ",
+ "_player_name": "名前",
+ "_your_avatar": "あなたのキャラクタ",
+ "_save_changes": "保存する",
+ "_play": "チャレンジする",
+ "_edit": "変更する",
+ "_hi": "おおい",
+ "_level_name": "このステージは",
+ "_game_instructions": "矢印キーで動く。スペースバーで跳ぶ。",
+ "_other_levels": "他のステージ",
+ "_time": "時間",
+ "_useless_trinkets": "お宝",
+ "_winning": "やったね!大成功だ!",
+ "_saving_score": "スコア保存中。。。",
+ "_lose_monster": "食べられたよ。。",
+ "_reload_play_again": "リロードして再チャレンジ!",
+ "_lose_falling": "落ちたよ。。",
+ "_level_designer": "ステージの設計",
+ "_play_this_level": "このステージをチャレンジ!",
+ "_background_img_url": "背景画像のURL",
+ "_tileset_url": "タイルセットのURL",
+ "_goal_img_url": "ゴール画像のURL",
+ "_music_url": "BGMのURL",
+ "_gravity": "重力",
+ "_ground_friction": "摩擦",
+ "_air_friction": "空気抵抗",
+ "_ground_accel": "地上での加速度",
+ "_air_accel": "空での加速度",
+ "_ground_decel": "地上での減速度",
+ "_air_decel": "空での減速度",
+ "_jump_power": "跳躍のパワー",
+ "_top_speed": "最高速度",
+ "_eraser_tool": "消しゴムツール",
+ "_eraser_tool_exp": "(消したい物をクリックして)",
+ "_scroll_tool": "スクロールツール",
+ "_scroll_tool_exp": "(ステージをスクロールするためにドラッグして)",
+ "_start_loc_tool": "スタート設置ツール",
+ "_goal_loc_tool": "ゴール設置ツール",
+ "_publish": "このステージを公開する",
+ "_lang_pref": "言語",
+ "_this_language": "日本語",
+ "_you": "あなた",
+ "_nobody": "誰もいない",
+ "_nobody_yet": "まだ誰もクリアしていません",
+ "_published_yes": "公開中",
+ "_published_no": "未公開",
+ "_other_player_score": "%(player)s さんの成績:%(time)s お宝 %(trinkets)d 個",
+ "_your_score": "%(time)s お宝 %(trinkets)d 個"
+}
+ </span>
</body></html>
View
14 strings.json
@@ -60,7 +60,12 @@
"_published_yes": "Yes",
"_published_no": "No",
"_other_player_score": "%(time)s by %(player)s with %(trinkets)d trinkets",
- "_your_score": "%(time)s with %(trinkets)d trinkets"
+ "_your_score": "%(time)s with %(trinkets)d trinkets",
+
+ "_obstacle_tools": "",
+ "_monster_tools": "",
+ "_powerup_tools": "",
+ "_show_hide": ""
},
"jp": {
"_runjumpbuild": "ラン・ジャンプ・ビルド",
@@ -123,7 +128,12 @@
"_published_yes": "公開中",
"_published_no": "未公開",
"_other_player_score": "%(player)s さんの成績:%(time)s お宝 %(trinkets)d 個",
- "_your_score": "%(time)s お宝 %(trinkets)d 個"
+ "_your_score": "%(time)s お宝 %(trinkets)d 個",
+
+ "_obstacle_tools": "",
+ "_monster_tools": "",
+ "_powerup_tools": "",
+ "_show_hide": ""
}
}
View
25 templates/design.html
@@ -7,6 +7,11 @@
<script src="webrunner-world.js"></script>
<script src="webrunner-mobs.js"></script>
<script src="webrunner-edit.js"></script>
+ <style>
+ .hidden-panel {
+ display: none;
+ }
+ </style>
</head>
<body>
<canvas style="float: left" id="design-canvas"
@@ -18,9 +23,10 @@
<hr/>
<label for="level-bg-url">${_background_img_url}:</label><input type="text" id="level-bg-url"/><br>
<label for="level-tileset-url">${_tileset_url}:</label><input type="text" id="level-tileset-url"/><br>
- <label for="level-goal-url">${_goal_img_url}:</label><input type="text" id="level-goal-url"/><br>
<label for="level-music-url">${_music_url}:</label><input type="text" id="level-music-url"/><br>
- <div id="physics-props">
+
+ ${_physics}<button onclick="showhide('physics-props');">${_show_hide}</button>
+ <div id="physics-props" class="hidden-panel">
<label for="gravity">${_gravity}:</label><input type="text" id="gravity"/><br>
<label for="groundFriction">${_ground_friction}:</label><input type="text" id="groundFriction"/><br>
<label for="airFriction">${_air_friction}:</label><input type="text" id="airFriction"/><br>
@@ -31,6 +37,7 @@
<label for="jump-power">${_jump_power}:</label><input type="text" id="jumpPower"/><br>
<label for="top-speed">${_top_speed}:</label><input type="text" id="topSpeed"/><br>
</div>
+
<hr/>
<input type="radio" name="tools" value="eraser" id="eraser-tool"/>
<label for="eraser-tool">${_eraser_tool} ${_eraser_tool_exp}</label><br>
@@ -40,11 +47,21 @@
<label for="start-tool">${_start_loc_tool}</label><br>
<input type="radio" name="tools" value="goal" id="goal-tool"/>
<label for="goal-tool">${_goal_loc_tool}</label><br>
+ <label for="level-goal-url">${_goal_img_url}:</label><input type="text" id="level-goal-url"/><br>
<hr/>
- <div id="more-tools"></div>
+ <div id="more-tools">
+ ${_obstacle_tools} <button onclick="showhide('more-obstacle-tools');">${_show_hide}</button>
+ <div id="more-obstacle-tools" class="hidden-panel">
+ </div>
+ ${_monster_tools} <button onclick="showhide('more-monster-tools');">${_show_hide}</button>
+ <div id="more-monster-tools" class="hidden-panel">
+ </div>
+ ${_powerup_tools} <button onclick="showhide('more-powerup-tools');">${_show_hide}</button>
+ <div id="more-powerup-tools" class="hidden-panel">
+ </div>
+ </div>
<input type="checkbox" id="publish"/><label for="publish">${_publish}</label>
<button onclick="saveChanges();">${_save_changes}</button><br>
</div>
-
</body>
</html>
View
12 webclient_utils.js
@@ -19,11 +19,11 @@ function playSfx(tagId) {
// shim layer with setTimeout fallback
// Written by Paul Irish
window.requestAnimFrame = (function(){
- return window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
@@ -84,7 +84,7 @@ AssetLoader.prototype = {
if (self._thingsLoaded == self._thingsToLoad) {
callback();
}
- }
+ };
thing.tag.src = thing.url;
})(this._things[t]);
}
View
121 webrunner-edit.js
@@ -1,3 +1,4 @@
+// TODO zoom function!!
function adjustToScreen() {
var screenWidth = window.innerWidth;
@@ -8,6 +9,20 @@ function adjustToScreen() {
$("#design-canvas").attr("width", TheWorld.canvasWidth);
$("#design-canvas").attr("height", TheWorld.canvasHeight);
+
+ $("#tools").css("max-width", screenWidth * 0.2);
+ $("#tools").attr("max-width", screenWidth * 0.2);
+ $("#tools").attr("width", screenWidth * 0.2);
+ redraw();
+}
+
+function showhide(id) {
+ var div = $("#" + id);
+ if (div.css("display") != "none") {
+ div.css("display", "none");
+ } else {
+ div.css("display", "block");
+ }
}
function GenericPlacementTool(cons) {
@@ -128,7 +143,7 @@ GenericRectangleTool.prototype = {
var rect = this.defineRect(pt.x, pt.y);
var context = $("#design-canvas")[0].getContext("2d");
context.strokeStyle = "black";
- context.strokeRect(TheWorld.worldXToScreenX(rect.l),
+ context.strokeRect(TheWorld.worldXToScreenX(rect.l),
TheWorld.worldYToScreenY(rect.t),
rect.w, rect.h);
}
@@ -245,7 +260,7 @@ function redraw() {
function saveChanges() {
// AJAX Post json data to save-level.py
var URL = "save-level.py";
-
+
var title = gup("level");
var i, objs;
var allData = {};
@@ -285,15 +300,15 @@ function saveChanges() {
allData.physicsConsts = {};
for (var prop in PhysicsConstants) {
var fieldVal = parseInt($("#" + prop).val());
- allData.physicsConsts[prop] = isNaN(fieldVal) ?
+ allData.physicsConsts[prop] = isNaN(fieldVal) ?
PhysicsConstants[prop] : fieldVal;
}
allData.published = $("#publish").attr("checked") ? "true":"false";
- $.ajax({type: "POST",
+ $.ajax({type: "POST",
url: URL,
data: {levelName: title,
- levelData: JSON.stringify(allData)},
+ levelData: JSON.stringify(allData)},
success: function(data, textStatus, jqXHR) {
$("#debug").html(data);
},
@@ -306,21 +321,74 @@ function saveChanges() {
$("#debug").html("Saving, don't close the page...");
}
+function makeFancyButton(constructorName) {
+ // TODO instead of a radio button, name, and canvas, how about
+ // a single canvas with the image and name both on it, that acts like a button
+ // when you click anywhere
+ // TODO instead of using constructorName as the name, use a localized description
+ // TODO images for the scroll, startloc, and eraser tools?
+ var button = $("<input></input>");
+ button.attr("type", "radio");
+ button.attr("name", "tools");
+ button.attr("value", constructorName);
+ button.attr("id", constructorName);
+ var label = $("<label></label>");
+ label.attr("for", constructorName);
+ label.html(constructorName + " tool");
+ var cons = ConstructorRegistry.getConstructor(constructorName);
+ var proto = cons.prototype;
+ var minicanvas = $("<canvas></canvas>");
+ var width = proto.width ? proto.width: 64;
+ var height = proto.height ? proto.height: 64;
+ minicanvas.attr("width", width);
+ minicanvas.attr("height", height);
+
+ // Put the tool into either the monster, obstacle, or powerup category, according to its
+ // classification
+ var container;
+ switch(proto.classification) {
+ case "monster":
+ container = $("#more-monster-tools");
+ break;
+ case "obstacle":
+ container = $("#more-obstacle-tools");
+ break;
+ case "powerup":
+ container = $("#more-powerup-tools");
+ break;
+ default:
+ container = $("#more-tools");
+ break;
+ }
+
+ container.append(button);
+ container.append(label);
+ container.append(minicanvas);
+ // let's try drawing that sucker
+ var loader = new AssetLoader();
+ var ctx = minicanvas[0].getContext("2d");
+ var obj = new cons(loader);
+ loader.loadThemAll( function() {
+ obj.boxInit(0, 0, width, height);
+ obj.draw(ctx);
+ });
+ container.append("<br/>");
+}
+
$(document).ready(function() {
var title = gup("level");
- adjustToScreen();
// Handle mouseclicks on canvas according to selected tool:
$("#design-canvas").bind("mousedown", function(evt) {
- pos = canvasCoords(evt);
+ var pos = canvasCoords(evt);
g_selectedTool.onMouseDown(pos.x, pos.y);
});
$("#design-canvas").bind("mousemove", function(evt) {
- pos = canvasCoords(evt);
+ var pos = canvasCoords(evt);
g_selectedTool.onMouseMove(pos.x, pos.y);
});
$("#design-canvas").bind("mouseup", function(evt) {
- pos = canvasCoords(evt);
+ var pos = canvasCoords(evt);
g_selectedTool.onMouseUp(pos.x, pos.y);
redraw();
});
@@ -328,19 +396,9 @@ $(document).ready(function() {
// Create tools for all the object constructors we know about
var names = ConstructorRegistry.listNames();
for (var i = 0; i < names.length; i++) {
- var button = $("<input></input>");
- button.attr("type", "radio");
- button.attr("name", "tools");
- button.attr("value", names[i]);
- button.attr("id", names[i]);
- var label = $("<label></label>");
- label.attr("for", names[i]);
- label.html(names[i] + " tool");
- $("#more-tools").append(button);
- $("#more-tools").append(label);
- $("#more-tools").append("<br/>");
+ makeFancyButton(names[i]);
}
-
+
// When you change the selected radio button, change the tool:
$("input").change(function() {
var id = $("input[@name=testGroup]:checked").attr('id');
@@ -379,14 +437,22 @@ $(document).ready(function() {
var progressBar = new ProgressBar($("#design-canvas")[0].getContext("2d"));
progressBar.draw(0);
- TheWorld.loadFromServer(title, loader, function() {
+ var startEditing = function() {
progressBar.draw(0.5);
$("#level-bg-url").val(TheWorld.bgUrl);
$("#level-tileset-url").val(TheWorld.tilesetUrl);
$("#level-goal-url").val(TheWorld.goalUrl);
$("#level-music-url").val(TheWorld.musicUrl);
-
+ var resizeTimer = null;
+ adjustToScreen();
+ $(window).resize(function() {
+ if (resizeTimer) {
+ clearTimeout(resizeTimer);
+ }
+ resizeTimer = setTimeout(adjustToScreen, 500);
+ });
+
for (var prop in PhysicsConstants) {
$("#" + prop).val( PhysicsConstants[prop] );
}
@@ -398,6 +464,13 @@ $(document).ready(function() {
loader.loadThemAll(redraw, function(progress) {
progressBar.draw(0.5 + 0.5 * progress);
});
- });
+ };
+
+ // Playing online or offline?
+ if (typeof offlineLevelData != "undefined") {
+ TheWorld.loadFromString(offlineLevelData, loader, startEditing);
+ } else {
+ TheWorld.loadFromServer(title, loader, startEditing);
+ }
});
View
25 webrunner-mobs.js
@@ -99,7 +99,7 @@ Mob.prototype = {
this.top = intercept.y;
playSfx("bonk-sfx")
break;
- }
+ }
},
update: function(elapsedTime) {
@@ -107,15 +107,15 @@ Mob.prototype = {
if (!this.onGround()) {
this.vy += PhysicsConstants.gravity * elapsedTime / 100;
}
-
+
var xDist = this.vx * elapsedTime / 100;
var yDist = this.vy * elapsedTime / 100;
-
+
var platform = TheWorld.touchingPlatform(this, "bottom");
if (platform && platform.vx) {
xDist += platform.vx * elapsedTime / 100;
}
-
+
// Collision detection
var pathModified = TheWorld.detectPlatformIntercept(this, xDist, yDist);
if (!pathModified) {
@@ -142,7 +142,7 @@ Mob.prototype = {
this.remainingJumpPower = 0;
}
}
-
+
},
stopJumping: function() {
@@ -187,7 +187,7 @@ Mob.prototype = {
return PhysicsConstants.airAcceleration;
}
}
- },
+ },
goLeft: function(elapsed) {
if (! TheWorld.touchingPlatform(this, "left")) {
@@ -301,7 +301,7 @@ function Enemy(loader) {
}
Enemy.prototype = {
roam: function(elapsed) {
- if (this.direction == "left" &&
+ if (this.direction == "left" &&
(TheWorld.touchingPlatform(this, "left") != null)) {
this.direction = "right";
} else if (this.direction == "right" &&
@@ -362,6 +362,7 @@ function MagicCarpet(loader) {
}
MagicCarpet.prototype = {
type: "magic_carpet",
+ classification: "obstacle",
vx: 0,
draw: function(ctx) {
@@ -387,22 +388,24 @@ MagicCarpet.prototype = {
var pathModified = TheWorld.detectPlatformIntercept(this, xDist, 0);
if (!pathModified) {
this.left += xDist;
- }
+ }
}
}
MagicCarpet.prototype.__proto__ = new Mob();
ConstructorRegistry.register(MagicCarpet);
-
function DefineEnemy(options) {
var constructor = function(loader) {
this.mobInit(loader, options.imageUrl, !(!options.animated));
- }
+ };
constructor.prototype = {
type: options.name,
width: options.width ? options.width : 64,
- height: options.height ? options.height : 64
+ height: options.height ? options.height : 64,
+ classification: "monster",
+ imageUrl: options.imageUrl
};
+ // TODO any crazy thing the options has should go in the prototype
constructor.prototype.__proto__ = new Enemy();
ConstructorRegistry.register(constructor);
View
6 webrunner-play.js
@@ -144,7 +144,7 @@ function startGame(loader) {
} else {
player.idle(elapsed);
}
-
+
TheWorld.updateEveryone(elapsed);
TheWorld.scrollIfNeeded(player);
TheWorld.cleanUpDead();
@@ -158,7 +158,7 @@ function startGame(loader) {
// stop bgm, play victory sound effects!
$("#bgm")[0].pause();
playSfx("victory-sfx");
- $.ajax({type: "POST",
+ $.ajax({type: "POST",
url: "complete-level.py",
data: {levelName: gup("level"),
completionTime: Date.now() - startTime,
@@ -180,7 +180,7 @@ function startGame(loader) {
$("#bgm")[0].pause();
playSfx("death-sfx");
} else if (player.top > bottomLimit) {
- $("#output").html(getLocalString("_lose_falling") + " " +
+ $("#output").html(getLocalString("_lose_falling") + " " +
getLocalString("_reload_play_again"));
$("#bgm")[0].pause();
playSfx("death-sfx");
View
59 webrunner-world.js
@@ -44,7 +44,7 @@ ProgressBar.prototype = {
draw: function(progress) {
this._ctx.strokeStyle = "black";
this._ctx.fillStyle = "green";
- this._ctx.strokeText("LOADING...",
+ this._ctx.strokeText("LOADING...",
TheWorld.canvasWidth /2,
TheWorld.canvasHeight/2 - 50);
this._ctx.fillRect(TheWorld.canvasWidth/2 - 200,
@@ -75,9 +75,9 @@ var TheWorld = {
goalUrl: "",
goalImg: null,
-
+
musicUrl: "",
-
+
goalArea: {
left: 500,
top: 350,
@@ -264,7 +264,7 @@ var TheWorld = {
}
}
// sort in increasing order of t (time-until intercept)
-
+
// If only one intercept, just do it:
intercepts.sort(function(a, b) { return a.cept.t - b.cept.t;} );
var pathModified;
@@ -334,7 +334,7 @@ var TheWorld = {
getPlatformAt: function(x, y) {
for (var i = 0; i < this.foregroundObjects.length; i++) {
var platform = this.foregroundObjects[i];
- if (x > platform.left && x <= platform.right
+ if (x > platform.left && x <= platform.right
&& y > platform.top && y <= platform.bottom) {
return platform;
}
@@ -532,7 +532,7 @@ Box.prototype = {
substantial: function(edge) {
return false;
- },
+ },
intersecting: function(rect) {
return (this.left <= rect.right && this.right >= rect.left
@@ -563,6 +563,7 @@ function Platform() {
}
Platform.prototype = {
type: "platform",
+ classification: "obstacle",
draw: function(ctx) {
if (TheWorld.tileSetImg) {
@@ -597,6 +598,7 @@ function SemiPermiablePlatform() {
}
SemiPermiablePlatform.prototype = {
type: "semiplatform",
+ classification: "obstacle",
draw: function(ctx) {
if (TheWorld.tileSetImg) {
@@ -618,7 +620,7 @@ SemiPermiablePlatform.prototype = {
},
substantial: function(edge) {
- return (edge == "top");
+ return (edge == "top");
}
};
SemiPermiablePlatform.prototype.__proto__ = new Box();
@@ -628,12 +630,13 @@ function PowerUp() {
}
PowerUp.prototype = {
type: "powerup",
+ classification: "powerup",
draw: function(ctx) {
},
onMobTouch: function(mob, intercept) {
if (mob.type == "player") {
// monsters don't collect powerups
- TheWorld.removeForegroundObject(this);
+ TheWorld.removeForegroundObject(this);
this.onCollect(mob);
// TODO play a sound here or something?
}
@@ -651,6 +654,7 @@ function SpeedPlus() {
}
SpeedPlus.prototype = {
type: "speedplus",
+ classification: "powerup",
width: 32,
height: 32,
draw: function(ctx) {
@@ -673,6 +677,7 @@ function JumpPlus() {
}
JumpPlus.prototype = {
type: "jumpplus",
+ classification: "powerup",
width: 32,
height: 32,
draw: function(ctx) {
@@ -693,6 +698,7 @@ function PointlessTrinket() {
}
PointlessTrinket.prototype = {
type: "trinket",
+ classification: "powerup",
width: 32,
height: 32,
draw: function(ctx) {
@@ -718,6 +724,7 @@ function DisappearingBlock() {
}
DisappearingBlock.prototype = {
type: "disappearing_block",
+ classification: "obstacle",
visible: true,
time: 0,
@@ -755,12 +762,13 @@ function ButtonBlock() {
}
ButtonBlock.prototype = {
type: "button_block",
+ classification: "obstacle",
activated: false,
activationTime: 5000,
timer: 0,
width: 70,
height: 10,
-
+
draw: function(ctx) {
if (!this.activated) {
ctx.fillStyle = "red";
@@ -769,7 +777,7 @@ ButtonBlock.prototype = {
ctx.strokeRect(this.left, this.top, this.width, this.height);
}
},
-
+
onMobTouch: function(mob, intercept) {
if (this.activated) {
return false;
@@ -783,11 +791,11 @@ ButtonBlock.prototype = {
return true;
}
},
-
+
substantial: function(edge) {
return !this.activated;
},
-
+
update: function(elapsedTime) {
if (this.activated) {
this.timer += elapsedTime;
@@ -796,7 +804,7 @@ ButtonBlock.prototype = {
}
}
},
-
+
deactivate_button: function() {
this.activated = false;
var i = 0;
@@ -807,7 +815,7 @@ ButtonBlock.prototype = {
}
}
},
-
+
activate_button: function() {
this.activated = true;
this.timer = 0;
@@ -827,10 +835,11 @@ function TrapdoorBlock() {
}
TrapdoorBlock.prototype = {
type: "trapdoor_block",
+ classification: "obstacle",
open: false,
width: 100,
height: 10,
-
+
draw: function(ctx) {
if (this.open) {
ctx.globalAlpha = 0.5;
@@ -844,7 +853,7 @@ TrapdoorBlock.prototype = {
ctx.strokeRect(this.left, this.top, this.width, this.height);
ctx.globalAlpha = 1;
},
-
+
onMobTouch: function(mob, intercept) {
if (!this.open) {
mob.stopAt(intercept);
@@ -854,15 +863,15 @@ TrapdoorBlock.prototype = {
return false;
}
},
-
+
substantial: function(edge) {
return !this.open;
},
-
+
button_deactivated: function() {
this.open = false;
},
-
+
button_activated: function() {
this.open = true;
}
@@ -874,10 +883,11 @@ function ActivatedBlock() {
}
ActivatedBlock.prototype = {
type: "activated_block",
+ classification: "obstacle",
active: false,
width: 100,
height: 10,
-
+
draw: function(ctx) {
if (!this.active) {
ctx.globalAlpha = 0.5;
@@ -891,7 +901,7 @@ ActivatedBlock.prototype = {
ctx.strokeRect(this.left, this.top, this.width, this.height);
ctx.globalAlpha = 1;
},
-
+
onMobTouch: function(mob, intercept) {
if (this.active) {
mob.stopAt(intercept);
@@ -901,15 +911,15 @@ ActivatedBlock.prototype = {
return false;
}
},
-
+
substantial: function(edge) {
return this.active;
},
-
+
button_deactivated: function() {
this.active = false;
},
-
+
button_activated: function() {
this.active = true;
}
@@ -921,6 +931,7 @@ function RubberBlock() {
}
RubberBlock.prototype = {
type: "rubber_block",
+ classification: "obstacle",
draw: function(ctx) {
ctx.fillStyle = "black";

0 comments on commit fc5a384

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