mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-27 09:58:44 +01:00
removing an ugly switch by adding an ugly array :/
This commit is contained in:
parent
f14b429b17
commit
bb2cee5dff
1 changed files with 9 additions and 21 deletions
|
@ -14,6 +14,13 @@ direction = {
|
||||||
LEFT: 'l',
|
LEFT: 'l',
|
||||||
RIGHT: 'r'
|
RIGHT: 'r'
|
||||||
};
|
};
|
||||||
|
css_classes = {
|
||||||
|
"@": "ball",
|
||||||
|
"H": "cube",
|
||||||
|
"#": "wall",
|
||||||
|
" ": "void",
|
||||||
|
"x": "gift"
|
||||||
|
};
|
||||||
options = {
|
options = {
|
||||||
starting_level: 0
|
starting_level: 0
|
||||||
};
|
};
|
||||||
|
@ -93,28 +100,9 @@ function format_level( state ) {
|
||||||
for ( i = 0 ; i < LEVEL_HEIGHT ; i++ ) {
|
for ( i = 0 ; i < LEVEL_HEIGHT ; i++ ) {
|
||||||
for ( j = 0 ; j < LEVEL_WIDTH ; j++ ) {
|
for ( j = 0 ; j < LEVEL_WIDTH ; j++ ) {
|
||||||
c = get_cell( state, j, i );
|
c = get_cell( state, j, i );
|
||||||
classes = "starcell";
|
classes = "starcell " + css_classes[ c ];
|
||||||
if ( state.moving == c) {
|
if ( state.moving == c) {
|
||||||
classes = classes + " selected";
|
classes = classes + "selected ";
|
||||||
}
|
|
||||||
switch( c ) {
|
|
||||||
case cell.BALL:
|
|
||||||
classes = classes + " ball";
|
|
||||||
break;
|
|
||||||
case cell.CUBE:
|
|
||||||
classes = classes + " cube";
|
|
||||||
break;
|
|
||||||
case cell.WALL:
|
|
||||||
classes = classes + " wall";
|
|
||||||
break;
|
|
||||||
case cell.VOID:
|
|
||||||
classes = classes + " void";
|
|
||||||
break;
|
|
||||||
case cell.GIFT:
|
|
||||||
classes = classes + " gift";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
dl = dl + "<span class=\"" + classes + "\">" + c + "</span>";
|
dl = dl + "<span class=\"" + classes + "\">" + c + "</span>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue