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.
41 lines
836 B
C
41 lines
836 B
C
#include <stdlib.h>
|
|
#include "SDL.h"
|
|
#include "sdl.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-1, mapsize-1);
|
|
}
|
|
|
|
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);
|
|
}
|