wok annotate boulderdash/stuff/freeze.u @ rev 25037

Up glza (0.11.4)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 21 21:38:29 2022 +0000 (2022-05-21)
parents
children
rev   line source
pascal@24126 1 --- boulderdash.js
pascal@24126 2 +++ boulderdash.js
pascal@24126 3 @@ -4,7 +4,7 @@ Boulderdash = function() {
pascal@24126 4 // GENERAL purpose constants and helper methods
pascal@24126 5 //=========================================================================
pascal@24126 6
pascal@24126 7 - var KEY = { ENTER: 13, ESC: 27, SPACE: 32, PAGEUP: 33, PAGEDOWN: 34, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40 };
pascal@24126 8 + var KEY = { ENTER: 13, ESC: 27, SPACE: 32, PAGEUP: 33, PAGEDOWN: 34, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, F: 70 };
pascal@24126 9
pascal@24126 10 var Dom = {
pascal@24126 11 get: function(id) { return (id instanceof HTMLElement) ? id : document.getElementById(id); },
pascal@24126 12 @@ -162,6 +162,7 @@ Boulderdash = function() {
pascal@24126 13 this.step = 1/this.fps; // how long is each game frame (in seconds)
pascal@24126 14 this.birth = 2*this.fps; // in which frame is rockford born ?
pascal@24126 15 this.timer = this.cave.caveTime; // seconds allowed to complete this cave
pascal@24126 16 + this.freeze = 0;
pascal@24126 17 this.idle = { blink: false, tap: false }; // is rockford showing any idle animation ?
pascal@24126 18 this.flash = false; // trigger white flash when rockford has collected enought diamonds
pascal@24126 19 this.won = false; // set to true when rockford enters the outbox
pascal@24126 20 @@ -261,8 +262,12 @@ Boulderdash = function() {
pascal@24126 21 this.endFrame();
pascal@24126 22 },
pascal@24126 23
pascal@24126 24 + toggleFreeze: function() {
pascal@24126 25 + this.freeze = 1 - this.freeze;
pascal@24126 26 + },
pascal@24126 27 +
pascal@24126 28 decreaseTimer: function(n) {
pascal@24126 29 - this.timer = Math.max(0, this.timer - (n || 1));
pascal@24126 30 + if (this.freeze === 0) this.timer = Math.max(0, this.timer - (n || 1));
pascal@24126 31 this.publish('timer', this.timer);
pascal@24126 32 return (this.timer === 0);
pascal@24126 33 },
pascal@24126 34 @@ -755,6 +760,7 @@ Boulderdash = function() {
pascal@24126 35 case KEY.DOWN: moving.startDown(); handled = true; break;
pascal@24126 36 case KEY.LEFT: moving.startLeft(); handled = true; break;
pascal@24126 37 case KEY.RIGHT: moving.startRight(); handled = true; break;
pascal@24126 38 + case KEY.F: game.toggleFreeze(); handled = true; break;
pascal@24126 39 case KEY.ESC: game.reset(); handled = true; break;
pascal@24126 40 case KEY.PAGEUP: game.prev(); handled = true; break;
pascal@24126 41 case KEY.PAGEDOWN: game.next(); handled = true; break;