Просмотр исходного кода

Buttons disable/enable properly. Rooms are described. Version number, baby!

tags/v0.2.8
Fen Dweller 8 лет назад
Родитель
Сommit
753b2edc2f
4 измененных файлов: 87 добавлений и 22 удалений
  1. +8
    -0
      feast.css
  2. +38
    -11
      feast.html
  3. +33
    -10
      feast.js
  4. +8
    -1
      world.js

+ 8
- 0
feast.css Просмотреть файл

@@ -15,6 +15,14 @@ button {
height: 100px; height: 100px;
} }


.active-compass-button {

}

.inactive-compass-button {
background: #111;
}

#log { #log {
background: #222; background: #222;
width: 100%; width: 100%;


+ 38
- 11
feast.html Просмотреть файл

@@ -19,24 +19,51 @@


<div id="game-and-stats"> <div id="game-and-stats">
<div id="log"> <div id="log">
qweqwwetr
Welcome to Feast v0.0.3
</div> </div>
<div id="stats"> <div id="stats">
qweqw
qweqw
</div> </div>
</div> </div>
<div id="footer"> <div id="footer">
<div id="compass"> <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>
<table>
<tr>
<th>
<button class="compass-button" id="compass-north-west">North West</button>
</th>
<th>
<button class="compass-button" id="compass-north">North</button>
</th>
<th>
<button class="compass-button" id="compass-north-east">North East</button>
</th>
</tr>
<tr>
<th>
<button class="compass-button" id="compass-west">West</button>
</th>
<th>
<button class="compass-button inactive-compass-button" id="compass-filler" disabled="true"></button>
</th>
<th>
<button class="compass-button" id="compass-east">East</button>
</th>
</tr>
<tr>
<th>
<button class="compass-button" id="compass-south-west">South West</button>
</th>
<th>
<button class="compass-button" id="compass-south">South</button>
</th>
<th>
<button class="compass-button" id="compass-south-east">South East</button>
</th>
</tr>
</table>
</div> </div>
</div> </div>
</body> </body>

</html> </html>

+ 33
- 10
feast.js Просмотреть файл

@@ -1,7 +1,21 @@
let currentRoom = null; let currentRoom = null;
let dirButtons = [];


function updateDisplay() { function updateDisplay() {
document.getElementById("location").innerHTML = currentRoom.name;
for (let i = 0; i < dirButtons.length; i++) {
let button = dirButtons[i];
if (currentRoom.exits[i] == null) {
button.disabled = true;
button.classList.remove("active-compass-button");
button.classList.add("inactive-compass-button");
button.innerHTML = "";
} else {
button.disabled = false;
button.classList.remove("inactive-compass-button");
button.classList.add("active-compass-button");
button.innerHTML = currentRoom.exits[i].name;
}
}
} }


function move(direction) { function move(direction) {
@@ -11,7 +25,7 @@ function move(direction) {
return; return;
} else { } else {
currentRoom = target; currentRoom = target;
update(["You move to " + currentRoom.name]);
update(["You move to " + currentRoom.name,currentRoom.description]);
updateDisplay(); updateDisplay();
} }


@@ -30,31 +44,40 @@ function update(lines=[]) {
div.innerHTML = lines[i]; div.innerHTML = lines[i];
log.appendChild(div); log.appendChild(div);
} }
updateDisplay();
} }


function loadCompass() { function loadCompass() {
document.getElementById("compass-north-west").addEventListener("click", function() {
dirButtons[NORTH_WEST] = document.getElementById("compass-north-west");
dirButtons[NORTH_WEST].addEventListener("click", function() {
move(NORTH_WEST); move(NORTH_WEST);
}); });
document.getElementById("compass-north").addEventListener("click", function() {
dirButtons[NORTH] = document.getElementById("compass-north");
dirButtons[NORTH].addEventListener("click", function() {
move(NORTH); move(NORTH);
}); });
document.getElementById("compass-north-east").addEventListener("click", function() {
dirButtons[NORTH_EAST] = document.getElementById("compass-north-east");
dirButtons[NORTH_EAST].addEventListener("click", function() {
move(NORTH_EAST); move(NORTH_EAST);
}); });
document.getElementById("compass-west").addEventListener("click", function() {
dirButtons[WEST] = document.getElementById("compass-west");
dirButtons[WEST].addEventListener("click", function() {
move(WEST); move(WEST);
}); });
document.getElementById("compass-east").addEventListener("click", function() {
dirButtons[EAST] = document.getElementById("compass-east");
dirButtons[EAST].addEventListener("click", function() {
move(EAST); move(EAST);
}); });
document.getElementById("compass-south-west").addEventListener("click", function() {
dirButtons[SOUTH_WEST] = document.getElementById("compass-south-west");
dirButtons[SOUTH_WEST].addEventListener("click", function() {
move(SOUTH_WEST); move(SOUTH_WEST);
}); });
document.getElementById("compass-south").addEventListener("click", function() {
dirButtons[SOUTH] = document.getElementById("compass-south");
dirButtons[SOUTH].addEventListener("click", function() {
move(SOUTH); move(SOUTH);
}); });
document.getElementById("compass-south-east").addEventListener("click", function() {
dirButtons[SOUTH_EAST] = document.getElementById("compass-south-east");
dirButtons[SOUTH_EAST].addEventListener("click", function() {
move(SOUTH_EAST); move(SOUTH_EAST);
}); });
} }

+ 8
- 1
world.js Просмотреть файл

@@ -14,7 +14,7 @@ let NORTH_WEST = 7;


function Location(name="Nowhere") { function Location(name="Nowhere") {
this.name = name; this.name = name;
this.description = "Not much of anything, really.";
this.description = "";
this.exits = [null,null,null,null,null,null,null,null]; this.exits = [null,null,null,null,null,null,null,null];
} }


@@ -41,9 +41,16 @@ function createWorld() {
let bedroom = new Location("Bedroom"); let bedroom = new Location("Bedroom");
let bathroom = new Location("Bathroom"); let bathroom = new Location("Bathroom");
let livingroom = new Location("Living Room"); let livingroom = new Location("Living Room");
let street = new Location("Street");
let alley = new Location("Alley");
let hotvore = new Location("Sexy vore scene");
hotvore.description = "Oh murr";


connectLocations(bedroom,bathroom,EAST); connectLocations(bedroom,bathroom,EAST);
connectLocations(bedroom,livingroom,NORTH); connectLocations(bedroom,livingroom,NORTH);
connectLocations(livingroom,street,NORTH);
connectLocations(street,alley,WEST);
connectLocations(alley,hotvore,NORTH_WEST);


return bedroom; return bedroom;
} }

Загрузка…
Отмена
Сохранить