mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-27 09:58:44 +01:00
uncouple switch_actor from its display part
This commit is contained in:
parent
56c25cdfb3
commit
6ae7f9fbbd
1 changed files with 5 additions and 0 deletions
|
@ -91,6 +91,9 @@ function initialize_a_star( dom_container, level_index ) {
|
||||||
|
|
||||||
function switch_actor( ) {
|
function switch_actor( ) {
|
||||||
state.moving = ( state.moving == cell.BALL ) ? cell.CUBE : cell.BALL;
|
state.moving = ( state.moving == cell.BALL ) ? cell.CUBE : cell.BALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function display_switch_actor( ) {
|
||||||
var ball_pos = get_pos( cell.BALL );
|
var ball_pos = get_pos( cell.BALL );
|
||||||
var cube_pos = get_pos( cell.CUBE );
|
var cube_pos = get_pos( cell.CUBE );
|
||||||
|
|
||||||
|
@ -232,6 +235,7 @@ function initialize_a_star( dom_container, level_index ) {
|
||||||
// We're inside the board
|
// We're inside the board
|
||||||
if ( click.x == notmovingpos[0] && click.y == notmovingpos[1] ) {
|
if ( click.x == notmovingpos[0] && click.y == notmovingpos[1] ) {
|
||||||
switch_actor( );
|
switch_actor( );
|
||||||
|
display_switch_actor( );
|
||||||
} else if ( click.x == movingpos[0] ) {
|
} else if ( click.x == movingpos[0] ) {
|
||||||
if ( click.y > movingpos[1] ) {
|
if ( click.y > movingpos[1] ) {
|
||||||
display_move_actor( make_a_move( direction.DOWN ) );
|
display_move_actor( make_a_move( direction.DOWN ) );
|
||||||
|
@ -256,6 +260,7 @@ function initialize_a_star( dom_container, level_index ) {
|
||||||
break;
|
break;
|
||||||
case 32: // SPACE
|
case 32: // SPACE
|
||||||
switch_actor( );
|
switch_actor( );
|
||||||
|
display_switch_actor( );
|
||||||
break;
|
break;
|
||||||
case 78: // n
|
case 78: // n
|
||||||
if ( state.level < assets.levels.length - 1 ) {
|
if ( state.level < assets.levels.length - 1 ) {
|
||||||
|
|
Loading…
Reference in a new issue