neingeist
/
cscape
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

46 lines
888 B
C

/* $Revision$ */
#include <stdlib.h>
#include <unistd.h>
#include <SDL.h>
#include "sdl.h"
#include "map.h"
#define MAPSIZE 256
void map_show(SDL_Surface *screen, char *map, int mapsize) {
int i,j;
/* Lock the screen for direct access to the pixels */
if(SDL_MUSTLOCK(screen))
if(SDL_LockSurface(screen) < 0) {
fprintf(stderr, "Can't lock screen: %s\n",
SDL_GetError());
return;
}
for(i=0;i<mapsize;i++)
for(j=0;j<mapsize;j++)
sdl_putpixel(screen, i, j, map[i*mapsize+j]);
if(SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);
SDL_UpdateRect(screen, 0, 0, mapsize, mapsize);
}
int main(void) {
char map[MAPSIZE*MAPSIZE];
SDL_Surface *screen;
map_init(map,MAPSIZE,MAPSIZE);
map_generate(map,0,0,MAPSIZE-1,MAPSIZE-1);
screen = sdl_init();
map_setpalette(screen);
map_show(screen, map, MAPSIZE);
sleep(30);
SDL_Quit(); exit(0);
}