SS ready DONE
This commit is contained in:
parent
b1aa4a4406
commit
45b2fe1814
13
index.html
13
index.html
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Adventures with Anxiety!</title>
|
<title>Anxiety Adventure!</title>
|
||||||
<link rel="stylesheet" type="text/css" href="styles/game.css">
|
<link rel="stylesheet" type="text/css" href="styles/game.css">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
</head>
|
</head>
|
||||||
|
@ -18,16 +18,17 @@
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<!-- SCRIPTS -->
|
<!-- SCRIPTS -->
|
||||||
<script src="scripts/lib/pinkyswear.min.js"></script>
|
<script src="scripts/lib/rsvp.min.js"></script>
|
||||||
<script src="scripts/lib/minpubsub.min.js"></script>
|
<script src="scripts/lib/minpubsub.min.js"></script>
|
||||||
|
|
||||||
<script src="scripts/game/Game.js"></script>
|
<script src="scripts/game/Game.js"></script>
|
||||||
|
<script src="scripts/game/Loader.js"></script>
|
||||||
<script src="scripts/game/Sprite.js"></script>
|
<script src="scripts/game/Sprite.js"></script>
|
||||||
<script src="scripts/game/HP.js"></script>
|
<script src="scripts/game/HP.js"></script>
|
||||||
<script src="scripts/game/SceneSetup.js"></script>
|
<script src="scripts/game/BG_Anxiety.js"></script>
|
||||||
<script src="scripts/game/BGAnxiety.js"></script>
|
|
||||||
|
|
||||||
<script src="scripts/game/Hong.js"></script>
|
<script src="scripts/demo/Demo_SceneSetup.js"></script>
|
||||||
<script src="scripts/game/Beebee.js"></script>
|
<script src="scripts/demo/Demo_Hong.js"></script>
|
||||||
|
<script src="scripts/demo/Demo_Beebee.js"></script>
|
||||||
|
|
||||||
<script src="scripts/main.js"></script>
|
<script src="scripts/main.js"></script>
|
|
@ -0,0 +1,59 @@
|
||||||
|
# demo
|
||||||
|
|
||||||
|
`SceneSetup.demo()`
|
||||||
|
|
||||||
|
> Prepare for trouble!
|
||||||
|
|
||||||
|
Oh no!
|
||||||
|
|
||||||
|
(#demo-attacks)
|
||||||
|
|
||||||
|
# demo-attacks
|
||||||
|
|
||||||
|
`publish("beebee",["normal"])`
|
||||||
|
|
||||||
|
[Attack 10 points](#demo-attack-low)
|
||||||
|
|
||||||
|
[Attack 20 points](#demo-attack-med)
|
||||||
|
|
||||||
|
[Attack 50%](#demo-attack-hi)
|
||||||
|
|
||||||
|
# attack
|
||||||
|
|
||||||
|
`publish("beebee",["scream"])`
|
||||||
|
|
||||||
|
`publish("hong",["shock"])`
|
||||||
|
|
||||||
|
(...1500)
|
||||||
|
|
||||||
|
{{if HP.hong==0}} (#dead) {{/if}}
|
||||||
|
|
||||||
|
`publish("hong",["normal"])`
|
||||||
|
|
||||||
|
(#demo-attacks)
|
||||||
|
|
||||||
|
# demo-attack-low
|
||||||
|
|
||||||
|
`HP.attackHong("10p")`
|
||||||
|
|
||||||
|
(#attack)
|
||||||
|
|
||||||
|
# demo-attack-med
|
||||||
|
|
||||||
|
`HP.attackHong("20p")`
|
||||||
|
|
||||||
|
(#attack)
|
||||||
|
|
||||||
|
# demo-attack-hi
|
||||||
|
|
||||||
|
`HP.attackHong("50%")`
|
||||||
|
|
||||||
|
(#attack)
|
||||||
|
|
||||||
|
# dead
|
||||||
|
|
||||||
|
`publish("beebee",["normal_speak"])`
|
||||||
|
|
||||||
|
i am ded
|
||||||
|
|
||||||
|
> u r ded
|
|
@ -1,59 +1,42 @@
|
||||||
# demo
|
# demo
|
||||||
|
|
||||||
`SceneSetup.demo()`
|
```
|
||||||
|
SceneSetup.demo();
|
||||||
|
publish("beebee",["normal_down"]);
|
||||||
|
```
|
||||||
|
|
||||||
> Prepare for trouble!
|
> So... scrolling your life away on Twitter, huh?
|
||||||
|
|
||||||
Oh no!
|
```
|
||||||
|
publish("beebee",["normal"]);
|
||||||
|
publish("hong",["sarcasm"]);
|
||||||
|
```
|
||||||
|
|
||||||
(#demo-attacks)
|
Yeah, I wonder why I don't just sit alone with my thoughts more often.
|
||||||
|
|
||||||
# demo-attacks
|
`publish("beebee",["normal_down"]);`
|
||||||
|
|
||||||
`publish("beebee",["normal"])`
|
> ...
|
||||||
|
|
||||||
[Attack 10 points](#demo-attack-low)
|
`publish("beebee",["normal_down_vexed"]);`
|
||||||
|
|
||||||
[Attack 20 points](#demo-attack-med)
|
[Oh god, look at that awful news!](#derp)
|
||||||
|
|
||||||
[Attack 50%](#demo-attack-hi)
|
[Ugh, look at that troll comment.](#derp)
|
||||||
|
|
||||||
# attack
|
[hey, a GIF of a cat drinking milk](#milk) `publish("beebee",["normal_speak"])`
|
||||||
|
|
||||||
`publish("beebee",["scream"])`
|
# milk
|
||||||
|
|
||||||
`publish("hong",["shock"])`
|
`publish("hong",["smile"])`
|
||||||
|
|
||||||
(...1500)
|
Heh, yeah that is pretty cu-
|
||||||
|
|
||||||
{{if HP.hong==0}} (#dead) {{/if}}
|
```
|
||||||
|
publish("beebee",["scream"]);
|
||||||
|
publish("hong",["shock"]);
|
||||||
|
HP.attackHong("60p");
|
||||||
|
Game.OVERRIDE_TEXT_SPEED = 1.5;
|
||||||
|
```
|
||||||
|
|
||||||
`publish("hong",["normal"])`
|
> CATS CAN'T DIGEST COW'S MILK AND YOU'RE A HORRIBLE PERSON FOR ENJOYING ANIMAL ABUSE
|
||||||
|
|
||||||
(#demo-attacks)
|
|
||||||
|
|
||||||
# demo-attack-low
|
|
||||||
|
|
||||||
`HP.attackHong("10p")`
|
|
||||||
|
|
||||||
(#attack)
|
|
||||||
|
|
||||||
# demo-attack-med
|
|
||||||
|
|
||||||
`HP.attackHong("20p")`
|
|
||||||
|
|
||||||
(#attack)
|
|
||||||
|
|
||||||
# demo-attack-hi
|
|
||||||
|
|
||||||
`HP.attackHong("50%")`
|
|
||||||
|
|
||||||
(#attack)
|
|
||||||
|
|
||||||
# dead
|
|
||||||
|
|
||||||
`publish("beebee",["normal_speak"])`
|
|
||||||
|
|
||||||
i am ded
|
|
||||||
|
|
||||||
> u r ded
|
|
|
@ -1,10 +1,10 @@
|
||||||
function Beebee(){
|
function Demo_Beebee(){
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// Sprite!
|
// Sprite!
|
||||||
var beebeeImage = new Image();
|
var beebeeImage = new Image();
|
||||||
beebeeImage.src = "sprites/beebee.png";
|
beebeeImage.src = "sprites/demo_beebee.png";
|
||||||
self.sprite = new Sprite({
|
self.sprite = new Sprite({
|
||||||
image: beebeeImage,
|
image: beebeeImage,
|
||||||
grid:{
|
grid:{
|
||||||
|
@ -20,10 +20,10 @@ function Beebee(){
|
||||||
y: 325/2
|
y: 325/2
|
||||||
},
|
},
|
||||||
frameNames:[
|
frameNames:[
|
||||||
"normal_look_phone",
|
|
||||||
"normal",
|
"normal",
|
||||||
|
"normal_down",
|
||||||
|
"normal_down_vexed",
|
||||||
"normal_speak",
|
"normal_speak",
|
||||||
"",
|
|
||||||
"scream",
|
"scream",
|
||||||
"scream_2"
|
"scream_2"
|
||||||
],
|
],
|
||||||
|
@ -31,6 +31,9 @@ function Beebee(){
|
||||||
y: 405
|
y: 405
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// First frame
|
||||||
|
self.sprite.gotoFrameByName("normal");
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
var ticker = 0;
|
var ticker = 0;
|
||||||
self.draw = function(ctx){
|
self.draw = function(ctx){
|
||||||
|
@ -67,7 +70,9 @@ function Beebee(){
|
||||||
self.sprite.gotoFrameByName(fname);
|
self.sprite.gotoFrameByName(fname);
|
||||||
|
|
||||||
// Bounce transition
|
// Bounce transition
|
||||||
self.sprite.bounce = 1.1;
|
if(fname=="normal_speak"){
|
||||||
|
self.sprite.bounce = 1.1;
|
||||||
|
}
|
||||||
if(fname=="scream"){
|
if(fname=="scream"){
|
||||||
self.sprite.bounce = 1.6;
|
self.sprite.bounce = 1.6;
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
function Hong(){
|
function Demo_Hong(){
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// Sprite!
|
// Sprite!
|
||||||
var beebeeImage = new Image();
|
var beebeeImage = new Image();
|
||||||
beebeeImage.src = "sprites/hong.png";
|
beebeeImage.src = "sprites/demo_hong.png";
|
||||||
self.sprite = new Sprite({
|
self.sprite = new Sprite({
|
||||||
image: beebeeImage,
|
image: beebeeImage,
|
||||||
grid:{
|
grid:{
|
||||||
width: 3,
|
width: 4,
|
||||||
height: 2
|
height: 2
|
||||||
},
|
},
|
||||||
frame:{
|
frame:{
|
||||||
|
@ -23,11 +23,13 @@ function Hong(){
|
||||||
"_body_1",
|
"_body_1",
|
||||||
"_body_2",
|
"_body_2",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
"normal",
|
"normal",
|
||||||
|
"sarcasm",
|
||||||
"smile",
|
"smile",
|
||||||
"shock"
|
"shock"
|
||||||
],
|
],
|
||||||
x: 80,
|
x: 70,
|
||||||
y: 400
|
y: 400
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ function Hong(){
|
||||||
self.sprite.bounceDamp = 0.9;
|
self.sprite.bounceDamp = 0.9;
|
||||||
|
|
||||||
// First frame
|
// First frame
|
||||||
self.sprite.gotoFrameByName("smile");
|
self.sprite.gotoFrameByName("normal");
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
var ticker = 0;
|
var ticker = 0;
|
||||||
|
@ -48,6 +50,15 @@ function Hong(){
|
||||||
|
|
||||||
var fname = self.sprite.currentFrameName;
|
var fname = self.sprite.currentFrameName;
|
||||||
|
|
||||||
|
// Breathe, unless shocked
|
||||||
|
if(fname=="shock"){
|
||||||
|
self.sprite.breatheSpeed = 0;
|
||||||
|
self.sprite.breatheAmp = 0;
|
||||||
|
}else{
|
||||||
|
self.sprite.breatheSpeed = 0.017;
|
||||||
|
self.sprite.breatheAmp = 0.014;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw body FIRST
|
// Draw body FIRST
|
||||||
var bod_frame = (Math.floor(ticker/30)%2 == 0) ? "_body_1" : "_body_2";
|
var bod_frame = (Math.floor(ticker/30)%2 == 0) ? "_body_1" : "_body_2";
|
||||||
ticker++;
|
ticker++;
|
|
@ -0,0 +1,19 @@
|
||||||
|
SceneSetup.demo = function(){
|
||||||
|
|
||||||
|
Game.resetScene();
|
||||||
|
|
||||||
|
HP.hong = 80;
|
||||||
|
|
||||||
|
// Background
|
||||||
|
var bg = new BG_Anxiety();
|
||||||
|
Game.scene.children.push(bg);
|
||||||
|
|
||||||
|
// Hong
|
||||||
|
var hong = new Demo_Hong();
|
||||||
|
Game.scene.children.push(hong);
|
||||||
|
|
||||||
|
// Beebee
|
||||||
|
var beebee = new Demo_Beebee();
|
||||||
|
Game.scene.children.push(beebee);
|
||||||
|
|
||||||
|
};
|
|
@ -5,7 +5,7 @@ or maybe CA?
|
||||||
|
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
function BGAnxiety(){
|
function BG_Anxiety(){
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -8,18 +8,31 @@ Game.dom = document.querySelector("#game_container");
|
||||||
Game.wordsDOM = document.querySelector("#game_words");
|
Game.wordsDOM = document.querySelector("#game_words");
|
||||||
Game.choicesDOM = document.querySelector("#game_choices");
|
Game.choicesDOM = document.querySelector("#game_choices");
|
||||||
|
|
||||||
|
Game.startSectionID = null;
|
||||||
Game.queue = [];
|
Game.queue = [];
|
||||||
|
|
||||||
// Parse data!
|
window.SceneSetup = {}; // A big ol' singleton class that just makes it easy to create scenes.
|
||||||
Game.onload = function(data){
|
|
||||||
|
|
||||||
// THE FIRST ID
|
// Init
|
||||||
Game.startSectionID = null;
|
Game.init = function(){
|
||||||
|
|
||||||
|
// Animation!
|
||||||
|
Game.wordsDOM.style.top = "80px";
|
||||||
|
var animloop = function(){
|
||||||
|
Game.update();
|
||||||
|
requestAnimationFrame(animloop);
|
||||||
|
};
|
||||||
|
requestAnimationFrame(animloop);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parse scene markdown!
|
||||||
|
Game.parseSceneMarkdown = function(md){
|
||||||
|
|
||||||
// Split into sections...
|
// Split into sections...
|
||||||
data = data.trim();
|
md = md.trim();
|
||||||
data = "\n" + data;
|
md = "\n" + md;
|
||||||
var sections = data.split(/\n\#\s*/);
|
var sections = md.split(/\n\#\s*/);
|
||||||
sections.shift();
|
sections.shift();
|
||||||
sections.forEach(function(section){
|
sections.forEach(function(section){
|
||||||
|
|
||||||
|
@ -43,18 +56,7 @@ Game.onload = function(data){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Animation!
|
};
|
||||||
Game.wordsDOM.style.top = "80px";
|
|
||||||
var animloop = function(){
|
|
||||||
Game.update();
|
|
||||||
requestAnimationFrame(animloop);
|
|
||||||
};
|
|
||||||
requestAnimationFrame(animloop);
|
|
||||||
|
|
||||||
// Let's go!
|
|
||||||
Game.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// SCENE MANAGEMENT ////////////////////////////////////////////////////////////////////////////
|
// SCENE MANAGEMENT ////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -98,8 +100,7 @@ Game.executeNextLine = function(){
|
||||||
var promiseNext;
|
var promiseNext;
|
||||||
if(line==""){
|
if(line==""){
|
||||||
// If no line, get immediate promise...
|
// If no line, get immediate promise...
|
||||||
promiseNext = new pinkySwear();
|
promiseNext = Game.immediatePromise();
|
||||||
promiseNext(true, []);
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// Execute based on what type it is!
|
// Execute based on what type it is!
|
||||||
|
@ -148,6 +149,13 @@ Game.addToQueue = function(line){
|
||||||
// TEXT AND STUFF //////////////////////////////////////////////////////////////////////////////
|
// TEXT AND STUFF //////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Immediate Promise
|
||||||
|
Game.immediatePromise = function(){
|
||||||
|
return new RSVP.Promise(function(resolve){
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Move the text DOM to latest
|
// Move the text DOM to latest
|
||||||
Game.updateText = function(){
|
Game.updateText = function(){
|
||||||
var wordsHeight = 80 + Game.wordsDOM.getBoundingClientRect().height;
|
var wordsHeight = 80 + Game.wordsDOM.getBoundingClientRect().height;
|
||||||
|
@ -159,81 +167,92 @@ Game.updateText = function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
// Execute text! Just add it to text DOM.
|
// Execute text! Just add it to text DOM.
|
||||||
|
Game.OVERRIDE_TEXT_SPEED = 1;
|
||||||
Game.executeText = function(line){
|
Game.executeText = function(line){
|
||||||
|
|
||||||
var div = document.createElement("div");
|
return new RSVP.Promise(function(resolve){
|
||||||
var promiseDone = pinkySwear();
|
|
||||||
|
|
||||||
// Is it human or wolf?
|
// Is it human or wolf?
|
||||||
var dialogue;
|
var isWolf = /^\>(.*)/.test(line);
|
||||||
var isWolf = /^\>(.*)/.test(line);
|
var dialogue = isWolf ? line.match(/^\>(.*)/)[1].trim() : line; // Remove the > for wolf
|
||||||
if(isWolf){
|
|
||||||
div.className = "wolf-bubble";
|
|
||||||
dialogue = line.match(/^\>(.*)/)[1].trim();
|
|
||||||
}else{
|
|
||||||
div.className = "human-bubble";
|
|
||||||
dialogue = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the bubble, with animation
|
// Add the bubble, with animation
|
||||||
Game.wordsDOM.appendChild(div);
|
var div = document.createElement("div");
|
||||||
requestAnimationFrame(function(){
|
Game.wordsDOM.appendChild(div);
|
||||||
|
div.className = isWolf ? "wolf-bubble" : "human-bubble";
|
||||||
requestAnimationFrame(function(){
|
requestAnimationFrame(function(){
|
||||||
div.style.opacity = 1;
|
requestAnimationFrame(function(){
|
||||||
div.style.left = 0;
|
div.style.opacity = 1;
|
||||||
|
div.style.left = 0;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Add the text, letter by letter!
|
// Add the text, letter by letter!
|
||||||
var interval = 0;
|
var interval = 0;
|
||||||
var SPEED = 40;
|
var SPEED = Math.round(40 / Game.OVERRIDE_TEXT_SPEED);
|
||||||
for(var i=0; i<dialogue.length; i++){
|
for(var i=0; i<dialogue.length; i++){
|
||||||
|
|
||||||
var ch = dialogue[i];
|
var ch = dialogue[i];
|
||||||
|
|
||||||
// for scopin'
|
// for scopin'
|
||||||
(function(ch, interval){
|
(function(ch, interval){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
div.innerHTML += ch;
|
div.innerHTML += ch;
|
||||||
}, interval);
|
}, interval);
|
||||||
})(ch, interval);
|
})(ch, interval);
|
||||||
|
|
||||||
|
// Bigger interval
|
||||||
|
if(ch=="."){
|
||||||
|
interval += SPEED*10;
|
||||||
|
}else{
|
||||||
|
interval += SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
// Bigger interval
|
|
||||||
if(ch=="."){
|
|
||||||
interval += SPEED*10;
|
|
||||||
}else{
|
|
||||||
interval += SPEED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// Return promise
|
||||||
|
var nextLineDelay = 300;
|
||||||
|
if(dialogue.slice(-1)=="-") nextLineDelay=0; // sudden interrupt!
|
||||||
|
setTimeout(resolve, interval+nextLineDelay);
|
||||||
|
|
||||||
// Return promise
|
});
|
||||||
setTimeout(function(){
|
|
||||||
promiseDone(true, []);
|
|
||||||
}, interval+200);
|
|
||||||
return promiseDone;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute choice! Add it to choice DOM.
|
// Execute choice! Add it to choice DOM.
|
||||||
|
Game.OVERRIDE_CHOICE_LINE = false;
|
||||||
Game.executeChoice = function(line){
|
Game.executeChoice = function(line){
|
||||||
|
|
||||||
var choiceText = line.match(/\[(.*)\]/)[1].trim();
|
var choiceText = line.match(/\[([^\]]*)\]/)[1].trim();
|
||||||
var choiceID = line.match(/\(\#(.*)\)/)[1].trim().toLocaleLowerCase();
|
var choiceID = line.match(/\(\#([^\)]*)\)/)[1].trim().toLocaleLowerCase();
|
||||||
|
|
||||||
|
var preChoiceCodeIfAny = null;
|
||||||
|
if(/\`(.*)\`/.test(line)){
|
||||||
|
preChoiceCodeIfAny = line.match(/\`(.*)\`/)[0]; // 0, with backticks
|
||||||
|
}
|
||||||
|
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.innerHTML = choiceText;
|
div.innerHTML = choiceText;
|
||||||
div.onclick = function(){
|
div.onclick = function(){
|
||||||
Game.addToQueue("> "+choiceText);
|
|
||||||
|
// Any pre-choice code?
|
||||||
|
if(preChoiceCodeIfAny) Game.executeCode(preChoiceCodeIfAny);
|
||||||
|
|
||||||
|
// Override line... ONCE
|
||||||
|
if(!Game.OVERRIDE_CHOICE_LINE){
|
||||||
|
Game.addToQueue("> "+choiceText);
|
||||||
|
}
|
||||||
|
Game.OVERRIDE_CHOICE_LINE = true;
|
||||||
|
|
||||||
|
// Goto that choice, now!
|
||||||
Game.goto(choiceID);
|
Game.goto(choiceID);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Game.choicesDOM.appendChild(div);
|
Game.choicesDOM.appendChild(div);
|
||||||
|
|
||||||
// Return promise
|
// Return immediate promise
|
||||||
var promiseImmediate = new pinkySwear();
|
return Game.immediatePromise();
|
||||||
promiseImmediate(true, []);
|
|
||||||
return promiseImmediate;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +266,8 @@ Game.executeCode = function(line){
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return promise
|
// Return immediate promise
|
||||||
var promiseImmediate = new pinkySwear();
|
return Game.immediatePromise();
|
||||||
promiseImmediate(true, []);
|
|
||||||
return promiseImmediate;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,11 +278,9 @@ Game.executeWait = function(line){
|
||||||
var waitTime = parseInt(line.match(/^\(\.\.\.(\d+)\)/)[1].trim());
|
var waitTime = parseInt(line.match(/^\(\.\.\.(\d+)\)/)[1].trim());
|
||||||
|
|
||||||
// Delayed promise
|
// Delayed promise
|
||||||
var promiseDelayed = new pinkySwear();
|
return RSVP.Promise(function(resolve){
|
||||||
setTimeout(function(){
|
setTimeout(resolve, waitTime);
|
||||||
promiseDelayed(true, []);
|
});
|
||||||
}, waitTime);
|
|
||||||
return promiseDelayed;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
window.Loader = {};
|
||||||
|
window.Library = {
|
||||||
|
images: {}
|
||||||
|
};
|
||||||
|
Loader.load = function(){
|
||||||
|
return new RSVP.Promise(function(resolve){
|
||||||
|
|
||||||
|
var loadPromises = [];
|
||||||
|
|
||||||
|
// All scenes
|
||||||
|
Loader.sceneSources.forEach(function(src){
|
||||||
|
loadPromises.push( Loader.loadScene(src) );
|
||||||
|
});
|
||||||
|
|
||||||
|
// All images
|
||||||
|
Loader.imageConfigs.forEach(function(config){
|
||||||
|
loadPromises.push( Loader.loadImage(config) );
|
||||||
|
});
|
||||||
|
|
||||||
|
// Go go go!
|
||||||
|
RSVP.all(loadPromises).then(resolve);
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// IMAGES ///////////////////
|
||||||
|
/////////////////////////////
|
||||||
|
|
||||||
|
Loader.imageConfigs = [];
|
||||||
|
Loader.addImages = function(imageConfigs){
|
||||||
|
Loader.imageConfigs = Loader.imageConfigs.concat(imageConfigs);
|
||||||
|
};
|
||||||
|
Loader.loadImage = function(imageConfig){
|
||||||
|
return new RSVP.Promise(function(resolve){
|
||||||
|
var img = new Image();
|
||||||
|
var id = imageConfig.id;
|
||||||
|
Library.images[id] = img; // ADD TO LIBRARY
|
||||||
|
img.onload = resolve;
|
||||||
|
img.src = imageConfig.src;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// SCENES ///////////////////
|
||||||
|
/////////////////////////////
|
||||||
|
|
||||||
|
Loader.sceneSources = [];
|
||||||
|
Loader.addScenes = function(sceneSources){
|
||||||
|
Loader.sceneSources = Loader.sceneSources.concat(sceneSources);
|
||||||
|
};
|
||||||
|
Loader.loadScene = function(src){
|
||||||
|
var loadDataPromise = new RSVP.Promise(function(resolve){
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", src);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if(xhr.status===200){
|
||||||
|
Game.parseSceneMarkdown(xhr.responseText); // PARSE INTO GAME
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,25 +0,0 @@
|
||||||
/**********************************
|
|
||||||
|
|
||||||
A big ol' singleton class that just makes it easy to create scenes.
|
|
||||||
|
|
||||||
**********************************/
|
|
||||||
|
|
||||||
window.SceneSetup = {};
|
|
||||||
|
|
||||||
SceneSetup.demo = function(){
|
|
||||||
|
|
||||||
Game.resetScene();
|
|
||||||
|
|
||||||
// Background
|
|
||||||
var bg = new BGAnxiety();
|
|
||||||
Game.scene.children.push(bg);
|
|
||||||
|
|
||||||
// Hong
|
|
||||||
var hong = new Hong();
|
|
||||||
Game.scene.children.push(hong);
|
|
||||||
|
|
||||||
// Beebee
|
|
||||||
var beebee = new Beebee();
|
|
||||||
Game.scene.children.push(beebee);
|
|
||||||
|
|
||||||
};
|
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,12 @@
|
||||||
var xhr = new XMLHttpRequest();
|
// Load assets
|
||||||
xhr.open('GET', 'scenes/demo.md?v='+Math.random());
|
Loader.addScenes([
|
||||||
xhr.onload = function() {
|
"scenes/demo.md"
|
||||||
if(xhr.status===200){
|
]);
|
||||||
Game.onload(xhr.responseText);
|
Loader.addImages([
|
||||||
}
|
{ id:"demo_beebee", src:"sprites/demo_beebee.png" },
|
||||||
};
|
{ id:"demo_hong", src:"sprites/demo_hong.png" }
|
||||||
xhr.send();
|
]);
|
||||||
|
Loader.load().then(function(){
|
||||||
|
Game.init();
|
||||||
|
Game.start();
|
||||||
|
});
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB |
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
sprites/hong.png
BIN
sprites/hong.png
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue