Skip to content

Commit 051deac

Browse files
committed
Assynchronous enemies added to WildX
1 parent b876a72 commit 051deac

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

samples/wildX/engine/game.clv

+11-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function render(gh)
132132
ok = gh.isRunning();
133133

134134
if (!ok) { gh.sync.setStatus(false); }
135-
gh.mw.sleep();
135+
sleep(30);
136136
gh.sync.nextID();
137137
}
138138
}
@@ -141,7 +141,7 @@ function render(gh)
141141
function make_moves(gh)
142142
{
143143
var ok = true;
144-
var st = 0.5;
144+
var st = 0.3;
145145
var tini = microtime();
146146

147147
while (gh.sync.status()) {
@@ -163,7 +163,7 @@ function make_moves(gh)
163163

164164
tini = tfim;
165165
}
166-
gh.mw.sleep();
166+
sleep(15);
167167
gh.sync.nextID();
168168
}
169169
}
@@ -334,9 +334,11 @@ class Game {
334334
function finish() {
335335
this.mw.setColor(8);
336336
this.mw.addStr(this.x0 - 3, 2, "GAME OVER!");
337+
this.mw.refresh();
337338

338339
this.mw.setColor(2);
339340
this.mw.addStr(this.n + this.x0 + 1, 2, "Press 'ctrl+C' to exit.");
341+
this.mw.refresh();
340342

341343
wait(this.mw, 113);
342344
}
@@ -346,9 +348,11 @@ class Game {
346348
function title() {
347349
this.mw.setColor(7);
348350
this.mw.addStr(0, 0, "The Wild X");
351+
this.mw.refresh();
349352

350353
this.mw.setColor(2);
351354
this.mw.addStr(this.n + this.x0 + 1, 2, "Press 'ctrl+C' to quit.");
355+
this.mw.refresh();
352356
}
353357

354358
/****************************************************************************/
@@ -360,6 +364,7 @@ class Game {
360364

361365
this.mw.setColor(this.colors[c]);
362366
this.mw.addChar(i + this.x0, j + this.y0, c);
367+
this.mw.refresh();
363368
}
364369
}
365370
}
@@ -389,6 +394,7 @@ class Game {
389394

390395
this.mw.setColor(this.colors['.']);
391396
this.mw.addChar(px + this.x0, py + this.y0, '.');
397+
this.mw.refresh();
392398

393399
this.mutex.lock();
394400
var kk = this.last_key.getInt();
@@ -483,6 +489,7 @@ class Game {
483489
this.mw.refresh();
484490

485491
print_info(this.mw, "Position player: ", "(" + py + ", " + px + ") ", this.n + this.x0 + 3, 2, 12, 10);
492+
this.mw.refresh();
486493
}
487494

488495
/****************************************************************************/
@@ -496,6 +503,7 @@ class Game {
496503
print_score(this.mw, this.colorst, '$', this.player.score.nS, this.x0 - 2, 25, 12);
497504
print_score(this.mw, this.colorst, '*', this.player.score.nP, this.x0 - 2, 35, 12);
498505
print_score(this.mw, this.colorst, '@', this.player.score.nA, this.x0 - 2, 45, 12);
506+
this.mw.refresh();
499507
}
500508

501509
/****************************************************************************/

0 commit comments

Comments
 (0)