mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-27 09:58:44 +01:00
I reorganize and it's my joy
This commit is contained in:
parent
a9214894a1
commit
bcbfac8502
1 changed files with 38 additions and 37 deletions
|
@ -32,43 +32,6 @@ function initialize_a_star( dom_container, level_index ) {
|
||||||
"################# # ## x ##x x ## #x x ## ## x ## #x ## #x x# x ## ##x #@ H ################# " ]
|
"################# # ## x ##x x ## #x x ## ## x ## #x ## #x x# x ## ##x #@ H ################# " ]
|
||||||
};
|
};
|
||||||
|
|
||||||
// First of all, setup our little DOM branch
|
|
||||||
var starhtml = '<div class="gstar">';
|
|
||||||
starhtml += '<aside id="help">' + format_help( ) + '</aside>';
|
|
||||||
starhtml += '<canvas id="starboard" width="320" height="180"></canvas>';
|
|
||||||
starhtml += '<aside id="infos"></aside>';
|
|
||||||
starhtml += '</div>';
|
|
||||||
jQuery( dom_container ).html( starhtml );
|
|
||||||
|
|
||||||
// Now we can collect some informations about this DOM branch we have
|
|
||||||
var DOM_infos = {
|
|
||||||
container: dom_container,
|
|
||||||
canvas: {
|
|
||||||
//jQuery() returns a jquery object, [0] to get the canvas itself
|
|
||||||
context: jQuery( dom_container + " #starboard" )[ 0 ].getContext( '2d' ),
|
|
||||||
offset: jQuery( dom_container + " #starboard" ).offset(),
|
|
||||||
width: jQuery( dom_container + " #starboard" ).width(),
|
|
||||||
height: jQuery( dom_container + " #starboard" ).height()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var level_infos = {
|
|
||||||
height: 9,
|
|
||||||
width: 16,
|
|
||||||
cell: {
|
|
||||||
width: DOM_infos.canvas.width / 16,
|
|
||||||
height: DOM_infos.canvas.height / 9
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var state = {
|
|
||||||
moving: cell.BALL,
|
|
||||||
distance_travelled: 0,
|
|
||||||
level: 0,
|
|
||||||
board: "",
|
|
||||||
it_s_over: false
|
|
||||||
};
|
|
||||||
|
|
||||||
////// FUNCTIONS //////
|
////// FUNCTIONS //////
|
||||||
function load_sprites( theme ) {
|
function load_sprites( theme ) {
|
||||||
var sprites = { };
|
var sprites = { };
|
||||||
|
@ -324,6 +287,44 @@ function initialize_a_star( dom_container, level_index ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
////// MAIN (so to speak) //////
|
////// MAIN (so to speak) //////
|
||||||
|
|
||||||
|
// First of all, setup our little DOM branch
|
||||||
|
var starhtml = '<div class="gstar">';
|
||||||
|
starhtml += '<aside id="help">' + format_help( ) + '</aside>';
|
||||||
|
starhtml += '<canvas id="starboard" width="320" height="180"></canvas>';
|
||||||
|
starhtml += '<aside id="infos"></aside>';
|
||||||
|
starhtml += '</div>';
|
||||||
|
jQuery( dom_container ).html( starhtml );
|
||||||
|
|
||||||
|
// Now we can collect some informations about this DOM branch we have
|
||||||
|
var DOM_infos = {
|
||||||
|
container: dom_container,
|
||||||
|
canvas: {
|
||||||
|
//jQuery() returns a jquery object, [0] to get the canvas itself
|
||||||
|
context: jQuery( dom_container + " #starboard" )[ 0 ].getContext( '2d' ),
|
||||||
|
offset: jQuery( dom_container + " #starboard" ).offset(),
|
||||||
|
width: jQuery( dom_container + " #starboard" ).width(),
|
||||||
|
height: jQuery( dom_container + " #starboard" ).height()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var level_infos = {
|
||||||
|
height: 9,
|
||||||
|
width: 16,
|
||||||
|
cell: {
|
||||||
|
width: DOM_infos.canvas.width / 16,
|
||||||
|
height: DOM_infos.canvas.height / 9
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var state = {
|
||||||
|
moving: cell.BALL,
|
||||||
|
distance_travelled: 0,
|
||||||
|
level: 0,
|
||||||
|
board: "",
|
||||||
|
it_s_over: false
|
||||||
|
};
|
||||||
|
|
||||||
state = load_level( ( level_index === undefined ) ? 0 :
|
state = load_level( ( level_index === undefined ) ? 0 :
|
||||||
( level_index >= assets.levels.length ) ? assets.levels.length - 1 :
|
( level_index >= assets.levels.length ) ? assets.levels.length - 1 :
|
||||||
( level_index < 0 ) ? 0 : level_index
|
( level_index < 0 ) ? 0 : level_index
|
||||||
|
|
Loading…
Reference in a new issue