| @@ -0,0 +1,6 @@ | |||||
| { | |||||
| "indent": 1, | |||||
| "esversion": 6, | |||||
| "node": true, | |||||
| "sub": true | |||||
| } | |||||
| @@ -0,0 +1,4 @@ | |||||
| .compass-button { | |||||
| width: 100px; | |||||
| height: 100px; | |||||
| } | |||||
| @@ -0,0 +1,35 @@ | |||||
| <!DOCTYPE html> | |||||
| <html lang="en"> | |||||
| <head> | |||||
| <meta charset="utf-8"> | |||||
| <title>Feast</title> | |||||
| <link rel="stylesheet" href="feast.css"> | |||||
| <script src="world.js"></script> | |||||
| <script src="feast.js"></script> | |||||
| <meta name="theme-color" content="#000000" /> | |||||
| <meta name="description" content="A vore text adventure" /> | |||||
| <meta property="og:title" content="Stroll" /> | |||||
| <meta property="og:description" content="A vore text adventure" /> | |||||
| <meta property="og:image" content="https://chemicalcrux.org/stroll.png" /> | |||||
| <link rel="shortcut icon" href="https://chemicalcrux.org/favicon.ico" type="image/x-icon" /> | |||||
| </head> | |||||
| <body> | |||||
| <div id="location"> | |||||
| </div> | |||||
| <div id="compass"> | |||||
| <button class="compass-button" id="compass-north-west">North West</button> | |||||
| <button class="compass-button" id="compass-north">North</button> | |||||
| <button class="compass-button" id="compass-north-east">North East</button><br> | |||||
| <button class="compass-button" id="compass-west">West</button> | |||||
| <button class="compass-button" id="compass-filler">Filler lol</button> | |||||
| <button class="compass-button" id="compass-east">East</button><br> | |||||
| <button class="compass-button" id="compass-south-west">South West</button> | |||||
| <button class="compass-button" id="compass-south">South</button> | |||||
| <button class="compass-button" id="compass-south-east">South East</button> | |||||
| </div> | |||||
| </body> | |||||
| @@ -0,0 +1,49 @@ | |||||
| let currentRoom = null; | |||||
| function updateDisplay() { | |||||
| document.getElementById("location").innerHTML = currentRoom.name; | |||||
| } | |||||
| function move(direction) { | |||||
| let target = currentRoom.exits[direction]; | |||||
| if (target == null) { | |||||
| alert("Tried to move to an empty room!"); | |||||
| return; | |||||
| } else { | |||||
| updateDisplay(); | |||||
| } | |||||
| } | |||||
| window.addEventListener('load', function(event) { | |||||
| loadCompass(); | |||||
| currentRoom = createWorld(); | |||||
| updateDisplay(); | |||||
| }); | |||||
| function loadCompass() { | |||||
| document.getElementById("compass-north-west").addEventListener("click", function() { | |||||
| move(NORTH_WEST); | |||||
| }); | |||||
| document.getElementById("compass-north").addEventListener("click", function() { | |||||
| move(NORTH); | |||||
| }); | |||||
| document.getElementById("compass-north-east").addEventListener("click", function() { | |||||
| move(NORTH_EAST); | |||||
| }); | |||||
| document.getElementById("compass-west").addEventListener("click", function() { | |||||
| move(WEST); | |||||
| }); | |||||
| document.getElementById("compass-east").addEventListener("click", function() { | |||||
| move(EAST); | |||||
| }); | |||||
| document.getElementById("compass-south-west").addEventListener("click", function() { | |||||
| move(SOUTH_WEST); | |||||
| }); | |||||
| document.getElementById("compass-south").addEventListener("click", function() { | |||||
| move(SOUTH); | |||||
| }); | |||||
| document.getElementById("compass-south-east").addEventListener("click", function() { | |||||
| move(SOUTH_EAST); | |||||
| }); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| "use strict"; | |||||
| let NORTH = 0; | |||||
| let NORTH_EAST = 1; | |||||
| let EAST = 2; | |||||
| let SOUTH_EAST = 3; | |||||
| let SOUTH = 4; | |||||
| let SOUTH_WEST = 5; | |||||
| let WEST = 6; | |||||
| let NORTH_WEST = 7; | |||||
| /*jshint browser: true*/ | |||||
| /*jshint devel: true*/ | |||||
| function Location(name="Nowhere") { | |||||
| this.name = name; | |||||
| this.exits = [null,null,null,null,null,null,null,null]; | |||||
| } | |||||
| function opposite(direction) { | |||||
| return (direction + 4) % 8; | |||||
| } | |||||
| function connectLocations(loc1,loc2,loc1Exit) { | |||||
| if (loc1.exits[loc1Exit] != null) { | |||||
| alert(loc1.name + " is already connected to " + loc1.exits[loc1Exit].name); | |||||
| return; | |||||
| } else if (loc2.exits[opposite(loc1Exit)] != null) { | |||||
| alert(loc2.name + " is already connected to " + loc2.exits[opposite(loc1Exit)].name); | |||||
| return; | |||||
| } else { | |||||
| if (loc1Exit >= 0 && loc1Exit <= 7) { | |||||
| loc1.exits[loc1Exit] = loc2; | |||||
| loc2.exits[opposite(loc1Exit)] = loc1; | |||||
| } | |||||
| } | |||||
| } | |||||
| function createWorld() { | |||||
| let bedroom = new Location("Bedroom"); | |||||
| let bathroom = new Location("Bathroom"); | |||||
| let livingroom = new Location("Living Room"); | |||||
| connectLocations(bedroom,bathroom,EAST); | |||||
| connectLocations(bedroom,livingroom,NORTH); | |||||
| return bedroom; | |||||
| } | |||||