home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7f15f01
)
Make map rendering slightly more efficient.
author
Christian Heller
<c.heller@plomlompom.de>
Sun, 25 Oct 2020 06:18:09 +0000
(07:18 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sun, 25 Oct 2020 06:18:09 +0000
(07:18 +0100)
new2/rogue_chat.html
patch
|
blob
|
history
diff --git
a/new2/rogue_chat.html
b/new2/rogue_chat.html
index 3d8e4c3850fa373bdb8dae0e2823cef6c50729be..f584ddd3108ccecbbb035047a5d9245a3984456f 100644
(file)
--- a/
new2/rogue_chat.html
+++ b/
new2/rogue_chat.html
@@
-26,13
+26,14
@@
let terminal = {
set_font: function(type='normal') {
this.ctx.font = type + ' ' + this.charHeight + 'px monospace';
},
set_font: function(type='normal') {
this.ctx.font = type + ' ' + this.charHeight + 'px monospace';
},
+ write_cheap: function(start_y, start_x, msg) {
+ this.ctx.fillText(msg, start_x*this.charWidth, start_y*this.charHeight);
+ },
+ set_color: function(color) {
+ this.ctx.fillStyle = color;
+ },
write: function(start_y, start_x, msg, foreground_color='white') {
write: function(start_y, start_x, msg, foreground_color='white') {
- if (foreground_color === 'black') {
- this.ctx.fillStyle = 'white';
- } else {
- this.ctx.fillStyle = 'black';
- }
- this.ctx.fillText(msg, start_x*this.charWidth, start_y*this.charHeight);
+ this.ctx.fillStyle = 'black';
this.ctx.fillRect(start_x*this.charWidth, start_y*this.charHeight,
this.charWidth*msg.length, this.charHeight);
this.ctx.fillStyle = foreground_color;
this.ctx.fillRect(start_x*this.charWidth, start_y*this.charHeight,
this.charWidth*msg.length, this.charHeight);
this.ctx.fillStyle = foreground_color;
@@
-99,22
+100,28
@@
let tui = {
}
},
draw_map: function() {
}
},
draw_map: function() {
- terminal.drawBox(0, 0, terminal.rows, terminal.cols / 2);
+ terminal.drawBox(0, 0, terminal.rows, terminal.cols / 2, 'black');
+ let last_c = '';
+ let color = 'white';
for (let i = 0, y = 0, x = 0; i < game.map.length; i++, x++) {
if (x >= game.map_size[1]) {
x = 0;
y += 1;
};
let c = game.map[i];
for (let i = 0, y = 0, x = 0; i < game.map.length; i++, x++) {
if (x >= game.map_size[1]) {
x = 0;
y += 1;
};
let c = game.map[i];
- let color = 'white';
- if (c == '.') {
- color = '#ffaa00';
- } else if (c == '~') {
- color = '#5555ff';
- } else if (c == 'X') {
- color = '#55ff00';
+ if (c != last_c) {
+ last_c = c;
+ color = 'white';
+ if (c == '.') {
+ color = '#ffaa00';
+ } else if (c == '~') {
+ color = '#5555ff';
+ } else if (c == 'X') {
+ color = '#55ff00';
+ }
+ terminal.set_color(color);
}
}
- terminal.write
(y, x, game.map[i], color
);
+ terminal.write
_cheap(y, x, c
);
}
for (const t in game.things) {
terminal.write(game.things[t][0], game.things[t][1], '@');
}
for (const t in game.things) {
terminal.write(game.things[t][0], game.things[t][1], '@');