Quote:Original post by Hnefi
I don't see how DevFred's comment could have dissuaded you.
Too bad.
Thanks for the help repliers.
Quote:Original post by Hnefi
I don't see how DevFred's comment could have dissuaded you.
#include <stdio.h>#include "SDL/SDL.h"#include "SDL/SDL_ttf.h"/* Cleans up and exits */int shutdown(int status);int main(int argc, char *argv[]){ /* Variables */ SDL_Surface *screen; SDL_Event event; TTF_Font *font; int x_pos = 0, x_vel = 0, y_pos = 0, y_vel = 0; int playing = 1; /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) > 0) { fprintf(stderr, "SDL_Init: %s\n", SDL_GetError()); exit(1); } /* Set video mode */ screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE); if (screen == NULL) { fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError()); shutdown(1); } SDL_ShowCursor(SDL_DISABLE); /* Initialize SDL_TTF */ if (TTF_Init() == -1) { fprintf(stderr, "TTF_Init: %s\n", TTF_GetError()); shutdown(1); } /* Initialize the font */ font = TTF_OpenFont("data/Vera.ttf", 12); if (font == NULL) { fprintf(stderr, "TTF_OpenFont: %s\n", TTF_GetError()); shutdown(1); } SDL_Color colorFg = {0,0,255,0}; // Blue SDL_Surface *text = TTF_RenderText_Solid(font, "Print something please! :(", colorFg); SDL_Rect destRect = {0,0,0,0}; SDL_BlitSurface(text, NULL, screen, &destRect); /* The game loop */ while (playing) { // Check input while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYUP: switch (event.key.keysym.sym) { case SDLK_q: playing = 0; break; default: break; } default: break; } } x_pos += x_vel, y_pos += y_vel; /* Play ball! */ } SDL_FreeSurface(text); TTF_CloseFont(font); shutdown(0);}/* Cleans up and exits */int shutdown(int status){ if (TTF_WasInit()) TTF_Quit(); SDL_Quit(); exit(status);}