Skip to content

Commit

Permalink
Added Chinese?
Browse files Browse the repository at this point in the history
  • Loading branch information
pippinbarr committed Mar 31, 2023
1 parent 9a09c6e commit 7633fe6
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 13 deletions.
128 changes: 128 additions & 0 deletions assets/json/cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"lang": "cn",
"title": "SNAKISMS",
"key": "SNAKISMS",
"menu": {
"homepage": "pippinbarr.com",
"instructions": {
"keyboard": [
"上/下=选择",
"回车=开始游戏"
],
"touch": [
"点击项目开始游戏"
]
}
},
"ui": {
"controls": {
"keyboard": [
"箭头键",
"CTRL键",
"贪吃蛇"
],
"touch": [
"滑动",
"CTRL键",
"贪吃蛇"
]
},
"reset": {
"keyboard": [
"R=重新开始 M=菜单"
],
"touch": {
"reset": [],
"menu": []
}
},
"gameover": "游戏结束",
"points": "得分"
},
"snakes": {
"Anthropomorphism": {
"title": "人性论",
"key": "Anthropomorphism"
},
"Apocalypticism": {
"title": "启示论",
"key": "Apocalypticism"
},
"Asceticism": {
"title": "禁欲主义",
"key": "Asceticism"
},
"Capitalism": {
"title": "资本主义",
"key": "Capitalism"
},
"Casualism": {
"title": "随性主义",
"key": "Casualism"
},
"Conservatism": {
"title": "保守主义",
"key": "Conservatism"
},
"Determinism": {
"title": "决定论",
"key": "Determinism"
},
"Dualism": {
"title": "二元论",
"key": "Dualism"
},
"Existentialism": {
"title": "存在主义",
"key": "Existentialism"
},
"Holism": {
"title": "整体主义",
"key": "Holism"
},
"Idealism": {
"title": "唯心主义",
"key": "Idealism"
},
"Monism": {
"title": "唯物主义",
"key": "Monism"
},
"Narcissism": {
"title": "自恋主义",
"key": "Narcissism"
},
"Nihilism": {
"title": "虚无主义",
"key": "Nihilism"
},
"Optimism": {
"title": "乐观主义",
"key": "Optimism"
},
"Pessimism": {
"title": "悲观主义",
"key": "Pessimism"
},
"Positivism": {
"title": "实证主义",
"key": "Positivism"
},
"Post-Apocalypticism": {
"title": "后启示录主义",
"key": "PostApocalypticism"
},
"Romanticism": {
"title": "浪漫主义",
"key": "Romanticism"
},
"Stoicism": {
"title": "斯多葛主义",
"key": "Stoicism"
},
"Utilitarianism": {
"title": "功利主义",
"key": "Utilitarianism"
}
}
}
1 change: 1 addition & 0 deletions assets/json/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"lang": "en",
"title": "SNAKISMS",
"key": "SNAKISMS",
"menu": {
Expand Down
127 changes: 127 additions & 0 deletions assets/json/snakisms-text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"title": "SNAKISMS",
"key": "SNAKISMS",
"menu": {
"homepage": "pippinbarr.com",
"instructions": {
"keyboard": [
"UP/DOWN=SELECT",
"ENTER=PLAY"
],
"touch": [
"TOUCH ITEM TO PLAY"
]
}
},
"ui": {
"controls": {
"keyboard": [
"ARROWS",
"CONTROL",
"SNAKE"
],
"touch": [
"SWIPES",
"CONTROL",
"SNAKE"
]
},
"reset": {
"keyboard": [
"R=RESTART M=MENU"
],
"touch": {
"reset": [],
"menu": []
}
},
"gameover": "GAME OVER",
"points": "POINTS"
},
"snakes": {
"Anthropomorphism": {
"title": "Anthropomorphism",
"key": "Anthropomorphism"
},
"Apocalypticism": {
"title": "Apocalypticism",
"key": "Apocalypticism"
},
"Asceticism": {
"title": "Asceticism",
"key": "Asceticism"
},
"Capitalism": {
"title": "Capitalism",
"key": "Capitalism"
},
"Casualism": {
"title": "Casualism",
"key": "Casualism"
},
"Conservatism": {
"title": "Conservatism",
"key": "Conservatism"
},
"Determinism": {
"title": "Determinism",
"key": "Determinism"
},
"Dualism": {
"title": "Dualism",
"key": "Dualism"
},
"Existentialism": {
"title": "Existentialism",
"key": "Existentialism"
},
"Holism": {
"title": "Holism",
"key": "Holism"
},
"Idealism": {
"title": "Idealism",
"key": "Idealism"
},
"Monism": {
"title": "Monism",
"key": "Monism"
},
"Narcissism": {
"title": "Narcissism",
"key": "Narcissism"
},
"Nihilism": {
"title": "Nihilism",
"key": "Nihilism"
},
"Optimism": {
"title": "Optimism",
"key": "Optimism"
},
"Pessimism": {
"title": "Pessimism",
"key": "Pessimism"
},
"Positivism": {
"title": "Positivism",
"key": "Positivism"
},
"Post-Apocalypticism": {
"title": "Post-Apocalypticism",
"key": "PostApocalypticism"
},
"Romanticism": {
"title": "Romanticism",
"key": "Romanticism"
},
"Stoicism": {
"title": "Stoicism",
"key": "Stoicism"
},
"Utilitarianism": {
"title": "Utilitarianism",
"key": "Utilitarianism"
}
}
}
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#000000">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@900&display=swap" rel="stylesheet">

<script src="js/libraries/phaser.min.js"></script>
<script src="js/libraries/swipe.js"></script>

Expand Down Expand Up @@ -36,6 +40,7 @@
<script src="js/snakes/Romanticism.js"></script>
<script src="js/snakes/Stoicism.js"></script>
<script src="js/snakes/Utilitarianism.js"></script>
<script src="js/Testing.js"></script>
</head>
<style>
body {
Expand Down Expand Up @@ -99,6 +104,10 @@
game.state.add('Stoicism', BasicGame.Stoicism);
game.state.add('Utilitarianism', BasicGame.Utilitarianism);



game.state.add('Testing', BasicGame.Testing);

// Now start the Boot state.
game.state.start('Boot');

Expand Down
14 changes: 11 additions & 3 deletions js/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ BasicGame.Menu.prototype.create = function () {
const keys = Object.keys(this.strings.snakes);
keys.sort();
games = [];
this.menuItems = [];
for (let i = 0; i < keys.length; i++) {
games.push(this.strings.snakes[keys[i]].title);
this.menuItems.push(this.strings.snakes[keys[i]]);
}
games.push("");
this.menuItems.push({});
games.push(this.strings.menu.homepage);
this.menuItems.push({
title: `pippinbarr.com`,
url: `this.strings.menu.homepage`
});

console.log(games);
this.menuButtons = this.game.add.group();
Expand Down Expand Up @@ -100,11 +107,11 @@ BasicGame.Menu.prototype.update = function () {
if (this.selected && !this.selectionComplete) {
this.checkMenuCollision();
if (this.snake[0].x > this.game.width) {
if (this.selected == "pippinbarr.com") {
if (this.selected.title == "pippinbarr.com") {
window.location = "http://www.pippinbarr.com/";
}
else {
this.game.state.start(this.strings.snakes[this.selected].key);
this.game.state.start(this.selected.key);
}
this.selectionComplete = true;
}
Expand Down Expand Up @@ -150,7 +157,8 @@ BasicGame.Menu.prototype.handleKeyboardInput = function () {

BasicGame.Menu.prototype.selectMenuItem = function () {
this.next = new Phaser.Point(this.GRID_SIZE, 0);
this.selected = games[this.snakeHead.y / this.GRID_SIZE - menuTop];
const selectedIndex = this.snakeHead.y / this.GRID_SIZE - menuTop;
this.selected = this.menuItems[selectedIndex];
this.appleSFX.play();
};

Expand Down
6 changes: 5 additions & 1 deletion js/Preloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ BasicGame.Preloader = function (game) {

};

let lang = `en`;
BasicGame.Preloader.prototype = {

preload: function () {
Expand All @@ -31,7 +32,10 @@ BasicGame.Preloader.prototype = {
this.load.audio('apple', ['assets/sounds/apple.mp3', 'assets/sounds/apple.ogg']);
this.load.audio('move', ['assets/sounds/move.mp3', 'assets/sounds/move.ogg']);

const lang = `en`;
console.log(window.location.search);
const params = new URLSearchParams(window.location.search);
console.log(params.get(`lang`))
const lang = params.get(`lang`) || `en`;
this.load.json('strings', `assets/json/${lang}.json`);
},

Expand Down
19 changes: 19 additions & 0 deletions js/Testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

BasicGame.Testing = function (game) {

};

BasicGame.Testing.prototype = {

init: function () {

},

create: function () {
this.add.text(100, 100, `浪漫主义`, {
fill: `yellow`,
fontSize: 64
});
}

};

0 comments on commit 7633fe6

Please sign in to comment.