Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Languages: Snake in French and Chinese

Mason Chen2c4ce8aa79f9
diff --git a/games/snake/Makefile b/games/snake/Makefile
index 24fc02db..1b063617 100644
--- a/games/snake/Makefile
+++ b/games/snake/Makefile
@@ -6,7 +6,7 @@ CC = arm-none-eabi-gcc
NWLINK ?= npx --yes -- [email protected]
BUILD_DIR = output
SRC = src/main.c
-HEADERS = ../common/epsilon_app.h ../common/epsilon_files.h
+HEADERS = ../common/epsilon_app.h ../common/epsilon_files.h ../common/np_text.h
CFLAGS = -std=c11 $(shell $(NWLINK) eadk-cflags-device)
CFLAGS += -Os -Wall -Wextra -Wno-unused-parameter -fno-math-errno -fsingle-precision-constant
diff --git a/games/snake/lang/fr.txt b/games/snake/lang/fr.txt
new file mode 100644
index 00000000..6d6f6d8d
--- /dev/null
+++ b/games/snake/lang/fr.txt
@@ -0,0 +1,62 @@
+# Snake in French: the English text as in the source, a tab, the translation (see tools/lang.py).
+Fruit Fruit
+Mode Mode
+Count Nombre
+Speed Vitesse
+Size Taille
+Color Couleur
+Theme Thème
+Apple Pomme
+Banana Banane
+Pineapple Ananas
+Grapes Raisin
+Strawberry Fraise
+Cherries Cerises
+Classic Classique
+Wall Mur
+Portal Portail
+Cheese Fromage
+Borderless Sans bords
+Twin Jumeaux
+Winged Ailé
+Yin Yang Yin Yang
+Statue Statue
+Light Lumière
+Magnet Aimant
+Peaceful Paisible
+# (a speed and a size: both feminine, "Vitesse : Normale", "Taille : Normale")
+Normal Normale
+Fast Rapide
+Slow Lente
+Small Petite
+Large Grande
+Blue Bleu
+Purple Violet
+Pink Rose
+Orange Orange
+Yellow Jaune
+Teal Turquoise
+White Blanc
+Black Noir
+Day Jour
+Night Nuit
+Snow Neige
+Volcano Volcan
+You win! Gagné !
+New best! Record !
+Play Jouer
+Settings Réglages
+Based on Tatone26's version D'après Tatone26
+# between a setting and its value
+: :
+# (the three buttons under the settings are narrow: 6 letters at most)
+Shuffle Hasard
+Reset Défaut
+Paused Pause
+Resume Reprendre
+Restart Recommencer
+Quit game Quitter
+# (the card is narrow)
+Quit game? Quitter ?
+No Non
+Yes Oui
diff --git a/games/snake/lang/zh.txt b/games/snake/lang/zh.txt
new file mode 100644
index 00000000..70be83e4
--- /dev/null
+++ b/games/snake/lang/zh.txt
@@ -0,0 +1,58 @@
+# Snake in Chinese: the English text as in the source, a tab, the translation (see tools/lang.py).
+Fruit 水果
+Mode 模式
+Count 数量
+Speed 速度
+Size 大小
+Color 颜色
+Theme 主题
+Apple 苹果
+Banana 香蕉
+Pineapple 菠萝
+Grapes 葡萄
+Strawberry 草莓
+Cherries 樱桃
+Classic 经典
+Wall 墙壁
+Portal 传送门
+Cheese 奶酪
+Borderless 无边界
+Twin 双蛇
+Winged 飞翼
+Yin Yang 阴阳
+Statue 雕像
+Light 灯光
+Magnet 磁铁
+Peaceful 和平
+Normal 普通
+Fast 快速
+Slow 慢速
+Small 小
+Large 大
+Blue 蓝色
+Purple 紫色
+Pink 粉色
+Orange 橙色
+Yellow 黄色
+Teal 青色
+White 白色
+Black 黑色
+Day 白天
+Night 夜晚
+Snow 雪地
+Volcano 火山
+You win! 你赢了!
+New best! 新纪录!
+Play 开始
+Settings 设置
+Based on Tatone26's version 基于 Tatone26 的版本
+: :
+Shuffle 随机
+Reset 重置
+Paused 暂停
+Resume 继续
+Restart 重新开始
+Quit game 退出游戏
+Quit game? 退出游戏?
+No 否
+Yes 是
diff --git a/games/snake/src/main.c b/games/snake/src/main.c
index c4a4f296..518fe628 100644
--- a/games/snake/src/main.c
+++ b/games/snake/src/main.c
@@ -14,6 +14,7 @@
#include <stdint.h>
#include "../../common/epsilon_app.h"
#include "../../common/epsilon_files.h"
+#include "../../common/np_text.h"
#ifdef __ELF__ /* app name and API level, for the calculator's installer */
const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Snake";
@@ -839,11 +840,7 @@ static void darkness(void) {
/* ------------------------------------------------------------------ text and panels */
static int pass, ty0, ty1; /* 0: shapes into buf; 1: the text whose last row is in ty0..ty1 */
-static int slen(const char *s) {
- int n = 0;
- while (s[n]) n++;
- return n;
-}
+static int slen(const char *s) { return np_text_cells(s); } /* (Chinese letters take two cells) */
static void lab(const char *s, int x, int y, int large, color fg, color bg) {
int b = y + (large ? 17 : 13);
if (pass && b >= ty0 && b < ty1) eadk_display_draw_string(s, (eadk_point_t){(uint16_t)x, (uint16_t)y}, large, fg, bg);
@@ -898,15 +895,16 @@ static void button(const char *s, int x, int y, int w, int h, bool on, int ic) {
clab(s, tx, y + (h - 18) / 2, 1, WHITE, c);
}
-static const char *const ROWS[NOPT] = {"Fruit", "Mode", "Count", "Speed", "Size", "Color", "Theme"};
+static const char *const ROWS[NOPT] = {T("Fruit"), T("Mode"), T("Count"), T("Speed"), T("Size"), T("Color"), T("Theme")};
static const char *const NAMES[] = {
- "Apple", "Banana", "Pineapple", "Grapes", "Strawberry", "Cherries",
- "Classic", "Wall", "Portal", "Cheese", "Borderless", "Twin", "Winged", "Yin Yang", "Statue", "Light", "Magnet", "Peaceful",
+ T("Apple"), T("Banana"), T("Pineapple"), T("Grapes"), T("Strawberry"), T("Cherries"),
+ T("Classic"), T("Wall"), T("Portal"), T("Cheese"), T("Borderless"), T("Twin"), T("Winged"), T("Yin Yang"), T("Statue"),
+ T("Light"), T("Magnet"), T("Peaceful"),
"1", "3", "5",
- "Normal", "Fast", "Slow",
- "Normal", "Small", "Large",
- "Blue", "Purple", "Pink", "Orange", "Yellow", "Teal", "White", "Black",
- "Day", "Night", "Snow", "Volcano",
+ T("Normal"), T("Fast"), T("Slow"),
+ T("Normal"), T("Small"), T("Large"),
+ T("Blue"), T("Purple"), T("Pink"), T("Orange"), T("Yellow"), T("Teal"), T("White"), T("Black"),
+ T("Day"), T("Night"), T("Snow"), T("Volcano"),
};
static const char *name_of(int o, int v) {
int b = 0;
@@ -939,12 +937,12 @@ static void title_card(void) {
clab(t, 124, Y + 40, 1, WHITE, C_CARD);
itoa(t, *best());
clab(t, 196, Y + 40, 1, WHITE, C_CARD);
- if (played && (won || newbest)) clab(won ? "You win!" : "New best!", 150, Y + 62, 0, RGB(0xFFF59D), C_CARD);
+ if (played && (won || newbest)) clab(won ? T("You win!") : T("New best!"), 150, Y + 62, 0, RGB(0xFFF59D), C_CARD);
}
/* the band on top, and the panel of the moment */
static void ui(void) {
- char t[24];
+ char t[NP_TEXT_EXTRA ? 48 : 24]; /* (a setting and its value: longer in other languages) */
if (!pass) fruit(V.opt[O_FRUIT], 14, 12, 20), trophy(84, 13, 0.95f, c_bar);
itoa(t, score);
lab(t, 28, 3, 1, WHITE, c_bar);
@@ -964,18 +962,18 @@ static void ui(void) {
case S_TITLE:
if (!pass) dim();
title_card();
- button("Play", 62, 160, 195, 26, sel == 0, 1);
- button("Settings", 62, 192, 195, 26, sel == 1, 2);
+ button(T("Play"), 62, 160, 195, 26, sel == 0, 1);
+ button(T("Settings"), 62, 192, 195, 26, sel == 1, 2);
if (!pass) box(62, 223, 195, 16, 8, mix(0, c_bar, 18));
- clab("Based on Tatone26's version", 160, 224, 0, RGB(0xC8D6BE), mix(0, c_bar, 18));
+ clab(T("Based on Tatone26's version"), 160, 224, 0, RGB(0xC8D6BE), mix(0, c_bar, 18));
break;
case S_SET: {
const int X = 24, Y = 28, W = 272;
if (!pass) dim();
card(X, Y, W, 172);
- cat(cat(cat(t, ROWS[row < NOPT ? row : 0]), ": "), name_of(row < NOPT ? row : 0, V.opt[row < NOPT ? row : 0]));
+ cat(cat(cat(t, ROWS[row < NOPT ? row : 0]), T(": ")), name_of(row < NOPT ? row : 0, V.opt[row < NOPT ? row : 0]));
if (row < NOPT) clab(t, 160, Y + 5, 1, WHITE, C_CARD);
- else clab("Settings", 160, Y + 5, 1, WHITE, C_CARD);
+ else clab(T("Settings"), 160, Y + 5, 1, WHITE, C_CARD);
if (!pass) {
blob(X + 14, Y + 14, X + 24, Y + 14, 1.3f, 1.3f, WHITE);
blob(X + 14, Y + 14, X + 19, Y + 9, 1.3f, 1.3f, WHITE), blob(X + 14, Y + 14, X + 19, Y + 19, 1.3f, 1.3f, WHITE);
@@ -992,24 +990,24 @@ static void ui(void) {
}
}
}
- static const char *const B[3] = {"Play", "Shuffle", "Reset"};
+ static const char *const B[3] = {T("Play"), T("Shuffle"), T("Reset")};
for (int i = 0; i < 3; i++) button(B[i], 24 + i * 94, 208, 84, 26, row == NOPT && sel == i, i ? i + 2 : 1);
break;
}
case S_PAUSE:
if (!pass) dim();
card(70, 44, 180, 164);
- clab("Paused", 160, 56, 1, WHITE, C_CARD);
- button("Resume", 86, 88, 148, 28, sel == 0, 1);
- button("Restart", 86, 124, 148, 28, sel == 1, 0);
- button("Quit game", 86, 160, 148, 28, sel == 2, 0);
+ clab(T("Paused"), 160, 56, 1, WHITE, C_CARD);
+ button(T("Resume"), 86, 88, 148, 28, sel == 0, 1);
+ button(T("Restart"), 86, 124, 148, 28, sel == 1, 0);
+ button(T("Quit game"), 86, 160, 148, 28, sel == 2, 0);
break;
case S_QUIT:
if (!pass) dim();
card(76, 72, 168, 104);
- clab("Quit game?", 160, 88, 1, WHITE, C_CARD);
- button("No", 92, 128, 60, 28, sel == 0, 0);
- button("Yes", 168, 128, 60, 28, sel == 1, 0);
+ clab(T("Quit game?"), 160, 88, 1, WHITE, C_CARD);
+ button(T("No"), 92, 128, 60, 28, sel == 0, 0);
+ button(T("Yes"), 168, 128, 60, 28, sel == 1, 0);
break;
}
}