From 8365e5f779829456056345af2c145d35c4e14e30 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Mon, 18 Apr 2016 03:16:45 +0000 Subject: [PATCH] Initial commit Changes to be committed: new file: bird.svg new file: birdcage.svg new file: csaj.svg new file: ground.svg new file: guard.svg new file: index.html new file: kecskecsaj.svg new file: shapeshift.html new file: shapeshift.js --- bird.svg | 58 +++++++++ birdcage.svg | 122 +++++++++++++++++++ csaj.svg | 97 +++++++++++++++ ground.svg | 12 ++ guard.svg | 133 +++++++++++++++++++++ index.html | 20 ++++ kecskecsaj.svg | 139 ++++++++++++++++++++++ shapeshift.html | 12 ++ shapeshift.js | 311 ++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 904 insertions(+) create mode 100644 bird.svg create mode 100644 birdcage.svg create mode 100644 csaj.svg create mode 100644 ground.svg create mode 100644 guard.svg create mode 100644 index.html create mode 100644 kecskecsaj.svg create mode 100644 shapeshift.html create mode 100644 shapeshift.js diff --git a/bird.svg b/bird.svg new file mode 100644 index 0000000..c9a7481 --- /dev/null +++ b/bird.svg @@ -0,0 +1,58 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/birdcage.svg b/birdcage.svg new file mode 100644 index 0000000..c648a4f --- /dev/null +++ b/birdcage.svg @@ -0,0 +1,122 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/csaj.svg b/csaj.svg new file mode 100644 index 0000000..05696f5 --- /dev/null +++ b/csaj.svg @@ -0,0 +1,97 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground.svg b/ground.svg new file mode 100644 index 0000000..b79998a --- /dev/null +++ b/ground.svg @@ -0,0 +1,12 @@ + + + + + diff --git a/guard.svg b/guard.svg new file mode 100644 index 0000000..10e764c --- /dev/null +++ b/guard.svg @@ -0,0 +1,133 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..138de3c --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + Ludum Dare 35 – Shapeshifting Goddess! + + + + +
+

Shapeshifting Goddess!

+

(Game for Ludum Dare 35)

+ +

By MegaBrutal

+
+ + diff --git a/kecskecsaj.svg b/kecskecsaj.svg new file mode 100644 index 0000000..d2c2a9c --- /dev/null +++ b/kecskecsaj.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/shapeshift.html b/shapeshift.html new file mode 100644 index 0000000..84916f9 --- /dev/null +++ b/shapeshift.html @@ -0,0 +1,12 @@ + + + + + Ludum Dare 35 – Shapeshifting Goddess! + + + + + + + diff --git a/shapeshift.js b/shapeshift.js new file mode 100644 index 0000000..ed05a37 --- /dev/null +++ b/shapeshift.js @@ -0,0 +1,311 @@ + window.onload = function() { + + var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); + var platforms; + var guards; + var guard1, guard2; + var birdcage; + var helptext; + var cursors; + var lastkeytime = 0; + var keyboard_handler; + var interaction_handler; + var actual_dialogue = null; + + var WAIT_KEY = 500; + + var SHAPE_GIRL = 0; + var SHAPE_GOAT = 1; + var SHAPE_BIRD = 2; + + var dialogue_guard1_girl = + [ { actor: 'player', text: "Hello! May I enter this town?" }, + { actor: 'guard', text: "Sorry, I don't know you.\nI can't let you in." } ]; + var dialogue_guard1_girl_retry = + [ { actor: 'player', text: "But I'm a goddess!" }, + { actor: 'guard', text: "I'm a feminist.\nI don't put women on pedestals." } ]; + var dialogue_guard1_goat = + [ { actor: 'guard', text: "Hmm, it must be Coralie's lost goat.\nI'd better let it in." } ]; + var dialogue_guard2_girl = + [ { actor: 'player', text: "Hi there! I'm a goddess and can transform into a goat!" }, + { actor: 'guard', text: "Hey, that's really cool!\nI'm Coralie." }, + { actor: 'player', text: "Nice bird you have there.\nCan I have it?" }, + { actor: 'guard', text: "Yeah, it's yours. Just take it." }, + { actor: 'guard', text: "Don't mind that it took me days to catch it." }, + { actor: 'player', text: "Observing this bird, I will be able to shapeshift into a bird too!" } ]; + var dialogue_guard2_goat = + [ { actor: 'guard', text: "This is not my goat. Strange to see random\ngoats wandering here while mine is still missing." } ]; + var dialogue_guard3_girl = + [ { actor: 'player', text: "Hi! I'd like to leave the town." }, + { actor: 'guard', text: "Sorry, we have a report of a missing goat.\nIt may have been stolen. We can't let anyone out\nuntil we find the thief." }, + { actor: 'player', text: "I just came here before the goat went missing. The other guard can support this." }, + { actor: 'player', text: "And the goat may have just wandered away.\nYou know they tend to escape, they require lots of space." }, + { actor: 'guard', text: "Maybe, but we can't be sure. Sorry." } ]; + var dialogue_guard3_girl_retry = + [ { actor: 'player', text: "But I'm a girl! I wouldn't steal anything!" }, + { actor: 'guard', text: "I'm a feminist.\nI don't give advantages to people based on their genders." } ]; + var dialogue_guard3_goat = + [ { actor: 'guard', text: "Another goat is trying to escape...\nGood that I'm on guard!" } ]; + var dialogue_guard3_bird = + [ { actor: 'guard', text: "Hi birdie! Don't fly at me, please!" } ]; + var dialogue_guard4_girl = + [ { actor: 'guard', text: "You are at home!\nYou don't have to pretend anymore." } ]; + var dialogue_guard4_goat = + [ { actor: 'guard', text: "Welcome home!\nGlad you shapeshifted back to your true form!" }, + { actor: 'guard', text: "Yes, your true form is goat.\nDidn't you suspect it all along?" } ]; + var dialogue_guard4_goat_retry = + [ { actor: 'guard', text: "(By the way, this is the end of the game.\nYou really can't do anything more.\nThanks for playing!)" } ]; + + + function sign(n) { + if (n >= 0) { return 1 } else { return -1 }; + } + + function preload () { + + game.load.image('ground', 'ground.svg'); + game.load.image('player_girl', 'csaj.svg'); + game.load.image('player_goat', 'kecskecsaj.svg'); + game.load.image('player_bird', 'bird.svg'); + game.load.image('guard', 'guard.svg'); + game.load.image('birdcage', 'birdcage.svg'); + + } + + function create () { + + game.world.setBounds(0, 0, 2800, 600); + game.stage.backgroundColor = 0xffffff; + game.physics.startSystem(Phaser.Physics.ARCADE); + + platforms = game.add.group(); + platforms.classType = Phaser.TileSprite; + platforms.enableBody = true; + + + var ground = game.add.tileSprite(0, game.world.height - 80, game.world.width, 200, 'ground'); + platforms.add(ground); + ground.body.immovable = true; + + + player = game.add.sprite(64, game.world.height - 200, 'player_girl'); + player.anchor.setTo(.4,.5); + player.scale.x = 0.5; + player.scale.y = player.scale.x; + game.physics.arcade.enable(player); + player.body.bounce.y = 0.2; + player.body.bounce.x = 0.2; + player.body.gravity.y = 300; + player.body.collideWorldBounds = true; + player.pushed = 0; + player.shape = SHAPE_GIRL; + player.learnedBird = false; + game.camera.follow(player); + + guards = game.add.group(); + guard1 = createGuard(600, game.world.height - 200, 'guard', + { girl: dialogue_guard1_girl, goat: dialogue_guard1_goat }); + guard2 = createGuard(1000, game.world.height - 200, 'player_girl', + { girl: dialogue_guard2_girl, goat: dialogue_guard2_goat }); + guard2.scale.x = -guard2.scale.x; + guard3 = createGuard(1400, game.world.height - 200, 'guard', + { girl: dialogue_guard3_girl, goat: dialogue_guard3_goat, bird: dialogue_guard3_bird }); + guard4 = createGuard(2400, game.world.height - 200, 'player_goat', + { girl: dialogue_guard4_girl, goat: dialogue_guard4_goat, bird: dialogue_guard4_girl }); + guard4.scale.x = -guard4.scale.x; + + birdcage = game.add.sprite(1100, game.world.height - 300, 'birdcage'); + birdcage.scale.x = 0.5; + birdcage.scale.y = birdcage.scale.x; + + cursors = game.input.keyboard.createCursorKeys(); + + keyboard_handler = keyPress_default; + interaction_handler = interaction; + + helptext = game.add.text(80, 30, "Press ARROWS to move.", { align: 'left', fill: '#000000', fontSize: 14 }); + helptext.font = "Ubuntu Mono"; + + } + + function update () { + + game.physics.arcade.collide(player, platforms); + game.physics.arcade.collide(guards, platforms); + game.physics.arcade.collide(player, guards, interaction_handler); + + if (player.pushed) + { + if ((game.time.now - player.pushed) > 1000) + player.pushed = 0; + } + else + { + player.body.velocity.x = 0; + } + + if (keyboard_handler) keyboard_handler(); + + } + + function keyPress_default() { + + if (cursors.left.isDown) + { + player.body.velocity.x = -150; + player.scale.x = - Math.abs(player.scale.x); + } + else if (cursors.right.isDown) + { + player.body.velocity.x = 150; + player.scale.x = Math.abs(player.scale.x); + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && ((game.time.now - lastkeytime) > WAIT_KEY)) + { + if (player.shape == SHAPE_GIRL) + { + player.shape = SHAPE_GOAT; + player.loadTexture('player_goat'); + } + else if ((player.shape == SHAPE_GOAT) && (player.learnedBird)) + { + player.shape = SHAPE_BIRD; + player.loadTexture('player_bird'); + } + else + { + player.shape = SHAPE_GIRL; + player.loadTexture('player_girl'); + } + lastkeytime = game.time.now; + } + + if ((cursors.up.isDown) && (player.shape == SHAPE_BIRD)) + { + player.body.velocity.y = -200; + } + + } + + function keyPress_indialogue() { + + if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && ((game.time.now - lastkeytime) > WAIT_KEY)) + { + var dialogue = actual_dialogue.dialogue; + if (dialogue[actual_dialogue.state + 1]) + { + var nextState = ++actual_dialogue.state; + var actor = null; + if (dialogue[nextState].actor == 'player') actor = actual_dialogue.player; + else if (dialogue[nextState].actor == 'guard') actor = actual_dialogue.guard; + + actual_dialogue.lastText.kill(); + actual_dialogue.lastText = putText(actor, dialogue[nextState].text); + lastkeytime = game.time.now; + } + else + { + leaveDialogue(); + lastkeytime = game.time.now; + } + } + + } + + function createGuard(x, y, sprite, dialogues) { + + var guard = game.add.sprite(x, y, sprite); + guard.anchor.setTo(.5,.5); + guard.scale.x = 0.5; + guard.scale.y = guard.scale.x; + game.physics.arcade.enable(guard); + guard.body.bounce.y = 0.2; + guard.body.bounce.x = 0.2; + guard.body.gravity.y = 300; + guard.body.collideWorldBounds = true; + guard.dialogues = dialogues; + guards.add(guard); + return guard; + + } + + function putText(entity, text, color = '#000000') { + var textObject = game.add.text(entity.x, entity.y - (entity.height / 2) - 30, text, { align: 'center', fill: color, fontSize: 14 }); + textObject.font = 'Ubuntu Mono'; + textObject.anchor.setTo(.5,.5); + return textObject; + } + + function interaction(player, guard) { + + console.log('Interaction with ' + guard.key); + player.body.velocity.x = -100; + player.pushed = game.time.now; + guard.body.velocity.x = 0; + + if (player.shape == SHAPE_GIRL) + { + if ((guard == guard1) && (guard.dialogues.girl == dialogue_guard1_girl)) + helptext.text = helptext.text + "\nPress SPACE to progress dialogue."; + enterDialogue(player, guard, guard.dialogues.girl); + } + else if (player.shape == SHAPE_GOAT) + { + enterDialogue(player, guard, guard.dialogues.goat); + } + else if (player.shape == SHAPE_BIRD) + { + enterDialogue(player, guard, guard.dialogues.bird); + } + + } + + function enterDialogue(player, guard, dialogue) { + + var actor = null; + if (dialogue[0].actor == 'player') actor = player; + else if (dialogue[0].actor == 'guard') actor = guard; + + var lastText = putText(actor, dialogue[0].text); + actual_dialogue = { player: player, guard: guard, dialogue: dialogue, state: 0 , lastText: lastText }; + keyboard_handler = keyPress_indialogue; + interaction_handler = null; + + } + + function leaveDialogue() { + + actual_dialogue.lastText.kill(); + if (actual_dialogue.dialogue == dialogue_guard1_girl) + { + helptext.text = helptext.text + "\nPress SPACE to shapeshift."; + guard1.dialogues.girl = dialogue_guard1_girl_retry; + } + else if (actual_dialogue.dialogue == dialogue_guard1_goat) + { + guard1.kill(); + } + else if (actual_dialogue.dialogue == dialogue_guard2_girl) + { + guard2.kill(); + birdcage.kill(); + player.learnedBird = true; + } + else if (actual_dialogue.dialogue == dialogue_guard3_girl) + { + guard3.dialogues.girl = dialogue_guard3_girl_retry; + } + else if (actual_dialogue.dialogue == dialogue_guard4_goat) + { + guard4.dialogues.goat = dialogue_guard4_goat_retry; + guard4.dialogues.girl = dialogue_guard4_goat_retry; + guard4.dialogues.bird = dialogue_guard4_goat_retry; + } + + actual_dialogue = null; + keyboard_handler = keyPress_default; + interaction_handler = interaction; + + } + + }; -- 2.34.1