My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SimpleExample  
Drawing a table of the code page 437 characters.
Updated Apr 29, 2009 by endgame....@gmail.com

This is about the simplest way to use libfake437. We draw every character in glorious white-on-black and wait for the user to hit escape.

#include <SDL.h>
#include "fake437.h"

int main(int argc, char *argv[]){
  SDL_Surface *screen;
  SDL_Event ev;
  int x;
  int y;
  int done = 0;
  SDL_Init(SDL_INIT_VIDEO);

  /* This makes the screen 80*25 characters. */
  screen = SDL_SetVideoMode(F437_DEFAULT_WIDTH_PX, F437_DEFAULT_HEIGHT_PX, 32, 0);
  for(y = 0 ; y < 16 ; y++)
    for(x = 0 ; x < 16 ; x++)
      f437_put_char(screen, x * F437_CHAR_WIDTH, y * F437_CHAR_HEIGHT,
                    y*16+x, F437_COLOR_BWHITE, F437_COLOR_BLACK);
  SDL_Flip(screen);
  while(!done)
    while(SDL_PollEvent(&ev))
      if((ev.type == SDL_KEYDOWN) &&
         (ev.key.keysym.sym == SDLK_ESCAPE)) done = 1;

  SDL_Quit();
  return 0;
}

Compile with

gcc -o test test.c `pkg-config --cflags --libs fake437`

or similar.


Sign in to add a comment
Powered by Google Project Hosting