/** * Showfile screen * * Display the file selection to the user */ static void ShowFiles (int offset, int selection) { int i, j; char text[MAXPATHLEN]; int ypos; int w; setfontsize(18); clearscreen (); ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1; if (screenheight == 480) ypos += 24; else ypos += 10; j = 0; for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++) { if (filelist[i].flags) // if a dir { strcpy (text, "["); strcat (text, filelist[i].displayname); strcat (text, "]"); } else strcpy (text, filelist[i].displayname); if (j == (selection - offset)) { /*** Highlighted text entry ***/ for ( w = 0; w < 20; w++ ) DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 ); setfontcolour (0x00, 0x00, 0xe0); DrawText (-1, (j * 20) + ypos, text); setfontcolour (0x00, 0x00, 0x00); } else { /*** Normal entry ***/ DrawText (-1, (j * 20) + ypos, text); } j++; } showscreen (); }
short play() { short c; short ret; short undolock = 1; /* locked for undo */ showscreen(); tmpsave(); ret = 0; while( ret == 0) { switch( (c = getch())) { case 'q': /* quit the game */ ret = E_ENDGAME; break; case 's': /* save the games */ if( (ret = savegame()) == 0) ret = E_SAVED; break; case '?': /* show the help file */ showhelp(); showscreen(); break; case CNTL_R: /* refresh the screen */ clear(); showscreen(); break; case 'c': /* temporary save */ tmpsave(); break; case CNTL_U: /* reset to temporary save */ tmpreset(); undolock = 1; showscreen(); break; case 'U': /* undo this level */ moves = pushes = 0; if( (ret = readscreen()) == 0) { showscreen(); undolock = 1; } break; case 'u': /* undo last move */ if( ! undolock) { undomove(); undolock = 1; } break; case 'k': /* up */ case 'K': /* run up */ case CNTL_K: /* run up, stop before object */ case 'j': /* down */ case 'J': /* run down */ case CNTL_J: /* run down, stop before object */ case 'l': /* right */ case 'L': /* run right */ case CNTL_L: /* run right, stop before object */ case 'h': /* left */ case 'H': /* run left */ case CNTL_H: /* run left, stop before object */ do { if( (action = testmove( c)) != 0) { lastaction = action; lastppos.x = ppos.x; lastppos.y = ppos.y; lppc = map[ppos.x][ppos.y]; lasttpos1.x = tpos1.x; lasttpos1.y = tpos1.y; ltp1c = map[tpos1.x][tpos1.y]; lasttpos2.x = tpos2.x; lasttpos2.y = tpos2.y; ltp2c = map[tpos2.x][tpos2.y]; domove( lastaction); undolock = 0; } } while( (action != 0) && (! islower( c)) && (packets != savepack)); break; default: helpmessage(); break; } if( (ret == 0) && (packets == savepack)) { scorelevel = level; scoremoves = moves; scorepushes = pushes; break; } } return( ret); }
static void display(Screenflip *c, int wire) { int frozen; GLfloat rot = current_device_rotation(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(viewer[0], viewer[1], viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); /* glRotatef(rot, 0, 0, 1); if ((rot > 45 && rot < 135) || (rot < -45 && rot > -135)) { GLfloat s = c->winw / (GLfloat) c->winh; glScalef (s, 1/s, 1); } */ if (inposition(c)) { frozen = 0; glTranslatef(5 * sin(c->theta), 5 * sin(c->rho), 10 * cos(c->gamma) - 10); /* randomly change the speed */ if (!c->button_down_p && !(random() % 300)) { if (random() % 2) c->drho = 1/60 - (float)(random() % 100)/3000; if (random() % 2) c->dtheta = 1/60 - (float)(random() % 100)/3000; if (random() % 2) c->dgamma = 1/60 - (float)(random() % 100)/3000; } glRotatef(rot, 0, 0, 1); gltrackball_rotate (c->trackball); glRotatef(-rot, 0, 0, 1); if (rotate) glRotatef(c->rot, c->rx, c->ry, c->rz); /* update variables with each frame */ if(!c->button_down_p && !c->fadetime) { c->theta += c->dtheta; c->rho += c->drho; c->gamma += c->dgamma; c->rot += c->drot; c->drot += c->ddrot; } /* dont let our rotation speed get too high */ if (c->drot > 5 && c->ddrot > 0) c->ddrot = 0 - (GLfloat)(random() % 100) / 1000; else if (c->drot < -5 && c->ddrot < 0) c->ddrot = (GLfloat)(random() % 100) / 1000; } else { /* reset some paramaters */ c->ddrot = 0.05 - (GLfloat)(random() % 100) / 1000; c->theta = c->rho = c->gamma = 0; c->rot = 0; frozen = 1; } if (!c->button_down_p && !c->fadetime && (c->rot >= 360 || c->rot <= -360) && !(random() % 7)) { /* rotate change */ c->rx = (GLfloat)(random() % 100) / 100; c->ry = (GLfloat)(random() % 100) / 100; c->rz = (GLfloat)(random() % 100) / 100; } if (c->odrot * c->drot < 0 && c->tw < c->winw && !(random() % 10)) { c->fadetime = 1; /* randomly fade and get new snapshot */ } c->orot = c->rot; c->odrot = c->drot; if (c->rot > 360 || c->rot < -360) /* dont overflow rotation! */ c->rot -= c->rot; showscreen(c, frozen, wire); glPopMatrix(); glFlush(); }
int play() { short c; short ret; short testmove(); short undolock = 1; /* locked for undo */ #if ATARIST /* Mess up keyboard to make cursor keys work */ KEY_TABLES *kbt; KEY_TABLES old_kbt; int i; kbt = Keytbl(-1, -1, -1); old_kbt = *kbt; for (i = 0; i < 128; i++) { unshifted[i] = kbt->unshifted[i]; shifted[i] = kbt->shifted[i]; } unshifted[0x48] = 'k'; /* Up */ unshifted[0x50] = 'j'; /* Down */ unshifted[0x4b] = 'h'; /* Left */ unshifted[0x4d] = 'l'; /* Right */ unshifted[0x61] = 'u'; /* Undo */ unshifted[0x62] = '?'; /* Help */ shifted[0x48] = '\013'; /* Up ^K */ shifted[0x50] = '\012'; /* Down ^J */ shifted[0x4b] = '\010'; /* Left ^H */ shifted[0x4d] = '\014'; /* Right ^L */ shifted[0x61] = 'q'; /* Undo */ Keytbl(unshifted, shifted, -1); #endif showscreen(); tmpsave(); ret = 0; while( ret == 0) { switch( (c = get_char())) { case 'q': /* quit the game */ ret = E_ENDGAME; break; case 's': /* save the games */ if( (ret = savegame()) == 0) ret = E_SAVED; break; case '?': /* show the help file */ showhelp(); showscreen(); break; case CNTL_R: /* refresh the screen */ clear(); showscreen(); break; case 'c': /* temporary save */ tmpsave(); break; case CNTL_U: /* reset to temporary save */ tmpreset(); undolock = 1; showscreen(); break; case 'U': /* undo this level */ moves = pushes = 0; if( (ret = readscreen()) == 0) { showscreen(); undolock = 1; } break; case 'u': /* undo last move */ if(state_num > 0) { undomove(); undolock = 0; /*1*/ } break; case 'k': /* up */ case 'K': /* run up */ case CNTL_K: /* run up, stop before object */ case 'j': /* down */ case 'J': /* run down */ case CNTL_J: /* run down, stop before object */ case 'l': /* right */ case 'L': /* run right */ case CNTL_L: /* run right, stop before object */ case 'h': /* left */ case 'H': /* run left */ case CNTL_H: /* run left, stop before object */ do { if( (action = testmove( c)) != 0) { soko_state *s; s = &state[state_num]; s->action = action; s->ppos = ppos; s->lppc = map[ppos.x][ppos.y]; s->tpos1 = tpos1; s->ltp1c = map[tpos1.x][tpos1.y]; s->tpos2 = tpos2; s->ltp2c = map[tpos2.x][tpos2.y]; domove( s->action); undolock = 0; state_num++; } } while( (action != 0) && (! islower( c)) && (packets != savepack)); break; default: helpmessage(); break; } if( (ret == 0) && (packets == savepack)) { scorelevel = level; scoremoves = moves; scorepushes = pushes; break; } } #if ATARIST kbt = Keytbl(-1, -1, -1); kbt->unshifted = old_kbt.unshifted; kbt->shifted = old_kbt.shifted; /* Keytbl(old_kbt.unshifted, old_kbt.shifted, old_kbt.capslock);*/ #endif return ret; }
int main() { SDL_Surface *screen, *bitmap, *bug, *bitmapT; int running,i=0,step_ud=0,step_lr=90; unsigned int timer; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "SDL konnte nicht initialisiert werden: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode(600, 600, 0, 0); if (!screen) { fprintf(stderr, "Konnte Bildschirmmodus nicht setzen: %s\n", SDL_GetError()); exit(1); } bitmap = SDL_LoadBMP("map.bmp");//Hintergrund laden if (!bitmap) { fprintf(stderr, "Bitmap konnte nicht geladen werden: %s\n", SDL_GetError()); exit(1); } bitmapT = SDL_LoadBMP("bug2.bmp");//Hintergrund laden if (!bitmap) { fprintf(stderr, "Bitmap konnte nicht geladen werden: %s\n", SDL_GetError()); exit(1); } bug = SDL_LoadBMP("bug1.bmp"); if (!bug) { fprintf(stderr, "Bitmap konnte nicht geladen werden: %s\n", SDL_GetError()); exit(1); } bug = colorkeying(bug); //Datei: coller_keying.c showscreen(bitmap,screen,bitmapT); SDL_Flip( screen );//Screen updaten running = 1; while(running) { SDL_Event event; while(SDL_PollEvent(&event)) { if( event.type == SDL_KEYDOWN ){ switch(event.key.keysym.sym) { case SDLK_s: movement(screen, bitmap, bug, bitmapT);//ausgelagerte Funktion(fehlerhaft) break; case SDLK_k: running = 0; break; } } if(event.type == SDL_QUIT){ running = 0; break; } } } SDL_FreeSurface(bitmap); SDL_FreeSurface(bug); return 0; }