mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-26 09:58:48 +01:00
refoctoring II more
This commit is contained in:
parent
92ca178370
commit
435498c074
1 changed files with 15 additions and 10 deletions
|
@ -7,6 +7,18 @@ function initialize_a_star( dom_container ) {
|
||||||
starhtml += '</div>';
|
starhtml += '</div>';
|
||||||
$( dom_container ).html( starhtml );
|
$( dom_container ).html( starhtml );
|
||||||
|
|
||||||
|
// Now we can collect some informations about this DOM branch we have
|
||||||
|
var DOM_infos = {
|
||||||
|
container: dom_container,
|
||||||
|
canvas: {
|
||||||
|
//$() returns a jquery object, [0] to get the canvas itself
|
||||||
|
context: $( dom_container + " #starboard" )[ 0 ].getContext( '2d' ),
|
||||||
|
offset: $( dom_container + " #starboard" ).offset(),
|
||||||
|
width: $( dom_container + " #starboard" ).width(),
|
||||||
|
height: $( dom_container + " #starboard" ).height()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var levels = [ "#################@## x#H## x #### ##x ## ## x #### x x x ## x x## x ## ##x x#################",
|
var levels = [ "#################@## x#H## x #### ##x ## ## x #### x x x ## x x## x ## ##x x#################",
|
||||||
" # # # # # ### x @# #x #x x # # x x # # # x # # #H# x # # # # #xx## # # # # ",
|
" # # # # # ### x @# #x #x x # # x x # # # x # # #H# x # # # # #xx## # # # # ",
|
||||||
"################# x#@## ## ##H## #x x ## x x## x## #x x x# x### ##x #x x x####x ##x #################",
|
"################# x#@## ## ##H## #x x ## x x## x## #x x x# x### ##x #x x x####x ##x #################",
|
||||||
|
@ -33,6 +45,7 @@ function initialize_a_star( dom_container ) {
|
||||||
"################# # ### ##x x ##x### #x x# #### xx x# ## ## #x x # ## ## ## @#H###xx################# ",
|
"################# # ### ##x x ##x### #x x# #### xx x# ## ## #x x # ## ## ## @#H###xx################# ",
|
||||||
"################# # ## x ##x x ## #x x ## ## x ## #x ## #x x# x ## ##x #@ H ################# " ];
|
"################# # ## x ##x x ## #x x ## ## x ## #x ## #x x# x ## ##x #@ H ################# " ];
|
||||||
|
|
||||||
|
// kinda enums
|
||||||
var cell= { WALL: '#', BALL: '@', CUBE: 'H', VOID: ' ', GIFT: 'x' };
|
var cell= { WALL: '#', BALL: '@', CUBE: 'H', VOID: ' ', GIFT: 'x' };
|
||||||
var direction = { UP: 'u', DOWN: 'd', LEFT: 'l', RIGHT: 'r' };
|
var direction = { UP: 'u', DOWN: 'd', LEFT: 'l', RIGHT: 'r' };
|
||||||
|
|
||||||
|
@ -44,16 +57,6 @@ function initialize_a_star( dom_container ) {
|
||||||
level : 0,
|
level : 0,
|
||||||
board : ""
|
board : ""
|
||||||
};
|
};
|
||||||
var DOM_infos = {
|
|
||||||
container: dom_container,
|
|
||||||
canvas: {
|
|
||||||
//$() returns a jquery object, [0] to get the canvas itself
|
|
||||||
context: $( dom_container + " #starboard" )[ 0 ].getContext( '2d' ),
|
|
||||||
offset: $( dom_container + " #starboard" ).offset(),
|
|
||||||
width: $( dom_container + " #starboard" ).width(),
|
|
||||||
height: $( dom_container + " #starboard" ).height()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var level_infos = {
|
var level_infos = {
|
||||||
height: 9,
|
height: 9,
|
||||||
width:16,
|
width:16,
|
||||||
|
@ -63,6 +66,7 @@ function initialize_a_star( dom_container ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////// FUNCTIONS //////
|
||||||
function count_gifts( ) {
|
function count_gifts( ) {
|
||||||
var n = 0;
|
var n = 0;
|
||||||
for ( var i = level_infos.height * level_infos.width ; i-- ; ) {
|
for ( var i = level_infos.height * level_infos.width ; i-- ; ) {
|
||||||
|
@ -341,6 +345,7 @@ function initialize_a_star( dom_container ) {
|
||||||
return sprites;
|
return sprites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// MAIN (so to speak) //////
|
||||||
state = load_level( levels, 0 );
|
state = load_level( levels, 0 );
|
||||||
|
|
||||||
start_loop( );
|
start_loop( );
|
||||||
|
|
Loading…
Reference in a new issue