aPong is a classic Pong game coded in x86 Assembly language, offering traditional gameplay and challenging levels.
Here are some key features of aPong:
- 2-player: The left player uses Q/A to move up/down, and the second player uses P/L. Press escape to quit.
- Uses SDL from assembly language: I love SDL, but I don't like x86. Since I already knew SDL, I chose to stick with it instead of learning something new. It was an excellent learning experience, and it allowed me to write the code quickly.
- Avoids the use of frame pointers: I find it unnecessary to use frame pointers if I'm not debugging the code. It's not complicated to keep track of the stack frame, and moving the stack pointer once at the start and end of a function is sufficient. All you need to do is take offsets from esp, as long as you remember the frame's size.
- Global variables are not bad: I feel that people tend to overlook the overhead involved in function calls. Saying that global variables are bad is incorrect. While it can be abused, it's like saying you shouldn't use C or UNIX because they don't hold your hand.
- The input system isn't great: I kept the code size small by using SDL_GetKeyState and SDL_PumpEvents. However, it causes the code to drop the keypress if the key is not down at the time of the PumpEvents call. If you want to see the proper way to do it, you can check the events system in STP.
Requirements:
- NASM
- GCC (for linking)
- libSDL (for graphics and input)
Compilation:
- nasm -f elf pong.o
- gcc -o pong pong.o -lSDL
Controls:
- Player one: Q (up), A (down)
- Player two: P (up), L (down)
- Press escape to quit.