Skip to content

Commit

Permalink
Merge pull request #11 from platacard/add-timer
Browse files Browse the repository at this point in the history
Add timer
  • Loading branch information
parabolabamse authored Oct 9, 2024
2 parents 131c6e2 + f95fe35 commit 3649fd9
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 60 deletions.
3 changes: 2 additions & 1 deletion js/CGameBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ CGameBase.prototype.update = function () {
this.raceTimer =
this.raceTimer ||
setInterval(() => {
this.raceTime += 10;
this._iGameState;
this.raceTime += this._iGameState === STATE_GAME_END ? 0 : 10;
this._oInterface.refreshRaceTime(this.raceTime);
}, 10);

Expand Down
2 changes: 1 addition & 1 deletion js/CLang.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var TEXT_LAP = "%s / %s";
var TEXT_SHARE_IMAGE = "200x200.jpg";
var TEXT_SHARE_TITLE = "¡Felicidades!";
var TEXT_SHARE_MSG1 = "Has recolectado <strong>";
var TEXT_YOUR_TIME = "Tu tiempo: ";
var TEXT_YOUR_TIME = "TU RESULTADO: ";
var TEXT_SHARE_MSG2 =
" puntos</strong>!<br><br>¡Comparte tu puntuación con tus amigos!";
var TEXT_SHARE_SHARE1 = "Mi puntuación es ";
Expand Down
106 changes: 61 additions & 45 deletions js/CLosePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,69 @@ function CLosePanel(iPlayerRank){
var _oParent;

var _pStartPanelPos;
this._init = function(){

setVolume(s_aSounds["game_soundtrack"], SOUNDTRACK_VOLUME_IN_GAME);

_oFade = new createjs.Shape();
_oFade.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);
_oFade.alpha = 0;
_oFade.on("mousedown",function(){});
s_oStage.addChild(_oFade);

new createjs.Tween.get(_oFade).to({alpha:0.7},500);

_oPanelContainer = new createjs.Container();
s_oStage.addChild(_oPanelContainer);

var oSprite = s_oSpriteLibrary.getSprite('msg_box');
var oPanel = createBitmap(oSprite);
oPanel.regX = oSprite.width/2;
oPanel.regY = oSprite.height/2;
_oPanelContainer.addChild(oPanel);

_oPanelContainer.x = CANVAS_WIDTH/2;
_oPanelContainer.y = CANVAS_HEIGHT + oSprite.height/2;
_pStartPanelPos = {x: _oPanelContainer.x, y: _oPanelContainer.y};
new createjs.Tween.get(_oPanelContainer).to({y:CANVAS_HEIGHT/2},500, createjs.Ease.quartIn);
this._init = function () {
setVolume(s_aSounds["game_soundtrack"], SOUNDTRACK_VOLUME_IN_GAME);

var oTitle = new CTLText(_oPanelContainer,
-300,-100, 600, 120,
60, "center", "#fff", PRIMARY_FONT, 1.2,
0, 0,
sprintf(TEXT_LOSE,ordinal(iPlayerRank),ordinal(MIN_RANK_FOR_WIN)),
true, true, true,
false );
oTitle.setStroke(10,"#000");


var oSprite = s_oSpriteLibrary.getSprite('but_exit');
_oExitBut = new CGfxButton(0, 100, oSprite,_oPanelContainer);
_oExitBut.addEventListener(ON_MOUSE_UP, this._onExit, this);

var oSprite = s_oSpriteLibrary.getSprite('but_restart');
_oRestartBut = new CGfxButton(-120, 100, oSprite,_oPanelContainer);
_oRestartBut.addEventListener(ON_MOUSE_UP, this._onRestart, this);
_oRestartBut.setVisible(false);

_oFade = new createjs.Shape();
_oFade.graphics
.beginFill("black")
.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
_oFade.alpha = 0;
_oFade.on("mousedown", function () {});
s_oStage.addChild(_oFade);

new createjs.Tween.get(_oFade).to({ alpha: 0.7 }, 500);

_oPanelContainer = new createjs.Container();
s_oStage.addChild(_oPanelContainer);

var oSprite = s_oSpriteLibrary.getSprite("msg_box");
var oPanel = createBitmap(oSprite);
oPanel.regX = oSprite.width / 2;
oPanel.regY = oSprite.height / 2;
_oPanelContainer.addChild(oPanel);

_oPanelContainer.x = CANVAS_WIDTH / 2;
_oPanelContainer.y = CANVAS_HEIGHT + oSprite.height / 2;
_pStartPanelPos = { x: _oPanelContainer.x, y: _oPanelContainer.y };
new createjs.Tween.get(_oPanelContainer).to(
{ y: CANVAS_HEIGHT / 2 },
500,
createjs.Ease.quartIn
);

var oTitle = new CTLText(
_oPanelContainer,
-300,
-100,
600,
120,
60,
"center",
"#fff",
PRIMARY_FONT,
1.2,
0,
0,
sprintf(TEXT_LOSE, ordinal(iPlayerRank), ordinal(MIN_RANK_FOR_WIN)),
true,
true,
true,
false
);
oTitle.setStroke(10, "#000");

var oSprite = s_oSpriteLibrary.getSprite("but_exit");
_oExitBut = new CGfxButton(0, 100, oSprite, _oPanelContainer);
_oExitBut.addEventListener(ON_MOUSE_UP, this._onExit, this);

var oSprite = s_oSpriteLibrary.getSprite("but_restart");
_oRestartBut = new CGfxButton(-120, 100, oSprite, _oPanelContainer);
_oRestartBut.addEventListener(ON_MOUSE_UP, this._onRestart, this);
_oRestartBut.setVisible(false);
};



this.unload = function(){
s_oStage.removeChild(_oPanelContainer);
_oFade.off("mousedown",function(){});
Expand Down
2 changes: 1 addition & 1 deletion js/CMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function CMain(oData) {
s_oSpriteLibrary.addSprite("gold_cup", "./sprites/gold_cup.png");
s_oSpriteLibrary.addSprite("silver_cup", "./sprites/silver_cup.png");
s_oSpriteLibrary.addSprite("bronze_cup", "./sprites/bronze_cup.png");
s_oSpriteLibrary.addSprite("soothing_cup", "./sprites/soothing_cup.png");
s_oSpriteLibrary.addSprite("soothing_cup", "./sprites/no_cup.png");

RESOURCE_TO_LOAD += s_oSpriteLibrary.getNumSprites();
s_oSpriteLibrary.loadSprites(5);
Expand Down
2 changes: 1 addition & 1 deletion js/CMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function CMenu() {
_oBg.y = CANVAS_HEIGHT / 2;
_oBg.regX = oSprite.width / 2;
_oBg.regY = oSprite.height / 2.15;
_oBg.scale = 1.7;
_oBg.scale = 1;
s_oStage.addChild(_oBg);

var oSprite = s_oSpriteLibrary.getSprite("logo_menu");
Expand Down
62 changes: 51 additions & 11 deletions js/CNextLevelPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,42 +96,42 @@ function CNextLevelPanel(iRank, iScore, iLevel, raceTime) {
var oScoreTextHeader = new CTLText(
oScoreContainer,
-100,
-50,
-30,
150,
50,
50,
"right",
30,
"left",
"#fff",
PRIMARY_FONT,
1,
0,
0,
"Tu tiempo:",
true,
true,
"TU RESULTADO:",
false,
true,
false,
false
);
oScoreTextHeader.setStroke(10, "#000");

var oScoreText = new CTLText(
oScoreContainer,
-100,
-20,
20,
150,
50,
50,
"right",
30,
"left",
"#fff",
PRIMARY_FONT,
1,
0,
0,
formatTimeCustomly(raceTime),
true,
true,
false,
true,
false,
false
);
oScoreText.setStroke(10, "#000");

Expand All @@ -150,9 +150,49 @@ function CNextLevelPanel(iRank, iScore, iLevel, raceTime) {
_oContinueBut.addEventListener(ON_MOUSE_UP, this._onContinue, this);
_oContinueBut.pulseAnimation();

new CTLText(
_oPanelContainer,
90,
190,
50,
50,
30,
"center",
"#fff",
PRIMARY_FONT,
1.2,
0,
0,
"Guardar",
false,
true,
true,
false
).setStroke(10, "#000");

var oSprite = s_oSpriteLibrary.getSprite("but_restart");
_oRestartBut = new CGfxButton(-120, 100, oSprite, _oPanelContainer);
_oRestartBut.addEventListener(ON_MOUSE_UP, this._onRestart, this);

new CTLText(
_oPanelContainer,
-150,
190,
50,
50,
30,
"center",
"#fff",
PRIMARY_FONT,
1.2,
0,
0,
"Reintentar",
false,
true,
true,
false
).setStroke(10, "#000");
};

this.unload = function () {
Expand Down
Binary file added sprites/no_cup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed sprites/soothing_cup.png
Binary file not shown.

0 comments on commit 3649fd9

Please sign in to comment.