← All the games

Pong

All of Pong is here, in Quantum's game language: pong.q, compiled for Godot 4.4.1, with no script besides. Point at a tag or an attribute to see what it does; a tag opens its entry in the language's reference.

Play in the browser
The 23 tags it uses, of the language's 145 qg:button qg:character qg:deflect qg:fullscreen qg:goto-scene qg:hud qg:input qg:instance qg:language qg:lobby qg:menu qg:multiplayer qg:on-collision qg:phrase qg:prefab qg:rebind qg:respawn qg:scene qg:sprite qg:spritesheet qg:text qg:touch-button qg:zone
pong.q113 lines Download On GitHub
<q:application id="pong" type="game">  <!-- Pong: Godot's own "Pong with GDScript" demo (godotengine/godot-demo-projects,       2d/pong, MIT), transcribed into the game language node for node and line       for line. README.md next to this file maps each piece of the original to       its tag, and lists what the language had to grow to say it. The sprites       are the demo's (assets/LICENSE.md). -->  <qg:spritesheet name="paddle" src="assets/paddle.png" tile="8x32" />  <qg:spritesheet name="ball" src="assets/ball.png" tile="8" />  <qg:spritesheet name="separator" src="assets/separator.png" tile="2x400" />  <!-- The left paddle is player 1 on W/S, the right one player 2 on the arrows —       on one keyboard. Over the network each machine is one player (the       title's Host and Join), and the game runs in lockstep, the same on       both (README.md). -->  <qg:input player="1" action="up" keys="W" />  <qg:input player="1" action="down" keys="S" />  <qg:input player="2" action="up" keys="Up" />  <qg:input player="2" action="down" keys="Down" />  <qg:multiplayer players="2" delay="3" start="court" />  <!-- The ball flies left at 100 px/s, 2 px/s faster every second; it bounces       off the ceiling and the floor, and goes back to its start, as it was,       when it passes a paddle. -->  <qg:prefab name="Ball" tag="ball" sheet="ball" hitbox="8x8" ai="fly" heading="left" speed="100" accel="2">    <qg:on-collision with="edge">      <qg:deflect target="me" axis="y" />    </qg:on-collision>    <qg:on-collision with="wall">      <qg:respawn target="me" />    </qg:on-collision>  </qg:prefab>  <!-- The title: two on one keyboard, or one on each machine — host, or join at       an address. The court starts on both machines once both are there. -->  <!-- the game in Portuguese and Spanish (a web page's ?lang=pt, the command line's q-lang, or the system's language) -->    <!-- on a phone: what the keys do, under a finger, in every scene -->  <qg:touch-button action="up" label="^" x="48" y="300" size="64" />  <qg:touch-button action="down" label="v" x="48" y="360" size="64" />  <qg:language lang="pt" name="Português">    <qg:phrase text="PONG" as="PONG" />    <qg:phrase text="Two players, one keyboard" as="Dois jogadores, um teclado" />      <qg:phrase text="OPTIONS" as="OPÇÕES" />    <qg:phrase text="Full screen" as="Tela cheia" />    <qg:phrase text="on" as="sim" />    <qg:phrase text="off" as="não" />    <qg:phrase text="Back" as="Voltar" />    <qg:phrase text="P1 up" as="J1 cima" />    <qg:phrase text="P2 up" as="J2 cima" />    <qg:phrase text="P1 down" as="J1 baixo" />    <qg:phrase text="P2 down" as="J2 baixo" /></qg:language>  <qg:language lang="es" name="Español">    <qg:phrase text="PONG" as="PONG" />    <qg:phrase text="Two players, one keyboard" as="Dos jugadores, un teclado" />      <qg:phrase text="OPTIONS" as="OPCIONES" />    <qg:phrase text="Full screen" as="Pantalla completa" />    <qg:phrase text="on" as="sí" />    <qg:phrase text="off" as="no" />    <qg:phrase text="Back" as="Volver" />    <qg:phrase text="P1 up" as="J1 arriba" />    <qg:phrase text="P2 up" as="J2 arriba" />    <qg:phrase text="P1 down" as="J1 abajo" />    <qg:phrase text="P2 down" as="J2 abajo" /></qg:language>  <qg:scene name="title" width="640" height="400" background="#24272a">    <qg:hud position="top-center" size="48"><qg:text value="{'PONG'}" /></qg:hud>    <qg:lobby local="court" local-label="Two players, one keyboard" size="20" options="options" />  </qg:scene>  <qg:scene name="court" width="640" height="400" background="#24272a" seed="1">    <qg:sprite sheet="separator" x="320" y="200" />    <!-- A paddle moves up and down at 100 px/s, kept on the screen; the ball         it touches leaves towards the other side, at a random slant. -->    <qg:character id="left" controller="ship" player="1" axis="vertical" speed="100"                  sheet="paddle" x="67.6285" y="192.594" hitbox="8x32" gd:modulate="#00ffff">      <qg:on-collision with="ball">        <qg:deflect target="other" dx="1" dy="{random(-1, 1)}" />      </qg:on-collision>    </qg:character>    <qg:character id="right" controller="ship" player="2" axis="vertical" speed="100"                  sheet="paddle" x="563.815" y="188.919" hitbox="8x32" gd:modulate="#ff00ff">      <qg:on-collision with="ball">        <qg:deflect target="other" dx="-1" dy="{random(-1, 1)}" />      </qg:on-collision>    </qg:character>    <qg:instance prefab="Ball" name="ball" x="320.5" y="191.124" />    <qg:zone name="ceiling" tag="edge" x="0" y="-20" width="640" height="20" />    <qg:zone name="floor" tag="edge" x="0" y="400" width="640" height="20" />    <qg:zone name="left-wall" tag="wall" x="-20" y="0" width="20" height="400" />    <qg:zone name="right-wall" tag="wall" x="640" y="0" width="20" height="400" />  </qg:scene>  <!-- ===== Options: how loud, the full screen, the keys; kept between runs ===== -->  <qg:scene name="options" width="640" height="400" background="#24272a">    <qg:hud position="top-center" size="36"><qg:text value="{tr('OPTIONS')}" /></qg:hud>    <qg:menu position="center" size="18" columns="2">      <qg:rebind label="P1 up" action="up" />      <qg:rebind label="P2 up" action="up" player="2" />      <qg:rebind label="P1 down" action="down" />      <qg:rebind label="P2 down" action="down" player="2" />      <qg:button label="{tr('Full screen') + ': ' + (tr('on') if fullscreen() else tr('off'))}"><qg:fullscreen /></qg:button>      <qg:button label="Back"><qg:goto-scene name="title" /></qg:button>    </qg:menu>  </qg:scene></q:application>