@@ -111,7 +111,7 @@ mariobros.MainGame = function(lcdgame) {
111111 this . dropcase = [ ] ;
112112
113113 // initialise variable only once
114- for ( var c = 1 ; c < 11 ; c ++ ) {
114+ for ( var c = 0 ; c < 11 ; c ++ ) {
115115 this . holdcase [ c ] = false ;
116116 } ;
117117 // 2 stacks of 4 cases on the truck, for dropped animation
@@ -312,15 +312,23 @@ mariobros.MainGame.prototype = {
312312 if ( ( ! moveleft ) && ( [ 1 , 4 , 5 , 8 , 9 ] . indexOf ( c ) > - 1 ) ) { docheck = true } ;
313313
314314 if ( docheck ) {
315- // if case goes into middle of bottlemachine, temporary invisible
316- hold = this . lcdgame . sequenceShapeVisible ( ( "case" + c ) , - 1 ) ;
317- this . holdcase [ c ] = hold ;
315+
316+ if ( [ 2 , 4 , 6 , 8 , 10 ] . indexOf ( c ) > - 1 ) {
317+ // cases going into middle of bottlemachine, temporary invisible
318+ hold = this . lcdgame . sequenceShapeVisible ( ( "case" + c ) , - 1 ) ;
319+ this . holdcase [ c ] = hold ;
320+ // cases going up one level (grabbed by mario or luigi)
321+ hold = this . holdcase [ c - 1 ] ;
322+
323+ if ( hold ) this . lcdgame . sequenceSetPos ( ( "case" + c ) , 0 , false ) ; // make empty so hold in place for one tick
324+ } ;
318325
319326 // move all case on conveyor belt
320327 this . lcdgame . sequenceShift ( "case" + c ) ;
321328
322329 // previous
323330 var hold = this . holdcase [ c - 1 ] ;
331+ this . holdcase [ c - 1 ] = false ;
324332 if ( hold == true ) this . lcdgame . sequenceSetFirst ( ( "case" + ( c ) ) , true ) ;
325333
326334 // play belt move sound if any cases moving left (or right) so do not play sound for each and every case
@@ -370,9 +378,15 @@ mariobros.MainGame.prototype = {
370378 // };
371379 //};
372380 } ;
373-
374381 // refresh shapes
375382 this . lcdgame . shapesRefresh ( ) ;
383+
384+ //TESTING
385+ //var str = "";
386+ //for (var c = 0; c <= 11; c++) {
387+ // str = str + "holdcase["+c+"]" + this.holdcase[c] + "\n";
388+ //}
389+ //this.lcdgame.debugText(str, 10, 10);
376390 } ,
377391
378392 doCheckGrabCase : function ( ) {
@@ -396,6 +410,8 @@ mariobros.MainGame.prototype = {
396410 this . lcdgame . sequenceSetPos ( ( "case" + casemove ) , - 1 , false ) ;
397411 this . lcdgame . sequenceSetPos ( ( "case" + ( casemove + 1 ) ) , 0 , true ) ;
398412 this . scorePoints ( 1 ) ;
413+ // when moving up one place, case doesn't move immediately, hold for one tick
414+ this . holdcase [ casemove ] = true ;
399415
400416 // arms move animations
401417 this . lcdgame . sequenceSetPos ( "luigi_arms" , ( this . luigipos * 2 ) , false ) ;
@@ -436,6 +452,8 @@ mariobros.MainGame.prototype = {
436452 this . lcdgame . sequenceSetPos ( ( "case" + casemove ) , - 1 , false ) ;
437453 this . lcdgame . sequenceSetPos ( ( "case" + ( casemove + 1 ) ) , 0 , true ) ;
438454 this . scorePoints ( 1 ) ;
455+ // when moving up one place, case doesn't move immediately, hold for one tick
456+ this . holdcase [ casemove ] = true ;
439457
440458 // arms move animations
441459 this . lcdgame . sequenceSetPos ( "mario_arms" , ( this . mariopos * 2 ) , false ) ;
@@ -642,7 +660,7 @@ mariobros.MainGame.prototype = {
642660 this . lcdgame . gametype = ( btn == "gamea" ? 1 : 2 ) ; // 1=game a, 2=game b
643661 this . newGame ( ) ;
644662 } ;
645- } else { // if (this.gamestate == STATE_GAMEPLAY) {
663+ } else if ( this . gamestate == STATE_GAMEPLAY ) {
646664 // which button, up or down
647665 if ( btn == "luigi" ) {
648666 var update = false ;
0 commit comments