Skip to content

Commit beb9c92

Browse files
committed
Improve Look mode flow and allow items to be visible
1 parent 430717d commit beb9c92

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

src/Items/Sword.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ class SwordAction extends Action {
4343
world.appendMessage("You kill the " + target.name + ".");
4444

4545
(<Floor>obj).removeOccupation();
46-
console.log("room actors pre: ", room.actors);
47-
console.log("activeRoom actors pre: ", world.getActiveRoom().actors);
4846
room.actors = room.actors.filter(a => {
4947
return a != target;
5048
});
51-
console.log("room actors post: ", room.actors);
52-
console.log("activeRoom actors post: ", world.getActiveRoom().actors);
5349
}
5450

5551
return true;

src/Rooms/Room.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class Room {
145145
}
146146

147147
default: {
148-
console.log("DoorType:", type, " not supported by ", this.name);
148+
console.log("DoorType:", type, " not supported by room:", this.name);
149149
break;
150150
}
151151
}
@@ -164,6 +164,8 @@ export class Room {
164164

165165
addActor(actor: Actor) {
166166
this.actors.push(actor);
167+
this.objects[actor.x][actor.y] = new Floor(actor.x, actor.y, this.floorTile);
168+
(<Floor>this.objects[actor.x][actor.y]).setOccupation(actor);
167169
}
168170

169171
getActors() {

src/Systems/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class Renderer {
256256
}
257257
}
258258

259-
public addWindow(name: string, width: number, height: number, isTiled?: boolean) {
259+
public addWindow(name: string, width: number, height?: number, isTiled?: boolean) {
260260
this.windows[name] = new Window(-1, -1, width, height, isTiled);
261261
this.windows[name].initContext();
262262
this.bind(this.windows[name].getContext());

src/importer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ export class Importer {
3737
let option = new MenuOption(o.name, o.letter);
3838
if (o.toMenu != null) option.toMenu = o.toMenu;
3939
if (o.toState != null) option.toState = o.toState;
40-
menu.addElement(option);
40+
41+
if (o.hidden) {
42+
menu.options[o.letter] = option;
43+
} else {
44+
menu.addElement(option);
45+
}
4146
});
4247

4348
menus[m.name] = menu;

src/main.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class game extends Game {
6161
this.renderer.addWindow('create_game', Menu.width, Menu.height);
6262
this.renderer.addWindow('about_game', Menu.width, Menu.height);
6363

64-
this.renderer.addWindow('messagebox', Menu.width, 2);
64+
this.renderer.addWindow('messagebox', Menu.width, 1);
6565
this.renderer.addWindow('game', Menu.width, Menu.height, true);
6666
this.renderer.addWindow('inventory', Menu.width, Menu.height);
67-
this.renderer.addWindow('status_info', Menu.width, 3);
67+
this.renderer.addWindow('status_info', Menu.width);
6868

6969
this.renderer.hideAllWindows();
7070
this.renderer.windows['start'].show();
@@ -166,6 +166,7 @@ class game extends Game {
166166
}
167167

168168
if (key == 'Escape') {
169+
this.renderer.renderGameObject(this.world.getActiveRoom().objects[this.lookCursor.x][this.lookCursor.y], this.renderer.windows['game'].getContext());
169170
this.state = GameState.Play;
170171
}
171172

@@ -174,6 +175,11 @@ class game extends Game {
174175
if (obj instanceof Floor && (<Floor>obj).getOccupation() != null) {
175176
name = (<Floor>obj).getOccupation().name;
176177
}
178+
179+
if (obj instanceof Floor && (<Floor>obj).getObjects().length > 0) {
180+
name = (<Floor>obj).getObjects()[0].name;
181+
}
182+
177183
(<MenuInfo>this.menus['messagebox'].elements[0]).content = name;
178184

179185
}
@@ -197,9 +203,7 @@ class game extends Game {
197203
this.state = GameState.Look;
198204
this.lookCursor.x = this.world.getPlayer().x;
199205
this.lookCursor.y = this.world.getPlayer().y;
200-
201-
// this.renderer.renderLookCursor(this.lookCursor, this.renderer.windows['game'].getContext());
202-
206+
return;
203207
}
204208

205209
this.world.getPlayer().receiveKeyInput(key);

src/menus.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,26 @@
3939
"letter": "s",
4040
"name": "Enter Seed",
4141
"onSelect": "seed_entry"
42+
},
43+
{
44+
"letter": "Escape",
45+
"name": "",
46+
"toMenu": "start",
47+
"hidden": "true"
4248
}
4349
]
4450
},
4551
{
4652
"name": "about_game",
4753
"title": "About Game",
48-
"options": []
54+
"options": [
55+
{
56+
"letter": "Escape",
57+
"name": "",
58+
"toMenu": "start",
59+
"hidden": "true"
60+
}
61+
]
4962
}
5063
],
5164
"menuActions": [

0 commit comments

Comments
 (0)