This project is part of the 🎮 SDL One-Night-Stand collection (unhappy name, I know, but that's my sense of humor).
This repository contains a bare-bones implementation of a Tic-Tac-Toe game, based on the SDL2 framework.
I started this one-night project (read the motivation if you're interested in the conditions 🤣) with the goal to implement a game without images or fonts. You know when you take a leap into the past and start to make text-based game that run on the command line? Well, this was the mood.
For this reason the game itself is really simplistic and, as said before, bare-bones.
Irrelevant information, skip this paragraph. I mean it.
As all the project in this collection, this has been developed on my Android tablet, with a rickety IDE, as an evening filler while watching TV from my bed. That's to say none of these projects ever claimed to be serious.
After finishing a couple of these projects, I started wondering what would mean porting them to a web version. War Plan:
- Move the sources to my PC
- Make a decent refactoring (finally I had a keyboard, I couldn't stand that ugly code any further)
- Widely comment, so the dumb future me will understand what the past me did
- Added Emscripten support
That's how this collection started, so look at this as something born to be trivial enough not to distract me too much from the TV.
You can clone the repository using you favourite git client or via cli:
git clone https://github.com/guareschiluca/sdl-tictactoe.git
cd sdl-tictactoeThis repository includes a Visual Studio solution file fully configured and ready to run, if you want to compile it for PC.
To build for PC just open the solution in Visual Studio and build! Debug and Release configuration differ by initialization and console output. Release configuration will build a windows application while Debug configuration will show up the console.
In general, the Debug configuration has a few tricks to ease debugging, while Release configuration is made to look good.
If you want to build the web version you will need a fully configured Emscripten environment (download), CMake (download) and Ninja (download).
With a fully configured environment, and all ports built, all you need to build for web is to run the build batch file.
REM Run a web assembly build
build-wasm.bat
REM Run a clean web assembly build (clears cache before building)
build-wasm.bat -c
REM or
build-wasm.bat --clean
REM Run a web assembly build and open output directory (can be combined with -c or --clean)
build-wasm.bat -o
REM or
build-wasm.bat --openOnce the build succeeded, a directory called public-html should contain the built files plus:
- a testing html page
- a testing server batch file (requires python).
If you run the testing server, you can test the build at http://localhost:8000/ (unless you edit the configuration).
The game is implemented based on:
- 3x3 Game Field
- Two Players
- AI with 3 Different Difficulties (drafted, actually)
The repository also contains:
- Web Assembly Building Script
- Sample Web Page to Test
- Python-based Testing Server
This project is for educational purposes and does not accept collaborators. However, feel free to fork the repository and make your own modifications.
Read the license file for more information: LICENSE.md
This repository is based on the following libraries:
- SDL2 - Simple DirectMedia Layer