|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
// # Quintus platformer example
|
|
|
|
|
//
|
|
|
|
|
// [Run the example](../examples/platformer/index.html)
|
|
|
|
|
// WARNING: this game must be run from a non-file:// url
|
|
|
|
|
// as it loads a level json file.
|
|
|
|
|
//
|
|
|
|
|
// This is the example from the website homepage, it consists
|
|
|
|
|
// a simple, non-animated platformer with some enemies and a
|
|
|
|
|
// target for the player.
|
|
|
|
|
// heavily based on the Quintus platformer example.
|
|
|
|
|
// vim:tw=120:
|
|
|
|
|
|
|
|
|
|
// jQuery center() function. it centers things.
|
|
|
|
|
jQuery.fn.center = function () {
|
|
|
|
|
this.css("position", "absolute");
|
|
|
|
|
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
|
|
|
|
|
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener("load",function() {
|
|
|
|
|
|
|
|
|
|
// Set up an instance of the Quintus engine and include
|
|
|
|
@ -183,29 +185,6 @@ Q.scene('endGame',function(stage) {
|
|
|
|
|
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
|
|
|
|
|
// Q.load can be called at any time to load additional assets
|
|
|
|
|
// assets that are already loaded will be skipped
|
|
|
|
|