In this tutorial we'll write a GUI for the snake game, we've written earlier.
SDL is a cross-platform free-source library which allows you to draw to the screen (so make graphical programs), we'll make 2D games with it, but it can make 3D render as well, if you use it with OpenGL.
SDL tutorial:
http://www.lazyfoo.net/SDL_tutorials/index.php
Download && other things:
http://www.libsdl.org/
The ncurses version of the snake game (for Linux only, this is the original source, I started the work):
http://pastebin.com/p5NPZD5f
http://pastebin.com/AZzHSifV
http://pastebin.com/apdXFugL
Compile: g++ snake.cpp main.cpp -lncurses
The SDL version (this can be compiled almost any platform, included Linux, MacOS, Windows...):
http://pastebin.com/SJw08DHR
http://pastebin.com/BeqDAVFU
http://pastebin.com/ch9CPT10
If you download the SDL version VERY IMPORTANT to put a air.ttf (true type font) beside the runnable (binary file), else the program just collapse (RTE).
Compile:
On Windows the compile works the same way as I showed you in the SDL tutorial 0, in the project/properties-project settings-project's build option-linker settings you have to add -lSDL_ttf
Linux:
g++ snake.cpp main.cpp -lSDL -lSDL_ttf
@theobserver5000
You only need ncurses.h, if you want to compile the original (Linux version), download the SDL version, and it should work (you need the SDL, which you can download for any platform (tutorial 0))
thecplusplusguy 4 months ago
I need ncurses.h
theobserver5000 4 months ago
@TheSAguy
You can find the source code in the description (i've just uploaded it). The original version (so the ncurses version) not works on Windows (but it can be rewritten with dos.h). The graphical version is available as well (so the SDL version, which I wrote in this tutorial), it's cross platform, so you're able to run it on Windows without any modification, but don't forget to put the air.ttf file beside the runnable).
If you have any problem with the compile or run let me know.
thecplusplusguy 8 months ago
Please post the code for Snake, using windows.
Thx.
TheSAguy 8 months ago