瀏覽代碼

Audio information is included with each game. Reorganized a bit.

tags/v0.1.0
Fen Dweller 6 年之前
父節點
當前提交
db1121d989
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: E80B35A6F11C3656
共有 3 個文件被更改,包括 94 次插入82 次删除
  1. +7
    -5
      audio.js
  2. +1
    -1
      satiate.js
  3. +86
    -76
      world.js

+ 7
- 5
audio.js 查看文件

@@ -169,13 +169,15 @@ function checkCache(type, name, hit, miss) {
}
}

function initAudio() {
audioContext = new (window.AudioContext || window.webkitAudioContext)();

console.log("Initialized audio context");
console.log(audioContext);
function initAudio(game, state) {
if (!audioContext)
audioContext = new (window.AudioContext || window.webkitAudioContext)();

createCache();

games[game].sounds.forEach(sound => {
loadAudio(sound);
});
}

// caching stuff here


+ 1
- 1
satiate.js 查看文件

@@ -30,7 +30,7 @@ function print(lines) {

function init() {
initWorld("demo", state);
initAudio();
initAudio("demo", state);

goToRoom("Home", state);
}


+ 86
- 76
world.js 查看文件

@@ -12,12 +12,11 @@ dirs = {
}

function initWorld(worldChoice, state) {
state.world = worlds[worldChoice];
state.world = games[worldChoice]["world"];
initRoomState(state);
}

function initRoomState(state) {
console.log(state.world);
state.player.rooms = {};
Object.entries(state.world).forEach(([key, val]) => {
state.player.rooms[key] = {};
@@ -37,7 +36,6 @@ function removeActionDescription() {
}

function moveToRoom(src, exit, dest, state) {
console.log(state)
const room = state.world[dest];

if (exit.hooks) {
@@ -181,85 +179,97 @@ function updateRoom(dest, state) {

}

worlds = {
games = {
"demo": {
"Home": {
"id": "Home",
"name": "Home",
"desc": "Where the wifi autoconnects",
"move": (room, state) => {
print(["You go back to your living room"]);
},
"actions": [
{
"name": "Squint",
"desc": "Squint in a very aggressive manner",
"execute": (room, state) => {
state.player.rooms[room.id].squinted = true;
print(["You stare at the wall and notice a secret door. But where is the key?"]);
}
"id": "demo",
"sounds": [
"sfx/oof.ogg"
],
"world": {
"Home": {
"id": "Home",
"name": "Home",
"desc": "Where the wifi autoconnects",
"move": (room, state) => {
print(["You go back to your living room"]);
},
{
"name": "Find Keys",
"desc": "Find your keys",
"execute": (room, state) => {
state.player.items.keys.push("Locked Room");
print(["You found your keys under the couch cushions"]);
"actions": [
{
"name": "Squint",
"desc": "Squint in a very aggressive manner",
"execute": (room, state) => {
state.player.rooms[room.id].squinted = true;
print(["You stare at the wall and notice a secret door. But where is the key?"]);
}
},
"show": [
(room, state) => {
return state.player.rooms[room.id].squinted;
{
"name": "Find Keys",
"desc": "Find your keys",
"execute": (room, state) => {
state.player.items.keys.push("Locked Room");
print(["You found your keys under the couch cushions"]);
},
(room, state) => {
return !state.player.items.keys.includes("Locked Room");
}
]
}
],
"exits": {
"up": {
"target": "Locked Room",
"desc": "It's locked!",
"conditions": [
(room, state) => {
return state.player.items.keys.includes("Locked Room");
}
],
"show": [
(room, state) => {
console.log(room);
return state.player.rooms[room.id].squinted;
}
]
}
},
"hooks": [
(room, state) => {
print(["This is a test of the hooks"]);
return true;
}
]
},
"Locked Room": {
"id": "Locked Room",
"name": "Locked Room",
"desc": "Super seecret",
"move": (room, state) => {
print(["You enter the locked room. wowie!"]);
"show": [
(room, state) => {
return state.player.rooms[room.id].squinted;
},
(room, state) => {
return !state.player.items.keys.includes("Locked Room");
}
]
}
],
"exits": {
"up": {
"target": "Locked Room",
"desc": "It's locked!",
"conditions": [
(room, state) => {
return state.player.items.keys.includes("Locked Room");
}
],
"show": [
(room, state) => {
return state.player.rooms[room.id].squinted;
}
]
}
},
"hooks": [
(room, state) => {
print(["This is a test of the hooks"]);
return true;
}
]
},
"exits": {
"down": {
"target": "Home",
"desc": "Back to home",
"hooks": [
(room, exit, state) => {
print(["Potato"]);
console.log(room);
console.log(exit);
console.log(state);
return true;
"Locked Room": {
"id": "Locked Room",
"name": "Locked Room",
"desc": "Super seecret",
"move": (room, state) => {
print(["You enter the locked room. wowie!"]);
},
"actions": [
{
name: "Oof",
desc: "Oof",
execute: (room, state) => {
print(["Oof"]);
playSfx("sfx/oof.ogg");
}
]
}
],
"exits": {
"down": {
"target": "Home",
"desc": "Back to home",
"hooks": [
(room, exit, state) => {
print(["Potato"]);
return true;
}
]
}
}
}
}


Loading…
取消
儲存