| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <SDL/SDL.h> |
| 9 |
#include <curses.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <time.h> |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
PDCEX SDL_Surface *pdc_screen; |
| 17 |
PDCEX int pdc_yoffset; |
| 18 |
|
| 19 |
int main(int argc, char **argv) |
| 20 |
{ |
| 21 |
char inp[60]; |
| 22 |
int i, j, seed; |
| 23 |
|
| 24 |
seed = time((time_t *)0); |
| 25 |
srand(seed); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
if (SDL_Init(SDL_INIT_VIDEO) < 0) |
| 30 |
exit(1); |
| 31 |
|
| 32 |
atexit(SDL_Quit); |
| 33 |
|
| 34 |
pdc_screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE|SDL_ANYFORMAT); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
pdc_yoffset = 416; |
| 39 |
|
| 40 |
initscr(); |
| 41 |
start_color(); |
| 42 |
scrollok(stdscr, TRUE); |
| 43 |
|
| 44 |
PDC_set_title("PDCurses for SDL"); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
for (i = 640, j = 416; j; i -= 2, j -= 2) |
| 49 |
{ |
| 50 |
SDL_Rect dest; |
| 51 |
|
| 52 |
dest.x = (640 - i) / 2; |
| 53 |
dest.y = (416 - j) / 2; |
| 54 |
dest.w = i; |
| 55 |
dest.h = j; |
| 56 |
|
| 57 |
SDL_FillRect(pdc_screen, &dest, |
| 58 |
SDL_MapRGB(pdc_screen->format, rand() % 256, |
| 59 |
rand() % 256, rand() % 256)); |
| 60 |
} |
| 61 |
|
| 62 |
SDL_UpdateRect(pdc_screen, 0, 0, 640, 416); |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
init_pair(1, COLOR_WHITE + 8, COLOR_BLUE); |
| 67 |
bkgd(COLOR_PAIR(1)); |
| 68 |
|
| 69 |
addstr("This is a demo of "); |
| 70 |
attron(A_UNDERLINE); |
| 71 |
addstr("PDCurses for SDL"); |
| 72 |
attroff(A_UNDERLINE); |
| 73 |
addstr(".\nYour comments here: "); |
| 74 |
getnstr(inp, 59); |
| 75 |
addstr("Press any key to exit."); |
| 76 |
|
| 77 |
getch(); |
| 78 |
endwin(); |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |