Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
make -C games/sudoku host test
make -C games/uttt host test
make -C games/sokoban host test
make -C games/twoplayer host test
make -C games/flappydunk host test
make -C games/towerblock host test
make -C games/suika host test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ NumPlay is licensed under the [GNU General Public License v3.0](LICENSE). Copyri
<td align="center"><img src="docs/media/gallery/leveldevil.gif" alt="Level Devil: platforms give way, a saw comes out of the floor, the ice slides the runner onto a spring, gravity flips past the saws"><br><a href="games/leveldevil/README.md"><b>Level Devil</b></a></td>
</tr>
<tr>
<td align="center"><img src="docs/media/gallery/twoplayer.gif" alt="2 Players: Pong, Air Hockey, Tanks and Light Cycles against the computer"><br><a href="games/twoplayer/README.md"><b>2 Players</b></a></td>
<td align="center"><img src="docs/media/gallery/twoplayer.gif" alt="2 Players: Pong, Air Hockey, Tanks, Light Cycles, Quick Draw and Tug of War against the computer"><br><a href="games/twoplayer/README.md"><b>2 Players</b></a></td>
<td align="center"><img src="docs/media/gallery/cookieclicker.gif" alt="Cookie Clicker: a golden cookie caught for a Frenzy, the store's upgrades, then an ascension: the cookie bursts and the heavens open"><br><a href="games/cookieclicker/README.md"><b>Cookie Clicker</b></a></td>
<td align="center"><img src="docs/media/gallery/invaders.gif" alt="Space Invaders: the rack marches down, the saucer is hit for 100"><br><a href="games/invaders/README.md"><b>Space Invaders</b></a></td>
</tr>
Expand Down
Binary file modified docs/media/gallery/twoplayer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/play.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,16 +816,16 @@ Google's brick breaker: seven bricks across in blue, red, yellow and green, wall

## 2 Players

<img src="../games/twoplayer/docs/games.png" width="320" align="right" alt="2 Players: Pong, Air Hockey, Tanks and Light Cycles">
<img src="../games/twoplayer/docs/games.png" width="320" align="right" alt="2 Players: its six games">

| Key | Player 1 | Player 2 |
| --- | --- | --- |
| **Move** (in Pong, up and down) | Arrows | **×** up, **Ans** down, **3** left, **−** right |
| **Fire** (Tanks) | **shift** | **EXE** |
| **Fire, draw, pull** | **OK** | **EXE** |

On the menu, **Up / Down** pick a game and **Left / Right** who player 2 is: a friend, or the computer (easy, normal, hard). Against the computer, **OK** and **EXE** fire too. **Back** pauses (Resume, Restart, Other games, Quit game).
On the menu, **Up / Down** pick a game and **Left / Right** who player 2 is: a friend, or the computer (easy, normal, hard). Against the computer, **EXE** works as OK too. **Back** pauses (Resume, Restart, Other games, Quit game).

Pong (first to 11), Air Hockey (first to 7), Tanks in a new maze every round and Light Cycles (first to 5 rounds). Before each game, a map of the keyboard lights up each player's keys. The matches each side wins are kept for every game.
Pong (first to 11), Air Hockey (first to 7), Tanks in a new maze every round, Light Cycles (first to 5 rounds), Quick Draw (draw first when the signal shows) and Tug of War (tap faster than the other side). Before each game, a map of the keyboard lights up each player's keys. The matches each side wins are kept for every game.

<br clear="right">

Expand Down
17 changes: 15 additions & 2 deletions games/twoplayer/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 2 Players — Pong, Air Hockey, Tanks, Light Cycles and Quick Draw, for two on one calculator.
# 2 Players: Pong, Air Hockey, Tanks, Light Cycles, Quick Draw and Tug of War, for two on one calculator.
# make build output/twoplayer.nwa
# make check link the app like the calculator does (output/twoplayer.bin)
# make test the tests on a computer (tests/play.c)
#
# In NumPlay the game draws with the launcher's strips, shapes and fonts and saves through its
# file functions (module.o leaves them to the launcher); on its own it brings them along.
Expand All @@ -21,7 +22,7 @@ LDFLAGS = -Wl,--relocatable -nostartfiles --specs=nano.specs
LDFLAGS += -Wl,-e,main -Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_level
LDFLAGS += -Wl,--gc-sections -flinker-output=nolto-rel

.PHONY: build check clean
.PHONY: build check clean host test
build: $(BUILD_DIR)/twoplayer.nwa

check: $(BUILD_DIR)/twoplayer.nwa
Expand All @@ -45,6 +46,18 @@ $(BUILD_DIR)/twoplayer.nwa: $(BUILD_DIR)/main.o $(BUILD_DIR)/gfx.o $(BUILD_DIR)/
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
$(Q) arm-none-eabi-strip --strip-unneeded $@

# on a computer, with the sanitizers: the rules, bots against bots, random sessions, old saves (tests/play.c)
HOST_FLAGS = -std=gnu11 -O1 -g -Wall -Wextra -Wno-unused-parameter -DPLATFORM_DEVICE=1 -DHOST -ffp-contract=off \
$(shell $(NWLINK) eadk-cflags-simulator) -fsanitize=address,undefined -fno-sanitize-recover=undefined
host: output/play
output/play: $(SRC) tests/play.c $(HEADERS)
$(Q) mkdir -p output
$(Q) cc $(HOST_FLAGS) tests/play.c ../../launcher/src/gfx.c ../../launcher/src/font_data.c \
../../launcher/src/xfont.c -lm -o $@
@echo "HOST $@"
test: output/play
output/play test

$(BUILD_DIR)/icon.o: src/icon.png | $(BUILD_DIR)
@echo "ICON $<"
$(Q) $(NWLINK) png-icon-o $< $@
Expand Down
20 changes: 12 additions & 8 deletions games/twoplayer/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
# 2 Players

Pong and three more games for two people on one calculator, side by side: player 1 on the arrows, player 2 on the keys around +, both at once. No one to play with? Player 2 can be the computer, easy, normal or hard.
Six games for two people on one calculator, side by side: player 1 on the arrows and OK, player 2 on the keys around + and EXE, both at once. No one to play with? Player 2 can be the computer, easy, normal or hard.

<img src="docs/games.png" width="480" alt="Pong, Air Hockey, Tanks and Light Cycles">
<img src="docs/games.png" width="720" alt="Pong, Air Hockey, Tanks, Light Cycles, Quick Draw and Tug of War">

- **Pong**, the 1972 arcade game: black and white, the dashed net and the blocky scores. The paddle has eight segments: the two in the middle send the ball back straight, the others at steeper and steeper angles. The ball speeds up as a rally goes on, and the first to 11 wins.
- **Air Hockey**: a mallet each, in your own half, and a puck that slides and bounces off the rails and the goal posts. Hit it while you move to send it flying. First to 7.
- **Tanks**: a new maze every round, shells that bounce off the walls (five each at a time) and can hit the tank that fired them. First to 5 rounds.
- **Light Cycles**: never stop, never turn back, and make the other cycle crash into a wall or a trail. Two turns can wait in line, and the cycles speed up as the round goes on. First to 5 rounds.
- **Quick Draw**: wait for DRAW!, then press your key before the other one. Press too soon and you lose the round. First to 5.
- **Tug of War**: tap your key as fast as you can to pull the flag past your line. The rope slides back a little, and after 30 seconds the one ahead takes the round. First to 5.
- **Before each game**, a map of the calculator's keyboard lights up each player's keys in their colour, with the rules.
- **The computer** plays every game: in Pong it works out where the ball will come and aims at the corners, in Air Hockey it gets behind the puck to shoot or guards its goal, its tank finds its way through the maze and plans shots off the walls, and its light cycle keeps the most room for itself and, on hard, cuts you off.
- **The computer** plays at a player's pace: it reacts after a moment, misjudges a little and moves slower than you, more so on easy. In Pong it works out where the ball will come, in Air Hockey it gets behind the puck to shoot or guards its goal, its tank finds its way through the maze and looks for a shot, and its light cycle keeps the most room for itself.
- **The matches won** by each side are kept for every game, against a friend and against the computer.

## Controls

| | Player 1 | Player 2 |
| --- | --- | --- |
| Move (in Pong, up and down) | Arrows | × up, Ans down, 3 left, − right |
| Fire (Tanks) | shift | EXE |
| Fire, draw, pull | OK | EXE |

| Key | Action |
| --- | --- |
| Up, Down, OK | Pick a game, then OK to play |
| Left, Right | Player 2, or the computer: easy, normal, hard |
| Back | Pause: Resume, Restart, Other games, Quit game |
| Home | Quit |
| Home | Save and quit |

Against the computer, OK and EXE fire too.
Against the computer, EXE works as OK too.

## Credits

**Pong** is Atari's arcade game (1972, by Allan Alcorn), whose paddles and ball this one follows. Air hockey, tanks duelling in a maze in the spirit of Tank Trouble, and the light cycles of the film Tron (1982) are classics of two-player games. Everything here is written in C for NumPlay and drawn from shapes as it goes, with no code or art from any of them.

Inside NumPlay it draws with the launcher's own shapes and fonts and saves through its file functions, so the four games take about 13 KB.
**Quick Draw** and **Tug of War** are by [Bobydeluxe](https://github.com/Bobydeluxe), in the spirit of the short duels of 12 MiniBattles and GoBattle 2, with no code or art from them. Bobydeluxe also put player 1's key on OK and made the computer fairer.

Inside NumPlay it draws with the launcher's own shapes and fonts and saves through its file functions, so the six games take about 15 KB.

It comes inside [NumPlay](https://github.com/Mason363/NumPlay), or on its own as `TwoPlayers.nwa` from the [latest release](https://github.com/Mason363/NumPlay/releases/latest).

Build: `make` (needs `arm-none-eabi-gcc` and Node.js for nwlink). `tools/bot.py` plays it against the computer in the emulator for these pictures.
Build: `make` (needs `arm-none-eabi-gcc` and Node.js for nwlink). `make test` plays every game on a computer, bots against bots. `tools/bot.py` plays it against the computer in the emulator.
Binary file modified games/twoplayer/docs/games.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions games/twoplayer/lang/fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,64 @@ Pong Pong
Air Hockey Air hockey
Tanks Tanks
Light Cycles Motos de lumière
Quick Draw Duel éclair
Tug of War Tir à la corde
Volleyball Volley
Sumo Sumo
Rocket Race Course de fusées
Archery Tir à l'arc
Dodgeball Balle aux prisonniers
Football Football
Meteor Run Pluie de météores
Fishing Pêche
Memory Duel Duel de mémoire
Return the ball with your paddle: its middle sends the ball back straight, its ends at a steep angle. The longer a rally lasts, the faster the ball. Renvoie la balle avec ta raquette : son milieu la renvoie tout droit, ses bouts en biais. Plus l'échange dure, plus la balle va vite.
Knock the puck into the other goal. Your mallet stays in your half; hit the puck on the move to send it flying. Envoie le palet dans l'autre but. Ton maillet reste dans ta moitié ; frappe le palet en bougeant pour qu'il file.
Drive through the maze and hit the other tank. Shells bounce off the walls: watch out for your own! Roule dans le labyrinthe et touche l'autre tank. Les obus rebondissent sur les murs : gare aux tiens !
Steer your light cycle and make the other one crash into a wall or a trail. It never stops and never turns back. Pilote ta moto de lumière et fais percuter l'autre contre un mur ou une traînée. Elle ne s'arrête et ne recule jamais.
Wait for DRAW!, then press your key: the first one wins. Too soon loses the round. Attends FEU !, puis appuie sur ta touche : le premier gagne. Trop tôt, tu perds la manche.
Tap your key fast to pull the rope. Pull the flag past your line. Appuie vite sur ta touche pour tirer la corde. Fais passer le drapeau derrière ta ligne.
Jump with up or your key. Hit the ball over the net and don't let it land on your side. Saute avec haut ou ta touche. Renvoie la balle par-dessus le filet sans la laisser tomber de ton côté.
Push the other one out of the ring. Your key dashes. The ring shrinks. Pousse l'autre hors du cercle. Ta touche fonce. Le cercle rétrécit.
Tap up or your key to fly through the gaps. Don't touch the walls or the edges. Appuie sur haut ou ta touche pour passer dans les trous. Ne touche ni les murs ni les bords.
Up and down aim. Hold your key to draw the bow, let go to shoot. Three hits win. Haut et bas visent. Maintiens ta touche pour bander l'arc, relâche pour tirer. Trois touches gagnent.
Your key throws at the other one. Dodge their balls. Three hits win. Ta touche lance sur l'autre. Évite ses balles. Trois touches gagnent.
Push the ball into the other goal. Near it, your key kicks it at the goal. Pousse le ballon dans l'autre but. Tout près, ta touche le tire vers le but.
Dodge the falling rocks. Both lanes get the same ones. Last one standing wins. Évite les rochers qui tombent : les mêmes dans les deux couloirs. Le dernier debout gagne.
Hold your key to lower the hook, let go to reel in. Land a fish first. Maintiens ta touche pour descendre l'hameçon, relâche pour remonter. Attrape un poisson le premier.
Watch the arrows, then repeat them. First to finish without a mistake wins. Regarde les flèches, puis refais-les. Le premier à finir sans erreur gagne.
Computer IA
Player 2 Joueur 2
You Toi
Player 1 Joueur 1
Back pause Retour pause
DRAW! FEU !
Wait... Attends...
Your turn! À toi !
Watch Regarde
Computer: easy IA : facile
Computer: normal IA : normale
Computer: hard IA : difficile
2 Players 2 joueurs
OK play Back quit OK jouer Retour quitter
arrows flèches
First to Premier à
Play Jouer
Back games Retour jeux
Draw! Égalité !
Resume Reprendre
Restart Recommencer
Other games Autres jeux
Quit game Quitter
Paused Pause
OK choose Back resume OK choisir Retour reprendre
Player 1 wins! Joueur 1 gagne !
Player 2 wins! Joueur 2 gagne !
You win! Gagné !
The computer wins L'IA gagne
Rematch Revanche
OK choose Back games OK choisir Retour jeux
No Non
Yes Oui
Quit game? Quitter ?
OK choose Back no OK choisir Retour non
33 changes: 33 additions & 0 deletions games/twoplayer/lang/zh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,64 @@ Pong 乒乓
Air Hockey 桌上冰球
Tanks 坦克大战
Light Cycles 光速摩托
Quick Draw 快枪对决
Tug of War 拔河
Volleyball 排球
Sumo 相扑
Rocket Race 火箭穿越
Archery 射箭
Dodgeball 躲避球
Football 足球
Meteor Run 流星雨
Fishing 钓鱼
Memory Duel 箭头对决
Return the ball with your paddle: its middle sends the ball back straight, its ends at a steep angle. The longer a rally lasts, the faster the ball. 用球拍把球打回去:拍子中间把球直直打回,两端打出斜角。来回越久,球越快。
Knock the puck into the other goal. Your mallet stays in your half; hit the puck on the move to send it flying. 把冰球打进对方球门。你的球槌只能在自己半场;边移动边击球,球就会飞出去。
Drive through the maze and hit the other tank. Shells bounce off the walls: watch out for your own! 在迷宫里开坦克,击中对方。炮弹会在墙上反弹:小心别打到自己!
Steer your light cycle and make the other one crash into a wall or a trail. It never stops and never turns back. 驾驶你的光速摩托,让对方撞上墙壁或光轨。摩托从不停下,也不能掉头。
Wait for DRAW!, then press your key: the first one wins. Too soon loses the round. 等到出现「拔枪!」再按你的键,先按的获胜。按太快就输了这一局。
Tap your key fast to pull the rope. Pull the flag past your line. 快速连按你的键,把旗子拉过你的线。
Jump with up or your key. Hit the ball over the net and don't let it land on your side. 用上或你的键跳起。把球打过网,别让它落在你这边。
Push the other one out of the ring. Your key dashes. The ring shrinks. 把对方推出场地。你的键是冲撞。场地会变小。
Tap up or your key to fly through the gaps. Don't touch the walls or the edges. 按上或你的键飞过缺口。别碰到墙或上下边缘。
Up and down aim. Hold your key to draw the bow, let go to shoot. Three hits win. 上下调整角度。按住你的键拉弓,松开射箭。命中三次获胜。
Your key throws at the other one. Dodge their balls. Three hits win. 你的键向对方投球。躲开对方的球。命中三次获胜。
Push the ball into the other goal. Near it, your key kicks it at the goal. 把球推进对方球门。靠近时,你的键把球踢向球门。
Dodge the falling rocks. Both lanes get the same ones. Last one standing wins. 躲开落下的石头。两边落下的石头相同。最后留下的获胜。
Hold your key to lower the hook, let go to reel in. Land a fish first. 按住你的键放下鱼钩,松开收线。先钓到鱼的获胜。
Watch the arrows, then repeat them. First to finish without a mistake wins. 看好箭头,再照着按一遍。先全部按对的获胜,按错就输。
Computer 电脑
Player 2 玩家 2
You 你
Player 1 玩家 1
Back pause 返回 暂停
DRAW! 拔枪!
Wait... 等待…
Your turn! 轮到你了!
Watch 看好
Computer: easy 电脑:简单
Computer: normal 电脑:普通
Computer: hard 电脑:困难
2 Players 双人对战
OK play Back quit OK 开始 返回 退出
arrows 方向键
First to 先得
Play 开始
Back games 返回 游戏
Draw! 平局!
Resume 继续
Restart 重新开始
Other games 其他游戏
Quit game 退出游戏
Paused 暂停
OK choose Back resume OK 选择 返回 继续
Player 1 wins! 玩家 1 获胜!
Player 2 wins! 玩家 2 获胜!
You win! 你赢了!
The computer wins 电脑获胜
Rematch 再来一局
OK choose Back games OK 选择 返回 游戏
No 否
Yes 是
Quit game? 退出游戏?
OK choose Back no OK 选择 返回 否
Loading
Loading