From: MegaBrutal Date: Thu, 6 Sep 2018 14:15:15 +0000 (+0200) Subject: Initial commit X-Git-Tag: early-release~32 X-Git-Url: http://git.megabrutal.com/?p=wgj58.git;a=commitdiff_plain;h=9545ed9488e2af5b42f3d4816a1f0c6b491a5f73 Initial commit new file: card.svg new file: carlos.png new file: carlos.svg new file: clara.png new file: clara.svg new file: index.html new file: john.png new file: john.svg new file: names.lst new file: objects.png new file: objects.svg new file: peter.png new file: peter.svg new file: player.png new file: saiki.png new file: saiki.svg new file: tilemap.json new file: tilemap.tmx new file: tileset.png new file: tileset.svg new file: wgj58.html new file: wgj58.js --- 9545ed9488e2af5b42f3d4816a1f0c6b491a5f73 diff --git a/card.svg b/card.svg new file mode 100644 index 0000000..7b8232e --- /dev/null +++ b/card.svg @@ -0,0 +1,131 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + JohnEvals + IT Security Department + + diff --git a/carlos.png b/carlos.png new file mode 100644 index 0000000..025feff Binary files /dev/null and b/carlos.png differ diff --git a/carlos.svg b/carlos.svg new file mode 100644 index 0000000..8f6da51 --- /dev/null +++ b/carlos.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + CarlosElbacalper + Pre-sales + + diff --git a/clara.png b/clara.png new file mode 100644 index 0000000..2176067 Binary files /dev/null and b/clara.png differ diff --git a/clara.svg b/clara.svg new file mode 100644 index 0000000..a73c38e --- /dev/null +++ b/clara.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + ClaraTnavelerri + Accounting + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..4d5b0ce --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ + + + + + CARDS + + + + +
+

CARDS

+

(Inspired by Weekly Game Jam 58 Cards theme)

+ +

By MegaBrutal

+
+ + diff --git a/john.png b/john.png new file mode 100644 index 0000000..deaec93 Binary files /dev/null and b/john.png differ diff --git a/john.svg b/john.svg new file mode 100644 index 0000000..db6b321 --- /dev/null +++ b/john.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + JohnEvals + IT Security Department + + diff --git a/names.lst b/names.lst new file mode 100644 index 0000000..6dcd722 --- /dev/null +++ b/names.lst @@ -0,0 +1,11 @@ +John Evals + +Clara Tnavelerri + +Carlos Elbacalper + +Saiki Ytpme + +Peter Tluaf + +Bianca Gnihton diff --git a/objects.png b/objects.png new file mode 100644 index 0000000..90e27ab Binary files /dev/null and b/objects.png differ diff --git a/objects.svg b/objects.svg new file mode 100644 index 0000000..1c7e96f --- /dev/null +++ b/objects.svg @@ -0,0 +1,742 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Recycling + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/peter.png b/peter.png new file mode 100644 index 0000000..9f1868b Binary files /dev/null and b/peter.png differ diff --git a/peter.svg b/peter.svg new file mode 100644 index 0000000..5d71c74 --- /dev/null +++ b/peter.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + PeterTluaf + Design & Development + + diff --git a/player.png b/player.png new file mode 100644 index 0000000..7081815 Binary files /dev/null and b/player.png differ diff --git a/saiki.png b/saiki.png new file mode 100644 index 0000000..f7206d8 Binary files /dev/null and b/saiki.png differ diff --git a/saiki.svg b/saiki.svg new file mode 100644 index 0000000..2edff72 --- /dev/null +++ b/saiki.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Corp Logo + SaikiYtpme + Computer Systems + + diff --git a/tilemap.json b/tilemap.json new file mode 100644 index 0000000..38cfc3f --- /dev/null +++ b/tilemap.json @@ -0,0 +1,107 @@ +{ "height":19, + "infinite":false, + "layers":[ + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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+ "height":19, + "name":"floor", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":19, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2684354582, 2684354581, 2684354581, 1610612767, 61, 62, 3221225534, 61, 2684354591, 2684354581, 2684354581, 3221225494, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3221225493, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 2684354581, 2684354581, 3221225494, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1610612790, 0, 0, 21, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2684354613, 0, 0, 21, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1610612788, 0, 0, 21, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2684354582, 2684354581, 2684354581, 1610612758, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 22, 2684354581, 2684354581, 1610612767, 61, 62, 3221225534, 61, 2684354591, 2684354581, 2684354581, 1610612758, 0, 0, 0, 0, 0, 0, 0], + "height":19, + "name":"walls", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":19, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":19, + "name":"furniture", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":19, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "name":"objects", + "objects":[ + { + "gid":51, + "height":64, + "id":2, + "name":"john", + "rotation":0, + "type":"spawnpoint", + "visible":true, + "width":64, + "x":353.333333333333, + "y":1121.33333333333 + }, + { + "gid":51, + "height":64, + "id":3, + "name":"clara", + "rotation":0, + "type":"spawnpoint", + "visible":true, + "width":64, + "x":774.666666666667, + "y":894.666666666667 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextobjectid":4, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.1.6", + "tileheight":64, + "tilesets":[ + { + "columns":10, + "firstgid":1, + "image":"tileset.png", + "imageheight":320, + "imagewidth":640, + "margin":0, + "name":"tileset", + "spacing":0, + "tilecount":50, + "tileheight":64, + "tilewidth":64 + }, + { + "columns":10, + "firstgid":51, + "image":"objects.png", + "imageheight":320, + "imagewidth":640, + "margin":0, + "name":"objects", + "spacing":0, + "tilecount":50, + "tileheight":64, + "tilewidth":64 + }], + "tilewidth":64, + "type":"map", + "version":1, + "width":19 +} \ No newline at end of file diff --git a/tilemap.tmx b/tilemap.tmx new file mode 100644 index 0000000..e5a4dfe --- /dev/null +++ b/tilemap.tmx @@ -0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,0,0,0,0,0,0,0, +2684354582,2684354581,2684354581,1610612767,61,62,3221225534,61,2684354591,2684354581,2684354581,3221225494,0,0,0,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,3221225493,0,0,0,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,22,2684354581,2684354581,3221225494,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,1610612790,0,0,21,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,2684354613,0,0,21,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,1610612788,0,0,21,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,2684354582,2684354581,2684354581,1610612758,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,0, +21,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,0, +22,2684354581,2684354581,1610612767,61,62,3221225534,61,2684354591,2684354581,2684354581,1610612758,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,63,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + diff --git a/tileset.png b/tileset.png new file mode 100644 index 0000000..18964a2 Binary files /dev/null and b/tileset.png differ diff --git a/tileset.svg b/tileset.svg new file mode 100644 index 0000000..c836c89 --- /dev/null +++ b/tileset.svg @@ -0,0 +1,1015 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wgj58.html b/wgj58.html new file mode 100644 index 0000000..c4d7bb6 --- /dev/null +++ b/wgj58.html @@ -0,0 +1,16 @@ + + + + + Weekly Game Jam 58 + + + + + + + + diff --git a/wgj58.js b/wgj58.js new file mode 100644 index 0000000..d29f4e8 --- /dev/null +++ b/wgj58.js @@ -0,0 +1,511 @@ +var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: function() { this.state.add('GamePlay', GamePlay, true); } }); +var logic; +var cursors; + +const PLAYER_SPEED = 200; +const WAIT_MENUSTEP = 100; +const WAIT_TALK = 250; + +const MENUITEM_TALK = 0; +const MENUITEM_LEAVE = 1; +const MENUITEM_TAKE = 2; + +const GUI_MENUITEM_DISTANCE = 20; + +window.addEventListener("keydown", function(e) { + // Prevent default browser action for arrows and spacebar + if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) { + e.preventDefault(); + } +}, false); + +function hasTimePassed(time, delay) { + return (game.time.now - time) > delay; +} + +class Dialogue { + // dialogue is array of {actor, text} records. + constructor(dialogue) { + this.dialogue = dialogue; + this.state = 0; + } + + actual() { + return this.dialogue[this.state]; + } + + advance() { + this.state++; + } +} + +class Player extends Phaser.Sprite { + constructor(x, y) { + super(game, x, y, 'player'); + this.y -= this.height; + this.shortname = "John"; + this.fullname = "John Evals"; + this.offerInteraction(null); + this.unfreeze(); + } + + enablePhysics() { + game.physics.arcade.enable(this); + this.body.bounce.y = 0.2; + this.body.bounce.x = 0.2; + this.body.collideWorldBounds = true; + } + + control() { + if ((this.alive) && (!this.freezed)) + { + if (cursors.left.isDown) + { + this.body.velocity.x = -PLAYER_SPEED; + } + else if (cursors.right.isDown) + { + this.body.velocity.x = PLAYER_SPEED; + } + if (cursors.up.isDown) + { + this.body.velocity.y = -PLAYER_SPEED; + } + else if (cursors.down.isDown) + { + this.body.velocity.y = PLAYER_SPEED; + } + } + } + + update() { + this.body.velocity.x = this.body.velocity.y = 0; + this.control(); + } + + freeze() { + this.freezed = true; + } + + unfreeze() { + this.freezed = false; + } + + offerInteraction(npc) { + this.interactablenpc = npc; + } + + takeMe(npc) { + this.loadTexture(npc.key); + npc.kill(); + } +} + +class GameNPC extends Phaser.Sprite { + constructor(x, y, key, shortname, fullname, interaction_distance) { + super(game, x, y, key); + this.y -= this.height; + this.shortname = shortname; + this.fullname = fullname; + this.interaction_distance = interaction_distance; + this.interactable = false; + this.talkcount = 0; + } + + kill() { + super.kill(); + this.exists = false; + } + + update() { + super.update(); + if ((!this.interactable) && (game.physics.arcade.distanceBetween(this, logic.player) < this.interaction_distance)) { + logic.gameinterface.dropNotice("(ENTER) Interact with " + this.shortname + "!"); + logic.player.offerInteraction(this); + this.interactable = true; + } + else if ((this.interactable) && (game.physics.arcade.distanceBetween(this, logic.player) > this.interaction_distance)) { + logic.gameinterface.clearNotice(); + logic.player.offerInteraction(null); + this.interactable = false; + } + } + + actionTalk() { + this.talkcount++; + } + + actionLeave() { + } + + actionTake() { + logic.player.offerInteraction(null); + logic.player.takeMe(this); + return true; + } + + endTalk() { + return true; + } +} + +class NPC_Clara extends GameNPC { + actionTalk() { + switch (this.talkcount) { + case 0: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "What a morning..." }, + { actor: logic.player, text: "Hi Clara! What happened?" }, + { actor: this, text: "No one cares to tell. I just know that I have to log on people manually, as the access control system doesn't work properly." }, + { actor: logic.player, text: "Hmm... I'll look into it. Maybe it's just that everyone is fired." }, + { actor: this, text: "Haha! Wouldn't joke about this, though, due to the recent layoffs." }, + { actor: logic.player, text: "Well, maybe if we dare to joke about it, it won't happen to us..." }, + { actor: this, text: "Wish it worked like that... Is it some superstition like the belief that having an umbrella with you prevents rain?" }, + { actor: logic.player, text: "Nah, that actually works; it's not a superstition, but Murphy's Law!" }, + { actor: this, text: "If you say so..." } ] )); + break; + case 1: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "John, have you ever thought about losing your employee card?" }, + { actor: logic.player, text: "Yeah, you'd just get a new one." }, + { actor: this, text: "You don't understand me, John!" }, + { actor: this, text: "..." }, + { actor: this, text: "I mean... Losing it for real..." }, + { actor: this, text: "Doesn't it feel like it's the culmination of your being?" }, + { actor: this, text: "If I had no card, would I still exist?" }, + { actor: logic.player, text: "..." }, + { actor: logic.player, text: "You sound very philosophical today." } ] )); + break; + case 2: + case 3: + case 4: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Would you like to hear a random fun fact?" }, + { actor: logic.player, text: "Of course!" }, + { actor: this, text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s," }, + { actor: this, text: "when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap" }, + { actor: this, text: "into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem" }, + { actor: this, text: "Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." }, + { actor: logic.player, text: "That's very interesting, I didn't know that!" }, + { actor: logic.player, text: "Thanks for sharing, Clara!" } ] )); + break; + case 5: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Would you like to hear a random fun fact?" }, + { actor: logic.player, text: "Of course!..." }, + { actor: logic.player, text: "But first..." }, + { actor: this, text: "What is it?" }, + { actor: logic.player, text: "..." }, + { actor: logic.player, text: "Never mind, go on with what you wanted to say." }, + { actor: this, text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry..." }, + { actor: logic.player, text: "I knew that already..." }, + { actor: logic.player, text: "But..." }, + { actor: logic.player, text: "Would you go out on a date with me?" }, + { actor: this, text: "..." }, + { actor: this, text: "No." } ] )); + break; + default: + logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "..." } ] )); + } + super.actionTalk(); + } + + actionLeave() { + logic.gameinterface.dropNotice(this.shortname + ": Have a great day, John!"); + } + + endTalk() { + return (this.talkcount < 6); + } +} + + +class GameInterface extends Phaser.Group { + constructor(game, parent) { + super(game, parent, 'GUI', false, false, 0); + this.back_notice = new Phaser.Graphics(game, 0, game.height - 50); + this.back_notice.beginFill(0x000000); + this.back_notice.drawRect(0, 0, game.width, 30); + this.back_notice.endFill(); + this.add(this.back_notice); + this.text_notice = new Phaser.Text(game, 0, this.back_notice.y, null, { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' }); + this.text_notice.anchor.setTo(-0.5, -0.2); + this.add(this.text_notice); + this.clearNotice(); + + this.back_menu = new Phaser.Graphics(game, 150, (game.height / 2) + 40); + this.back_menu.beginFill(0x000000); + this.back_menu.drawRect(0, 0, 155, 105); + this.back_menu.endFill(); + this.back_menu.lineStyle(3, Phaser.Color.YELLOW, 1); + this.back_menu.moveTo(10, 35); + this.back_menu.lineTo(this.back_menu.width - 10, 35); + this.add(this.back_menu); + var style = { align: 'left', fill: 'yellow', font: 'Ubuntu Mono', fontSize: 22, fontWeight: 'bold' }; + this.text_menutitle = new Phaser.Text(game, this.back_menu.x, this.back_menu.y, null, style); + this.text_menutitle.anchor.setTo(-0.2, -0.2); + style = { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' }; + this.text_menuitem_Talk = new Phaser.Text(game, this.back_menu.x + 35, this.back_menu.y + 40, "Talk", style); + this.text_menuitem_Leave = new Phaser.Text(game, this.back_menu.x + 35, this.text_menuitem_Talk.y + GUI_MENUITEM_DISTANCE, "Leave", style); + this.text_menuitem_Take = new Phaser.Text(game, this.back_menu.x + 35, this.text_menuitem_Leave.y + GUI_MENUITEM_DISTANCE, "Take ID", style); + style.fill = 'yellow'; + this.text_menucursor = new Phaser.Text(game, this.back_menu.x + 15, this.text_menuitem_Talk.y, "→", style); + this.add(this.text_menutitle); + this.add(this.text_menuitem_Talk); + this.add(this.text_menuitem_Leave); + this.add(this.text_menuitem_Take); + this.add(this.text_menucursor); + this.leaveMenu(); + this.last_menustep = 0; + + this.back_talk = new Phaser.Graphics(game, 100, game.height - 120); + this.back_talk.beginFill(0x000000); + this.back_talk.drawRect(0, 0, game.width - 200, 105); + this.back_talk.endFill(); + this.back_talk.lineStyle(3, Phaser.Color.YELLOW, 1); + this.back_talk.moveTo(10, 35); + this.back_talk.lineTo(this.back_talk.width - 10, 35); + this.add(this.back_talk); + style = { align: 'left', fill: 'yellow', font: 'Ubuntu Mono', fontSize: 22, fontWeight: 'bold' }; + this.text_talktitle = new Phaser.Text(game, this.back_talk.x, this.back_talk.y, null, style); + this.text_talktitle.anchor.setTo(-0.2, -0.2); + this.add(this.text_talktitle); + style = { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' }; + this.text_talk = new Phaser.Text(game, this.back_talk.x + 35, this.back_talk.y + 40, null, style); + this.text_talk.wordWrap = true; + this.text_talk.wordWrapWidth = this.back_talk.width - 70; + this.text_talk.lineSpacing = -5; + this.add(this.text_talk); + this.leaveTalk(); + this.last_talk = 0; + } + + dropNotice(text) { + this.text_notice.text = text; + this.back_notice.visible = true; + this.text_notice.visible = true; + } + + clearNotice() { + this.back_notice.visible = false; + this.text_notice.visible = false; + } + + npcMenu(npc) { + if (!this.inMenu) { + this.inMenu = true; + this.clearNotice(); + this.text_menutitle.text = npc.shortname; + this.back_menu.visible = true; + this.text_menutitle.visible = true; + this.text_menuitem_Talk.visible = true; + this.text_menuitem_Leave.visible = true; + this.text_menuitem_Take.visible = true; + this.currentmenuitem = MENUITEM_TALK; + this.actualizeCursorPosition(); + this.text_menucursor.visible = true; + this.last_menustep = game.time.now; + } + } + + leaveMenu() { + this.back_menu.visible = false; + this.text_menutitle.visible = false; + this.text_menuitem_Talk.visible = false; + this.text_menuitem_Leave.visible = false; + this.text_menuitem_Take.visible = false; + this.text_menucursor.visible = false; + this.inMenu = false; + } + + talk(dialogue) { + this.inTalk = true; + this.dialogue = dialogue; + this.advanceTalk(); + this.back_talk.visible = true; + this.text_talktitle.visible = true; + this.text_talk.visible = true; + } + + leaveTalk() { + this.inTalk = false; + this.dialogue = null; + this.back_talk.visible = false; + this.text_talktitle.visible = false; + this.text_talk.visible = false; + } + + advanceTalk() { + console.log(this.dialogue); + console.log(this.dialogue.actual()); + var actualdialogue = this.dialogue.actual(); + if (actualdialogue) { + this.text_talktitle.text = actualdialogue.actor.shortname; + this.text_talk.text = actualdialogue.text; + this.dialogue.advance(); + } + else { + this.leaveTalk(); + logic.endTalk(); + } + this.last_talk = game.time.now; + } + + actualizeCursorPosition() { + this.text_menucursor.y = this.text_menuitem_Talk.y + (this.currentmenuitem * GUI_MENUITEM_DISTANCE); + } + + update() { + if ((this.inMenu) && (hasTimePassed(this.last_menustep, WAIT_MENUSTEP))) { + if (cursors.up.isDown) + { + this.currentmenuitem--; + if (this.currentmenuitem < MENUITEM_TALK) this.currentmenuitem = MENUITEM_TAKE; + this.actualizeCursorPosition(); + } + else if (cursors.down.isDown) + { + this.currentmenuitem++; + if (this.currentmenuitem > MENUITEM_TAKE) this.currentmenuitem = MENUITEM_TALK; + this.actualizeCursorPosition(); + } + if (game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) { + logic.callMenu(this.currentmenuitem); + } + this.last_menustep = game.time.now; + } + if ((this.inTalk) && (game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) && (hasTimePassed(this.last_talk, WAIT_TALK))) { + this.advanceTalk(); + } + } +} + +class GameLogic { + + constructor() { + this.player = this.clara = this.carlos = this.saiki = this.peter = this.bianca = null; + this.gameinterface = new GameInterface(game, game.stage); + this.last_menuselect = 0; + } + + createObject(object) { + switch (object.type) { + case 'spawnpoint': this.createCharacter(object); break; + case '': console.error("Object type is empty:", object); break; + default: console.error("Unknown object type:", object); + } + } + + createCharacter(object) { + var newChar; + switch (object.name) { + case 'john': + newChar = new Player(object.x, object.y, 'player'); + this.player = newChar; + this.player.enablePhysics(); + game.camera.follow(this.player); + break; + case 'clara': + newChar = new NPC_Clara(object.x, object.y, 'clara', "Clara", "Clara Tnavelerri", 200); + this.clara = newChar; + break; + default: + console.error("Unknown character:", object); + } + newChar.name = object.name; + game.add.existing(newChar); + console.log(newChar); + } + + callMenu(menuitem) { + console.log("Menu callback received:", menuitem); + this.last_menuselect = game.time.now; + this.gameinterface.leaveMenu(); + switch (menuitem) { + case MENUITEM_TALK: + this.player.interactablenpc.actionTalk(); + break; + case MENUITEM_LEAVE: + this.player.interactablenpc.actionLeave(); + this.player.unfreeze(); + break; + case MENUITEM_TAKE: + if (this.player.interactablenpc.actionTake()) + this.player.unfreeze(); + break; + } + } + + endTalk() { + if (this.player.interactablenpc) { + if (this.player.interactablenpc.endTalk()) { + this.gameinterface.npcMenu(this.player.interactablenpc); + } + else { + this.player.unfreeze(); + this.last_menuselect = game.time.now; + } + } + } + + update() { + if ((game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) && (hasTimePassed(this.last_menuselect, WAIT_MENUSTEP))) { + if ((this.player.interactablenpc) && (this.player.interactablenpc.interactable) && (!this.gameinterface.inMenu) && (!this.gameinterface.inTalk)) { + console.log("Starting interaction with", this.player.interactablenpc.fullname); + this.player.freeze(); + this.gameinterface.npcMenu(this.player.interactablenpc); + } + } + } + +} + +class GamePlay extends Phaser.State { + + constructor() { + + super(); + logic = new GameLogic(); + game.world.updateOnlyExistingChildren = true; + //game.state.add('GameOver', GameOver, false); + + } + + preload() { + + game.load.image('player', 'john.png'); + game.load.image('clara', 'clara.png'); + game.load.image('saiki', 'saiki.png'); + game.load.image('tileset', 'tileset.png'); + game.load.image('objects', 'objects.png'); + game.load.tilemap('gamemap', 'tilemap.json', null, Phaser.Tilemap.TILED_JSON); + + } + + create() { + + game.world.setBounds(0, 0, 800, 600); + game.stage.backgroundColor = '#000000'; + game.physics.startSystem(Phaser.Physics.ARCADE); + + var map = game.add.tilemap('gamemap'); + map.addTilesetImage('tileset', 'tileset'); + map.addTilesetImage('objects', 'objects'); + var layer_floor = map.createLayer('floor'); + layer_floor.resizeWorld(); + this.layer_walls = map.createLayer('walls'); + map.setCollisionBetween(1, 100, true, this.layer_walls); + this.layer_furniture = map.createLayer('furniture'); + map.setCollisionBetween(1, 100, true, this.layer_furniture); + map.objects['objects'].forEach(function(o) { logic.createObject(o); }); + console.log(map.objects); + + cursors = game.input.keyboard.createCursorKeys(); + console.log(logic); + + } + + update() { + + game.physics.arcade.collide(logic.player, this.layer_walls); + game.physics.arcade.collide(logic.player, this.layer_furniture); + logic.update(); + + } +}