delay canvas drawing, only update location.href if idle, add bhickey maps
This commit is contained in:
parent
1a69b4673a
commit
dc3726f4c0
@ -6,6 +6,7 @@ MAPS+=$(wildcard ../maps/flood*.map)
|
||||
MAPS+=$(wildcard ../maps/contest?.map ../maps/contest10.map)
|
||||
MAPS+=$(wildcard ../maps/ems*.map)
|
||||
MAPS+=../maps/pacman.map ../maps/pacman2.map
|
||||
MAPS+=$(wildcard ../maps/bhickey*.map)
|
||||
|
||||
all: maps.js sprites.png gui.min.js mine.min.js maps.min.js
|
||||
|
||||
|
57
js/gui.js
57
js/gui.js
@ -221,8 +221,8 @@ function mineGui_setMap(map, ndx) {
|
||||
mineGui_curmap = mineMaps[map];
|
||||
mineGui_curndx = ndx;
|
||||
mineGui_moves = mineGui_movesBackup[mineGui_curndx];
|
||||
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
||||
if (!mineGui_moves) mineGui_moves = "";
|
||||
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
||||
mineGui_updateMine();
|
||||
}
|
||||
|
||||
@ -239,25 +239,26 @@ function mineGui_updateMine() {
|
||||
mineGui_show();
|
||||
}
|
||||
|
||||
function mineGui_show() {
|
||||
if (!mineGui_mine) return;
|
||||
var mineGui_drawQueued = false;
|
||||
function mineGui_draw() {
|
||||
if (!mineGui_drawQueued) {
|
||||
mineGui_drawQueued = true;
|
||||
window.setTimeout(mineGui_draw_queued, 0);
|
||||
}
|
||||
}
|
||||
function mineGui_draw_queued() {
|
||||
mineGui_drawQueued = false;
|
||||
|
||||
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
||||
var state = "";
|
||||
var spriteOffset = mineGui_spriteOffset;
|
||||
switch (mineGui_mine.state) {
|
||||
case Mine.ALIVE:
|
||||
state = "Still mining";
|
||||
break;
|
||||
case Mine.LOST:
|
||||
state = "Robot broken - " + mineGui_mine.reason;
|
||||
spriteOffset = mineGui_spriteOffset_Lost;
|
||||
break;
|
||||
case Mine.ABORTED:
|
||||
state = "Aborted";
|
||||
break;
|
||||
case Mine.WON:
|
||||
state = "Won - " + mineGui_mine.reason;
|
||||
spriteOffset = mineGui_spriteOffset_Won;
|
||||
break;
|
||||
}
|
||||
@ -294,6 +295,44 @@ function mineGui_show() {
|
||||
mapNode.style.display = '';
|
||||
mapNode.style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
|
||||
var mineGui_fragmentQueued = false;
|
||||
function mineGui_updateFragment() {
|
||||
if (false !== mineGui_fragmentQueued) window.clearTimeout(mineGui_fragmentQueued);
|
||||
mineGui_fragmentQueued = window.setTimeout(mineGui_updateFragment_queued, 100);
|
||||
}
|
||||
function mineGui_updateFragment_queued() {
|
||||
mineGui_fragmentQueued = false;
|
||||
|
||||
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
||||
}
|
||||
|
||||
function mineGui_show(queued) {
|
||||
if (!mineGui_mine) return;
|
||||
|
||||
mineGui_updateFragment();
|
||||
|
||||
var state = "";
|
||||
switch (mineGui_mine.state) {
|
||||
case Mine.ALIVE:
|
||||
state = "Still mining";
|
||||
break;
|
||||
case Mine.LOST:
|
||||
state = "Robot broken - " + mineGui_mine.reason;
|
||||
break;
|
||||
case Mine.ABORTED:
|
||||
state = "Aborted";
|
||||
break;
|
||||
case Mine.WON:
|
||||
state = "Won - " + mineGui_mine.reason;
|
||||
break;
|
||||
}
|
||||
|
||||
var waterLevel = Math.max(mineGui_mine.water_level, 0);
|
||||
var map = mineGui_mine.toString().split(/\n/);
|
||||
|
||||
mineGui_draw();
|
||||
|
||||
if (waterLevel > 0) {
|
||||
document.getElementById("mineGui_mineMapWater").textContent = map.splice(-waterLevel).join("\n");
|
||||
|
2
js/gui.min.js
vendored
2
js/gui.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
js/maps.min.js
vendored
2
js/maps.min.js
vendored
File diff suppressed because one or more lines are too long
26
maps/bhickey1.map
Normal file
26
maps/bhickey1.map
Normal file
@ -0,0 +1,26 @@
|
||||
################################ ##
|
||||
#******#******#******#**********L #
|
||||
##*****##*****##*****##********* #
|
||||
#*#****#*#****#*#****#*#*******## #
|
||||
# *#***# *#***# *#***# *#*****# # #
|
||||
# *#**# *#**# *#**# *#***# # #
|
||||
# *#*# *#*# *#*# *#*# # #
|
||||
# *A* *B* *C* *D* # #
|
||||
# \ \ \ \ # #
|
||||
# * * * * # #
|
||||
#*******************************# #
|
||||
#R..............................# #
|
||||
#\ # #
|
||||
#1 # #
|
||||
# # #
|
||||
################################# #
|
||||
# WE #
|
||||
###################################
|
||||
|
||||
Growth 1
|
||||
Trampoline A targets 1
|
||||
Trampoline B targets 1
|
||||
Trampoline C targets 1
|
||||
Trampoline D targets 1
|
||||
Trampoline E targets 1
|
||||
Author bhickey (https://gist.github.com/3115673)
|
28
maps/bhickey2.map
Normal file
28
maps/bhickey2.map
Normal file
@ -0,0 +1,28 @@
|
||||
###L######################
|
||||
#W#R #*****#!#\\\\\\\\\##
|
||||
#*# ..\.. #\\\\\\\*\##
|
||||
#*#A 2####### ########.###
|
||||
#*# #*****# #*****#B 3##
|
||||
#*# ..\.. ..\.. ##
|
||||
#**E 5 ############## ##
|
||||
#***.##C 1\ D# ####
|
||||
#***. #****###****# ***##
|
||||
#*** #G...\4 ...H# ..\ #
|
||||
#\## ################# ##
|
||||
#\\# #*****#F 6##*** ##
|
||||
#\\# ..\.. ... ##
|
||||
####################### ##
|
||||
##########################
|
||||
|
||||
Water 0
|
||||
Flooding 20
|
||||
Waterproof 18
|
||||
Trampoline A targets 1
|
||||
Trampoline B targets 1
|
||||
Trampoline C targets 2
|
||||
Trampoline D targets 3
|
||||
Trampoline E targets 4
|
||||
Trampoline F targets 4
|
||||
Trampoline G targets 5
|
||||
Trampoline H targets 6
|
||||
Author bhickey (https://gist.github.com/3114986)
|
Loading…
Reference in New Issue
Block a user