I've been thinking of doing a blog series on Game Development for a while now, though originally I wanted to do so on Tumblr. But quite frankly, every time I think of posting something on Tumblr, another part of me thinks it's just not worth the effort. 64Digits wins hands down, mostly because I find it easier to use. Faster too.
This is going to be an in-depth series, all about low level game development. Personally, I began at this level, using compilers such as Turbo Pascal and DJGPP, and thus working in a DOS environment.I wanted to write a series of tutorials that take you from the low level 'In video mode, what now?' up to some basic 3D software rendering. A lot of modern development kits and APIs create an abstraction layer around the primitive tools available to us. Allegro comes with ready-made line drawing functions… but how are lines drawn? Game Maker handles all sorts of collision detection for us, but what is the science behind it? You may ask as well, "And what is the point of learning this?". Answer: Because you never know when you'll have to test for an intersection between two arbitrary line segments and calculate the exact reflection vector for the intersection, use a raytrace to test for a collision or LOS, or create your own draw_line function. Because programming is like that: Stuff happens. Anyway, let us begin with part one….SDL, and getting it set upI had two options here; either use a library, or go back to DOS. And while getting a DOS window into mode 13h, and blitting your first sprite is very satisfying, it's also time consuming and constitutes knowledge that's nice to know, but won't be very useful in most cases… Unless we suffer through a Nuclear Armageddon that magically destroys all trace of the modern operating system leaving us with nothing but DOS 5. This is not going to happen.So I decided on SDL, for a few reasons: > It's readily available > It's easy to set up > It's cross-platform > It's about as low-level as you can go without descending into DOSI'm using Code::Blocks. It's free, cross-platform and stable. What more can you ask for?As for compiler, I'm currently running GCC 4.4.0 on Windows, and GCC 4.4.3 on Linux. We'll be focusing on the Windows setup. Most Linux users don't have a problem gettinglibraries and setting 'em up.First things first, get the latest SDL development package here.Unzip this somewhere. I put it in C:\Dev\SDL. Our next job is to set Code::Blocks up to use it, and to create a template project sowe don't have to do it again. I opt against using the built in SDL project template. Personal reasons, feel free to tryusing it, but no guarantees that it'll work.Creating a template project that uses SDLOpen Code::Blocks, and start a new Empty Project.Create a new source file, and call it main.cpp.Put the following into it:#include <cstdlib>
#include <cmath.h>
#include <SDL.h>
int main(int argc, char** argv)
{
if(SDL_Init(SDL_INIT_VIDEO) < 0)
return -1;
atexit(SDL_Quit);
bool keys[256];
for(int i = 0; i < 256; i++)keys[ i ] = false;
SDL_Surface* screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_DOUBLEBUF);
if(!screen)
return -2;
bool done = false;
while(!done)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
done = true;
break;
case SDL_KEYDOWN:
keys[event.key.keysym.sym] = true;
break;
case SDL_KEYUP:
keys[event.key.keysym.sym] = false;
break;
}
// Allows you to press Escape to exit
if(keys[SDLK_ESCAPE])done = true;
// All drawing takes place here ----------
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format,0,0,0));
// Put your code here
SDL_Delay(10);
SDL_Flip(screen);
// End drawing ----
}
}
return 0;
}
-lmingw32
-lSDLmain
-lSDL.dll
-luser32
-lgdi32
-lwinmm
-ldxguid
Someone should start compiling a list of all the useful programming/art/music tutorial blogs on 64digits. Someone…
Someone should add a facility to add Tutorials as a separate media type… We're all just too lazy…
I still vote for Stevenup's system of blog tags, eg. "a platformer game", "a silly story", "a programming tutorial", etc.
Then you can just filter the blog search and find everything in whatever category you want.eagly likes this.That would work too.