Skip to content

Commit e0de821

Browse files
committed
Mariobos minor gameplay fix
Mariobos minor gameplay fix
1 parent ccb8cff commit e0de821

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

bin/lcdgame.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,24 @@ LCDGame.Game.prototype = {
12401240
//this.context2d.fillStyle = "#fff";
12411241
//this.context2d.fillText(index, this.gamedata.frames[index].xpos, this.gamedata.frames[index].ypos);
12421242
},
1243+
1244+
debugText: function(str, x, y) {
1245+
// set font
1246+
this.context2d.font = "bold 12px sans-serif";
1247+
1248+
var lineheight = 15;
1249+
var lines = str.split('\n');
1250+
1251+
for (var i = 0; i<lines.length; i++) {
1252+
// shadow text
1253+
this.context2d.fillStyle = "#000";
1254+
this.context2d.fillText(lines[i], x+2, y+2);
1255+
// white text
1256+
this.context2d.fillStyle = "#fff";
1257+
this.context2d.fillText(lines[i], x, y);
1258+
y = y + lineheight;
1259+
};
1260+
},
12431261

12441262
// -------------------------------------
12451263
// buttons input through keyboard

games/mariobros/js/mariobros.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)