SDL tutorial 10 - snake game GUI (part 2) - example program 5

Published: 30 June 2011
on channel: thecplusplusguy
4,916
15

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/...
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


On this page of the site you can watch the video online SDL tutorial 10 - snake game GUI (part 2) - example program 5 with a duration of hours minute second in good quality, which was uploaded by the user thecplusplusguy 30 June 2011, share the link with friends and acquaintances, this video has already been watched 4,916 times on youtube and it was liked by 15 viewers. Enjoy your viewing!