wok diff boulderdash/stuff/freeze.u @ rev 25605
Update some current_version
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Jul 19 10:59:53 2023 +0000 (13 months ago) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/boulderdash/stuff/freeze.u Wed Jul 19 10:59:53 2023 +0000 1.3 @@ -0,0 +1,41 @@ 1.4 +--- boulderdash.js 1.5 ++++ boulderdash.js 1.6 +@@ -4,7 +4,7 @@ Boulderdash = function() { 1.7 + // GENERAL purpose constants and helper methods 1.8 + //========================================================================= 1.9 + 1.10 +- var KEY = { ENTER: 13, ESC: 27, SPACE: 32, PAGEUP: 33, PAGEDOWN: 34, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40 }; 1.11 ++ var KEY = { ENTER: 13, ESC: 27, SPACE: 32, PAGEUP: 33, PAGEDOWN: 34, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, F: 70 }; 1.12 + 1.13 + var Dom = { 1.14 + get: function(id) { return (id instanceof HTMLElement) ? id : document.getElementById(id); }, 1.15 +@@ -162,6 +162,7 @@ Boulderdash = function() { 1.16 + this.step = 1/this.fps; // how long is each game frame (in seconds) 1.17 + this.birth = 2*this.fps; // in which frame is rockford born ? 1.18 + this.timer = this.cave.caveTime; // seconds allowed to complete this cave 1.19 ++ this.freeze = 0; 1.20 + this.idle = { blink: false, tap: false }; // is rockford showing any idle animation ? 1.21 + this.flash = false; // trigger white flash when rockford has collected enought diamonds 1.22 + this.won = false; // set to true when rockford enters the outbox 1.23 +@@ -261,8 +262,12 @@ Boulderdash = function() { 1.24 + this.endFrame(); 1.25 + }, 1.26 + 1.27 ++ toggleFreeze: function() { 1.28 ++ this.freeze = 1 - this.freeze; 1.29 ++ }, 1.30 ++ 1.31 + decreaseTimer: function(n) { 1.32 +- this.timer = Math.max(0, this.timer - (n || 1)); 1.33 ++ if (this.freeze === 0) this.timer = Math.max(0, this.timer - (n || 1)); 1.34 + this.publish('timer', this.timer); 1.35 + return (this.timer === 0); 1.36 + }, 1.37 +@@ -755,6 +760,7 @@ Boulderdash = function() { 1.38 + case KEY.DOWN: moving.startDown(); handled = true; break; 1.39 + case KEY.LEFT: moving.startLeft(); handled = true; break; 1.40 + case KEY.RIGHT: moving.startRight(); handled = true; break; 1.41 ++ case KEY.F: game.toggleFreeze(); handled = true; break; 1.42 + case KEY.ESC: game.reset(); handled = true; break; 1.43 + case KEY.PAGEUP: game.prev(); handled = true; break; 1.44 + case KEY.PAGEDOWN: game.next(); handled = true; break;