Initial commit
authorMegaBrutal <code+git@megabrutal.com>
Mon, 24 Apr 2017 00:20:50 +0000 (02:20 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Mon, 24 Apr 2017 00:20:50 +0000 (02:20 +0200)
First version to be submitted for LD38.

new file:   gem.png
new file:   gem.svg
new file:   gem_active.png
new file:   gem_active.svg
new file:   index.html
new file:   ld38.html
new file:   ld38.js
new file:   player.png
new file:   player.svg
new file:   wall.png

gem.png [new file with mode: 0644]
gem.svg [new file with mode: 0644]
gem_active.png [new file with mode: 0644]
gem_active.svg [new file with mode: 0644]
index.html [new file with mode: 0644]
ld38.html [new file with mode: 0644]
ld38.js [new file with mode: 0644]
player.png [new file with mode: 0644]
player.svg [new file with mode: 0644]
wall.png [new file with mode: 0644]

diff --git a/gem.png b/gem.png
new file mode 100644 (file)
index 0000000..d1e50db
Binary files /dev/null and b/gem.png differ
diff --git a/gem.svg b/gem.svg
new file mode 100644 (file)
index 0000000..b3498d4
--- /dev/null
+++ b/gem.svg
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="16"
+   height="16"
+   viewBox="0 0 16 16"
+   id="svg4735"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="gem.svg"
+   inkscape:export-filename="/tmp/mnt/phaser/ld38/gem.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4737">
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="marker5571"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5573"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="marker5555"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5557"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="Arrow1Lstart"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5291"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="8.0275832"
+     inkscape:cx="-20.568748"
+     inkscape:cy="21.308863"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1375"
+     inkscape:window-height="876"
+     inkscape:window-x="65"
+     inkscape:window-y="24"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata4740">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="1. réteg"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-1036.3622)">
+    <rect
+       style="opacity:0.98000004;fill:#0080ff;fill-opacity:1;stroke:#00ffff;stroke-width:2.339;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect5285"
+       width="9.3232527"
+       height="9.3232527"
+       x="757.17493"
+       y="709.73419"
+       ry="0.62703776"
+       transform="matrix(0.68959732,0.72419302,-0.72419302,0.68959732,0,0)" />
+  </g>
+</svg>
diff --git a/gem_active.png b/gem_active.png
new file mode 100644 (file)
index 0000000..8cff838
Binary files /dev/null and b/gem_active.png differ
diff --git a/gem_active.svg b/gem_active.svg
new file mode 100644 (file)
index 0000000..7d97a5c
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="16"
+   height="16"
+   viewBox="0 0 16 16"
+   id="svg4735"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="gem_active.svg"
+   inkscape:export-filename="/tmp/mnt/phaser/ld38/gem_active.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4737">
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="marker5571"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5573"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="marker5555"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5557"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="Arrow1Lstart"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path5291"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
+         transform="scale(0.8) translate(12.5,0)" />
+    </marker>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="8.0275832"
+     inkscape:cx="-20.568748"
+     inkscape:cy="21.308863"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1375"
+     inkscape:window-height="876"
+     inkscape:window-x="65"
+     inkscape:window-y="24"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata4740">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="1. réteg"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-1036.3622)">
+    <rect
+       style="opacity:0.98000004;fill:#8000ff;fill-opacity:1;stroke:#ff00ff;stroke-width:2.339;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect5285"
+       width="9.3232527"
+       height="9.3232527"
+       x="757.17493"
+       y="709.73419"
+       ry="0.62703776"
+       transform="matrix(0.68959732,0.72419302,-0.72419302,0.68959732,0,0)" />
+  </g>
+</svg>
diff --git a/index.html b/index.html
new file mode 100644 (file)
index 0000000..93b54ff
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+       <meta charset="utf-8"/>
+       <title>Ludum Dare 38 – Working Title</title>
+       <meta name="description" content="" />
+       <style>
+               @font-face { font-family: "Ubuntu Mono"; src: url(UbuntuMono-R.ttf); }
+               h1 { text-decoration: underline; }
+               body { font-family: "Ubuntu Mono", monospace; color: #FFFFFF; background: #000000; }
+       </style>
+</head>
+<body>
+       <div align="center">
+       <h1>Ludum Dare 38 – Working Title</h1>
+       <h2>(Game for Ludum Dare 38)</h2>
+       <iframe width=800 height=600 frameborder="0" scrolling="no" src="ld38.html" seamless>Sorry, your browser is not supported. :(</iframe>
+       <h2>By MegaBrutal</h2>
+       </div>
+</body>
+</html>
diff --git a/ld38.html b/ld38.html
new file mode 100644 (file)
index 0000000..5762b3d
--- /dev/null
+++ b/ld38.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="UTF-8" />
+        <title>Ludum Dare 38 – Working Title</title>
+        <script src="phaser.min.js"></script>
+       <style>
+               @font-face { font-family: "Ubuntu Mono"; src: url(UbuntuMono-R.ttf); }
+               body { font-family: "Ubuntu Mono", monospace; color: #000000; background: #000000; }
+       </style>
+    </head>
+    <body>
+
+    <script src="ld38.js"></script>
+    </body>
+</html>
diff --git a/ld38.js b/ld38.js
new file mode 100644 (file)
index 0000000..3b58c48
--- /dev/null
+++ b/ld38.js
@@ -0,0 +1,197 @@
+        var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
+        var walls;
+        var gems;
+        var shrinklevel = 0;
+
+        const WAIT_KEY          =    200;
+        const WAIT_GEM          =   2000;
+        const WALL_THICKNESS    =     32;
+        const MAX_GEMS          =     16;
+
+        var newWorldStartX;
+        var newWorldEndX;
+        var newWorldStartY;
+        var newWorldEndY;
+
+        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);
+
+        class Entity extends Phaser.Sprite {
+            constructor(x, y, sprite) {
+                super(game, x, y, sprite);
+                this.anchor.setTo(.5,.5);
+            }
+
+            enablePhysics() {
+                game.physics.arcade.enable(this);
+                this.body.bounce.y = 0.2;
+                this.body.bounce.x = 0.2;
+                this.body.collideWorldBounds = true;
+            }
+        }
+
+        class Player extends Entity {
+            constructor(x, y, sprite) {
+                super(x, y, sprite);
+                this.lastmovetime = 0;
+            }
+        }
+
+        class Gem extends Entity {
+            constructor(x, y) {
+                super(x, y, 'gem');
+                this.lastInteraction = 0;
+                this.isActivated = false;
+            }
+
+            activate() {
+                this.isActivated = true;
+                this.loadTexture('gem_active');
+            }
+
+            deactivate() {
+                this.isActivated = false;
+                this.loadTexture('gem');
+            }
+        }
+
+        function sign(n) {
+            if (n >= 0) { return 1 } else { return -1 };
+        }
+
+        function preload () {
+
+            game.load.image('wall', 'wall.png');
+            game.load.image('player', 'player.png');
+            game.load.image('gem', 'gem.png');
+            game.load.image('gem_active', 'gem_active.png');
+
+        }
+
+        function create () {
+
+            game.world.setBounds(0, 0, 800, 600);
+            game.stage.backgroundColor = 'black';
+            game.physics.startSystem(Phaser.Physics.ARCADE);
+
+            walls = game.add.group();
+            walls.classType = Phaser.TileSprite;
+            walls.enableBody = true;
+
+            walls.add(game.add.tileSprite(0, 0, game.world.width, WALL_THICKNESS, 'wall'));
+            walls.add(game.add.tileSprite(0, game.world.height - WALL_THICKNESS, game.world.width, WALL_THICKNESS, 'wall'));
+            walls.add(game.add.tileSprite(0, 0, WALL_THICKNESS, game.world.height, 'wall'));
+            walls.add(game.add.tileSprite(game.world.width - WALL_THICKNESS, 0, WALL_THICKNESS, game.world.height, 'wall'));
+            walls.children.forEach(function(wall) { wall.body.immovable = true; });
+
+            gems = game.add.group();
+            for (var i = 0; i <= MAX_GEMS; i++)
+                gems.add(new Gem((Math.random() * (game.world.width - (WALL_THICKNESS * 4))) + (WALL_THICKNESS * 2), (Math.random() * (game.world.height - (WALL_THICKNESS * 4))) + (WALL_THICKNESS * 2)));
+            gems.children.forEach(function(gem) { gem.enablePhysics(); });
+
+            player = new Player(64, game.world.height - 200, 'player');
+            player.enablePhysics();
+            game.add.existing(player);
+            game.camera.follow(player);
+            cursors = game.input.keyboard.createCursorKeys();
+
+            keyboard_handler = keyPress_default;
+
+            newWorldStartX      =     WALL_THICKNESS;
+            newWorldEndX        =     game.world.width  - WALL_THICKNESS;
+            newWorldStartY      =     WALL_THICKNESS;
+            newWorldEndY        =     game.world.height - WALL_THICKNESS;
+
+            helptext = game.add.text(10, 10, "Move with arrows, activate dimension crystals to shrink the world.", { align: 'left', fill: '#000000', fontSize: 14 });
+            helptext.font = "Ubuntu Mono";
+
+        }
+
+        function update () {
+
+            game.physics.arcade.collide(player, walls);
+            game.physics.arcade.overlap(player, gems, gem_overlap, gem_isInteractable);
+
+            var isAllActive = true;
+            gems.children.forEach(function(gem) { if (!gem.isActivated) { isAllActive = false; }});
+            if (isAllActive) {
+                world_shrink();
+            };
+
+            if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0;
+            if (keyboard_handler) keyboard_handler();
+
+        }
+
+        function keyPress_default() {
+
+            if (cursors.left.isDown)
+            {
+                player.body.velocity.x = -150;
+                player.angle = -90;
+                player.lastmovetime = game.time.now;
+            }
+            else if (cursors.right.isDown)
+            {
+                player.body.velocity.x = 150;
+                player.angle = 90;
+                player.lastmovetime = game.time.now;
+            }
+            if (cursors.up.isDown)
+            {
+                player.body.velocity.y = -150;
+                player.angle = 0;
+                player.lastmovetime = game.time.now;
+            }
+            else if (cursors.down.isDown)
+            {
+                player.body.velocity.y = 150;
+                player.angle = 180;
+                player.lastmovetime = game.time.now;
+            }
+
+        }
+
+        function gem_isInteractable(player, gem) {
+            return (game.time.now - gem.lastInteraction) > WAIT_GEM;
+        }
+
+        function gem_overlap(player, gem) {
+
+            gem.lastInteraction = game.time.now;
+            gem.activate();
+
+        }
+
+        function world_shrink() {
+
+            if (player.x < (newWorldStartX + (newWorldEndX - newWorldStartX) / 2))
+                newWorldEndX   -= (newWorldEndX - newWorldStartX) / 2;
+            else
+                newWorldStartX += (newWorldEndX - newWorldStartX) / 2;
+            if (player.y < (newWorldStartY + (newWorldEndY - newWorldStartY) / 2))
+                newWorldEndY   -= (newWorldEndY - newWorldStartY) / 2;
+            else
+                newWorldStartY += (newWorldEndY - newWorldStartY) / 2;
+
+            // Draw a wall around the new world bounds.
+            walls.add(game.add.tileSprite(newWorldStartX - WALL_THICKNESS, newWorldStartY - WALL_THICKNESS, newWorldEndX - newWorldStartX + WALL_THICKNESS * 2, WALL_THICKNESS, 'wall'));
+            walls.add(game.add.tileSprite(newWorldStartX - WALL_THICKNESS, newWorldEndY, newWorldEndX - newWorldStartX + WALL_THICKNESS * 2, WALL_THICKNESS, 'wall'));
+            walls.add(game.add.tileSprite(newWorldStartX - WALL_THICKNESS, newWorldStartY - WALL_THICKNESS, WALL_THICKNESS, newWorldEndY - newWorldStartY + WALL_THICKNESS * 2, 'wall'));
+            walls.add(game.add.tileSprite(newWorldEndX, newWorldStartY - WALL_THICKNESS, WALL_THICKNESS, newWorldEndY - newWorldStartY + WALL_THICKNESS * 2, 'wall'));
+            walls.children.forEach(function(wall) { wall.body.immovable = true; });
+
+            function relocateGem(gem) {
+                if (gem.x < newWorldStartX) gem.x = newWorldStartX + (newWorldStartX - gem.x);
+                else if (gem.x > newWorldEndX) gem.x = newWorldEndX + (newWorldEndX - gem.x);   // Adding negative value is like substraction.
+                if (gem.y < newWorldStartY) gem.y = newWorldStartY + (newWorldStartY - gem.y);
+                else if (gem.y > newWorldEndY) gem.y = newWorldEndY + (newWorldEndY - gem.y);   // Same.
+                gem.deactivate();
+            }
+            gems.children.forEach(relocateGem);
+
+        }
diff --git a/player.png b/player.png
new file mode 100644 (file)
index 0000000..7081815
Binary files /dev/null and b/player.png differ
diff --git a/player.svg b/player.svg
new file mode 100644 (file)
index 0000000..5dd6c77
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="16"
+   height="16"
+   viewBox="0 0 16 16"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="player.svg"
+   inkscape:export-filename="/tmp/mnt/phaser/ld38/player.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="10"
+     inkscape:cx="17.10881"
+     inkscape:cy="21.780449"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1375"
+     inkscape:window-height="876"
+     inkscape:window-x="65"
+     inkscape:window-y="24"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="1. réteg"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-1036.3622)">
+    <path
+       style="opacity:0.98000004;fill:#00ff00;fill-opacity:1;stroke:#00ff00;stroke-width:0.15586562;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 7.3773171,1051.9931 c -0.1853076,-0.047 -0.4167415,-0.3457 -0.5142921,-0.6644 -0.2217564,-0.7245 -0.2339004,-9.5557 -0.014071,-10.2305 0.1358846,-0.4172 0.2731932,-0.5182 0.8594879,-0.6325 0.6101334,-0.1189 0.7481131,-0.1155 1.0986619,0.027 0.3581637,0.1459 0.4096886,0.6694 0.4833842,4.9112 0.045362,2.6114 0.00782,5.1183 -0.083401,5.571 -0.1540081,0.7642 -0.2133845,0.8331 -0.8293675,0.9629 -0.4015071,0.085 -0.79652,0.1064 -1.0004121,0.055 z"
+       id="path4706"
+       inkscape:connector-curvature="0" />
+    <ellipse
+       style="opacity:0.98000004;fill:none;fill-opacity:1;stroke:#00ff00;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="path4712"
+       cx="7.9933038"
+       cy="1037.8121"
+       rx="6.6038346"
+       ry="7.0085831" />
+  </g>
+</svg>
diff --git a/wall.png b/wall.png
new file mode 100644 (file)
index 0000000..aa512b7
Binary files /dev/null and b/wall.png differ