Archived
1
0
Fork 0
This repository has been archived on 2019-12-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
cscape/maptest.c

46 lines
888 B
C
Raw Normal View History

2002-05-20 11:10:25 +00:00
/* $Revision$ */
2002-05-20 11:07:54 +00:00
#include <stdlib.h>
2002-05-20 12:40:35 +00:00
#include <unistd.h>
#include <SDL.h>
2002-05-20 11:07:54 +00:00
#include "sdl.h"
2002-05-20 12:40:35 +00:00
#include "map.h"
2002-05-20 11:07:54 +00:00
#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);
2002-05-20 16:07:37 +00:00
SDL_UpdateRect(screen, 0, 0, mapsize, mapsize);
2002-05-20 11:07:54 +00:00
}
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);
}