Skip to content

Commit

Permalink
Translations applied to the games
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilaSosa96 committed May 16, 2019
1 parent 3c56987 commit 623468f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
@@ -1,6 +1,6 @@
class LanguageSystem{
constructor(_language){
language = _language;
constructor(_language = undefined){
this.language = _language;
}

translate(text){
Expand All @@ -23,8 +23,8 @@
if(text === 'Player '){
return 'Jugador ';
}
if(text === 'won!'){
return 'ganó!';
if(text === ' won!'){
return ' ganó!';
}
if(text === 'Health: '){
return 'Vida: ';
Expand Down
6 changes: 3 additions & 3 deletions build/snake.js
Expand Up @@ -60,7 +60,7 @@ function loop() {
gameover();
}

ui.cursor.goto(0, 0).yellow().write('Score: ' + score);
ui.cursor.goto(0, 0).yellow().write(translator.translate('Score: ') + score);
ui.cursor.reset();

setTimeout(loop, FRAME);
Expand Down Expand Up @@ -161,15 +161,15 @@ function createPart() {
}

function gameover() {
var MSG = 'Game Over!';
var MSG = translator.translate('Game Over!');
ui.cursor.goto(ui.center.x - MSG.length / 2, ui.center.y);
ui.cursor.red();
ui.cursor.bold();
ui.write(MSG);

ui.cursor.reset();
ui.cursor.hex('#f65590');
var RETRY = 'Press any key to play again';
var RETRY = translator.translate('Press any key to play again');
ui.cursor.goto(ui.center.x - RETRY.length / 2, ui.center.y + 2);
ui.write(RETRY);

Expand Down
2 changes: 1 addition & 1 deletion build/spacecraft.js
Expand Up @@ -68,7 +68,7 @@ setInterval(function () {
if (enemy.killed < 3) enemy.killed++;
});

ui.cursor.goto(0, 0).yellow().write('Score: ' + score);
ui.cursor.goto(0, 0).yellow().write(translator.translate('Score: ') + score);
ui.cursor.reset();
}, FRAME);

Expand Down
14 changes: 7 additions & 7 deletions build/tanks.js
Expand Up @@ -33,7 +33,7 @@ function loop() {

if (one.dead || two.dead) {
var num = one.dead ? '2' : '1';
var msg = 'Player ' + num + ' won!';
var msg = translator.translate('Player ') + num + translator.translate(' won!');
ui.cursor.red();
ui.cursor.bold();

Expand Down Expand Up @@ -62,12 +62,12 @@ function loop() {

ui.cursor.goto(0, 1);
if (turn() === one) ui.cursor.hex('#54ffff');
ui.write('Player 1');
ui.write(translator.translate('Player ') + '1');
ui.cursor.reset();
ui.cursor.goto(0, 2);
ui.write('Health: ' + one.health);
ui.write(translator.translate('Health: ') + one.health);
ui.cursor.goto(0, 3);
ui.write('Angle: ' + parseInt(one.angle));
ui.write(translator.translate('Angle: ') + parseInt(one.angle));

two.draw();
two.bullets.forEach(function (bullet, i) {
Expand All @@ -87,12 +87,12 @@ function loop() {

ui.cursor.goto(ui.output.columns - 10, 1);
if (turn() === two) ui.cursor.hex('#54ffff');
ui.write('Player 2');
ui.write(translator.translate('Player ') + '2');
ui.cursor.reset();
ui.cursor.goto(ui.output.columns - 10, 2);
ui.write('Health: ' + two.health);
ui.write(translator.translate('Health: ') + two.health);
ui.cursor.goto(ui.output.columns - 10, 3);
ui.write('Angle: ' + parseInt(two.angle));
ui.write(translator.translate('Angle: ') + parseInt(two.angle));

setTimeout(loop, FRAME);
}
Expand Down
3 changes: 3 additions & 0 deletions index.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node
const LanguageSystem = require('./build/classes/languageSystem')

var game = process.argv[2];
var language = process.argv[3];
Expand All @@ -17,6 +18,8 @@ if (!game) {
return;
}

global.translator = new LanguageSystem(language);

require('babel-polyfill');

require(__dirname + '/build/' + game);

0 comments on commit 623468f

Please sign in to comment.