|
|
@ -1,12 +1,14 @@
|
|
|
|
// # Quintus platformer example
|
|
|
|
// heavily based on the Quintus platformer example.
|
|
|
|
//
|
|
|
|
// vim:tw=120:
|
|
|
|
// [Run the example](../examples/platformer/index.html)
|
|
|
|
|
|
|
|
// WARNING: this game must be run from a non-file:// url
|
|
|
|
// jQuery center() function. it centers things.
|
|
|
|
// as it loads a level json file.
|
|
|
|
jQuery.fn.center = function () {
|
|
|
|
//
|
|
|
|
this.css("position", "absolute");
|
|
|
|
// This is the example from the website homepage, it consists
|
|
|
|
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
|
|
|
|
// a simple, non-animated platformer with some enemies and a
|
|
|
|
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
|
|
|
|
// target for the player.
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener("load",function() {
|
|
|
|
window.addEventListener("load",function() {
|
|
|
|
|
|
|
|
|
|
|
|
// Set up an instance of the Quintus engine and include
|
|
|
|
// Set up an instance of the Quintus engine and include
|
|
|
@ -183,29 +185,6 @@ Q.scene('endGame',function(stage) {
|
|
|
|
container.fit(16);
|
|
|
|
container.fit(16);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Q.scene('ThereWillBeCake',function(stage) {
|
|
|
|
|
|
|
|
var container = stage.insert(new Q.UI.Container({
|
|
|
|
|
|
|
|
x: Q.width/2, y: Q.height/2, fill: "rgba(0,0,0,0.5)"
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var button = container.insert(new Q.UI.Button({ x: 0, y: 0, fill: "#CCCCCC",
|
|
|
|
|
|
|
|
label: "Play Again" }));
|
|
|
|
|
|
|
|
var label = container.insert(new Q.UI.Text({x:10, y: -10 - button.p.h,
|
|
|
|
|
|
|
|
label: stage.options.label }));
|
|
|
|
|
|
|
|
// When the button is clicked, clear all the stages
|
|
|
|
|
|
|
|
// and restart the game.
|
|
|
|
|
|
|
|
button.on("click",function() {
|
|
|
|
|
|
|
|
$( "#einladung" ).hide();
|
|
|
|
|
|
|
|
Q.clearStages();
|
|
|
|
|
|
|
|
Q.stageScene('level1');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Expand the container to visibly fit its contents
|
|
|
|
|
|
|
|
// (with a padding)
|
|
|
|
|
|
|
|
container.fit(16);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ## Asset Loading and Game Launch
|
|
|
|
// ## Asset Loading and Game Launch
|
|
|
|
// Q.load can be called at any time to load additional assets
|
|
|
|
// Q.load can be called at any time to load additional assets
|
|
|
|
// assets that are already loaded will be skipped
|
|
|
|
// assets that are already loaded will be skipped
|
|
|
|