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/contest?.map ../maps/contest10.map)
|
||||||
MAPS+=$(wildcard ../maps/ems*.map)
|
MAPS+=$(wildcard ../maps/ems*.map)
|
||||||
MAPS+=../maps/pacman.map ../maps/pacman2.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
|
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_curmap = mineMaps[map];
|
||||||
mineGui_curndx = ndx;
|
mineGui_curndx = ndx;
|
||||||
mineGui_moves = mineGui_movesBackup[mineGui_curndx];
|
mineGui_moves = mineGui_movesBackup[mineGui_curndx];
|
||||||
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
|
||||||
if (!mineGui_moves) mineGui_moves = "";
|
if (!mineGui_moves) mineGui_moves = "";
|
||||||
|
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
|
||||||
mineGui_updateMine();
|
mineGui_updateMine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,25 +239,26 @@ function mineGui_updateMine() {
|
|||||||
mineGui_show();
|
mineGui_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mineGui_show() {
|
var mineGui_drawQueued = false;
|
||||||
if (!mineGui_mine) return;
|
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;
|
var spriteOffset = mineGui_spriteOffset;
|
||||||
switch (mineGui_mine.state) {
|
switch (mineGui_mine.state) {
|
||||||
case Mine.ALIVE:
|
case Mine.ALIVE:
|
||||||
state = "Still mining";
|
|
||||||
break;
|
break;
|
||||||
case Mine.LOST:
|
case Mine.LOST:
|
||||||
state = "Robot broken - " + mineGui_mine.reason;
|
|
||||||
spriteOffset = mineGui_spriteOffset_Lost;
|
spriteOffset = mineGui_spriteOffset_Lost;
|
||||||
break;
|
break;
|
||||||
case Mine.ABORTED:
|
case Mine.ABORTED:
|
||||||
state = "Aborted";
|
|
||||||
break;
|
break;
|
||||||
case Mine.WON:
|
case Mine.WON:
|
||||||
state = "Won - " + mineGui_mine.reason;
|
|
||||||
spriteOffset = mineGui_spriteOffset_Won;
|
spriteOffset = mineGui_spriteOffset_Won;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -294,6 +295,44 @@ function mineGui_show() {
|
|||||||
mapNode.style.display = '';
|
mapNode.style.display = '';
|
||||||
mapNode.style.visibility = 'visible';
|
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) {
|
if (waterLevel > 0) {
|
||||||
document.getElementById("mineGui_mineMapWater").textContent = map.splice(-waterLevel).join("\n");
|
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