Example #1
0
File: KBD.C Project: kytulendu/TW
void waitkbd( int p_xcurpos, int p_ycurpos ) {
	register unsigned int i;

	setcurpos( p_xcurpos, p_ycurpos, thaimode );
	while ( !keypressed( ) ) {
		for ( i = 0; !keypressed( ) && i < 6000; i++ );
		setcurpos( p_xcurpos, p_ycurpos, thaimode );
		for ( i = 0; !keypressed( ) && i < 6000; i++ );
		setcurpos( p_xcurpos, p_ycurpos, thaimode );
	}
	setcurpos( p_xcurpos, p_ycurpos, thaimode );
}
Example #2
0
File: console.c Project: rj76/kq
/* \brief Enter console mode
*
* Run the console. Does not return until the console
* is closed.
*/
void run_console(void) {
	int c;
	int sl;
	int running;
	g_console.inputline[0]='\0';
	g_console.on = 1;
	/* Wait for all keys up */
	while(keypressed()) {
		readkey();
	}
	running = 1;
	while (running == 1) {
		sl = strlen(g_console.inputline);
		/* Get a key */
		while (!keypressed()) {
			check_animation ();
			blit2screen (xofs, yofs);
			poll_music ();
			kq_yield();
		}			
		switch((c = readkey()) & 0xff) {
			case '\r': /* Return */
				if (sl == 0) {
					/* Stop when blank line is entered */
					running = 0;
					g_console.on = 0;
				}
				else {
					g_console.on = 0;
					scroll_console(g_console.inputline);
					do_console_command(g_console.inputline);
					g_console.inputline[0] = '\0';
					g_console.on = 1;
				}
				break;
			case 127: /* backspace */
				if (strlen(g_console.inputline) > 0)
					g_console.inputline[sl - 1] = '\0';
				break;
			default:
				if (strlen(g_console.inputline) < sizeof(g_console.inputline) - 1) {
					g_console.inputline[sl] = c & 0xff;
					g_console.inputline[sl + 1] = '\0';
				}
				break;
		}
	}
	/* Wait for enter key up */
	do {
		readcontrols();
	} while (benter);
}
Example #3
0
File: KBD.C Project: kytulendu/TW
void waitkbd( int p_xcurpos, int p_ycurpos ) {
	register unsigned int i;

	setcurpos( p_xcurpos, p_ycurpos, thaimode );
	while ( !keypressed( ) ) {
		for ( i = 0; !keypressed( ) && i < 6000; i++ );
		setcurpos( p_xcurpos, p_ycurpos, thaimode );
		for ( i = 0; !keypressed( ) && i < 6000; i++ );
		setcurpos( p_xcurpos, p_ycurpos, thaimode );
		if ( !last_menu_on )
			dispstrhgc( ( ebioskey( 2 ) & 0x10 ) ? "ΚΓι�§µ�Γ�§" : "         ",
			70, 2, BOLDATTR );
	}
	setcurpos( p_xcurpos, p_ycurpos, thaimode );
}
Example #4
0
/* Main entry decoder */
tgaview()
{
   int i;
   int cs;
   unsigned int width;
   struct fractal_info info;

   if((fptarga = t16_open(readname, (int *)&width, (int *)&height, &cs, (U8 *)&info))==NULL)
      return(-1);

   rowcount = 0;
   for (i=0; i<(int)height; ++i)
   {
       t16_getline(fptarga, width, (U16 *)boxx);
       if ((*outln)((void *)boxx,width))
       {
          fclose(fptarga);
          fptarga = NULL;
          return(-1);
       }
       if (keypressed())
       {
          fclose(fptarga);
          fptarga = NULL;
          return(-1);
       }
   }
   fclose(fptarga);
   fptarga = NULL;
   return(0);
}
Example #5
0
/**
 * The main loop of the jukebox. Waits for the end of the song (while updating
 * the timer) and then returns an indicator that we need the next song.
 * Also waits for keypresses; the user can press ESC, left arrow or right arrow
 * to trigger appropriate return codes.
 */
int jukebox_loop() {
    int key_p;
    while (TRUE) {
        while (keypressed()) {
            key_p = readkey() >> 8;
            if (key_p == KEY_ESC) {
                return JUKEBOX_EXIT;
            }
            if (key_p == KEY_LEFT) {
                return JUKEBOX_PREV_SONG;
            }
            if (key_p == KEY_RIGHT) {
                return JUKEBOX_NEXT_SONG;
            }
        }
        clear_bitmap(buffer);
        update_starfield(buffer);
        update_track_data();
        update_song_data();
        draw_help();
        vsync();
        blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

        // When we're at the end of the file, midi_pos will be set to
        // the negative number of beats in the song.
        if (midi_pos < 0) {
            rest(TRACK_CHANGE_WAIT);
            return JUKEBOX_NEXT_SONG;
        }
    }
}
Example #6
0
int process_input()
{
    int done;
    done = 0;
    while(keypressed()){


        int keyval;

        keyval = readkey();

        if(key_value_to_keycode(keyval)==KEY_ESC){
            done = 1;
        }

        if(key_value_to_keycode(keyval) == KEY_UP){
            glb_ds1edit.win_preview.y0 -= glb_ds1.cur_scroll.keyb.y;
        }

        if(key_value_to_keycode(keyval)==KEY_DOWN){
            glb_ds1edit.win_preview.y0 += glb_ds1.cur_scroll.keyb.y;
        }

        if(key_value_to_keycode(keyval)==KEY_LEFT) {
            glb_ds1edit.win_preview.x0 -= glb_ds1.cur_scroll.keyb.x;
        }

        if(key_value_to_keycode(keyval)==KEY_RIGHT) {
            glb_ds1edit.win_preview.x0 += glb_ds1.cur_scroll.keyb.x;
        }

    }
    return done;
}
Example #7
0
void gui_enter()
{
        int x = 1;
        DIALOG_PLAYER *dp;       
        
        while (keypressed()) readkey();
        while (key[KEY_F11]) rest(100);

        gui_update();

        if (curtube != 3 && !mouse_amx) install_mouse();
        
        set_color_depth(dcol);
        show_mouse(screen);
        bemgui[0].x  = (windx / 2) - 36;
        bemgui[0].y  = windy - 8;
        bemgui[0].fg = makecol(255,255,255);
        dp=init_dialog(bemgui, 0);
        while (x && !key[KEY_F11] && !key[KEY_ESC])
        {
                x = update_dialog(dp);
        }
        shutdown_dialog(dp);
        show_mouse(NULL);
        set_color_depth(8);

        if (curtube != 3 && !mouse_amx) remove_mouse();
        
        while (key[KEY_F11]) rest(100);

        video_clearscreen();
}
Example #8
0
int WaitForFkeys(void)
{
  struct dostime_t start;
  struct dostime_t now;
  int secs = 3;
  int ch;

  _dos_gettime(&start);
  printf("%d", secs);
  while (secs)
  {
    _dos_gettime(&now);
    if (now.second != start.second)
    {
      _dos_gettime(&start);
      secs--;
      printf("\b%d", secs);
    }
    if (keypressed())
    {
      if ((ch = getch()) == 0)
        ch = getch() + 256;
      printf("\b ");
      return ch;
    }
  }
  printf("\b ");
  return 0;
}
Example #9
0
void disperror( char *p_string ) {
	clear_message( );                                       /* from printing.obj */
	dispstrhgc( p_string, 40 - ( strlen( p_string ) / 2 ), 13, REVERSEATTR );
	/* errorsound( ); */
	while ( !keypressed( ) );
	clear_message( );                                       /* from printing.obj */
}
Example #10
0
int main()
{
 BITMAP *bumpmap, *colormap, *dest, *dest2;

 init();
 generate_envmap();

 bumpmap = load_bitmap("bumpmap3.bmp", NULL);
 colormap = load_bitmap("colormap.bmp", NULL);
 dest = create_bitmap(bumpmap->w, bumpmap->h);
 dest2 = create_bitmap(bumpmap->w, bumpmap->h);

 while(!keypressed())
  {
   //do_bumpmapping(dest, bumpmap, colormap, mouse_x, mouse_y);
   do_parallax(dest2, bumpmap, colormap, mouse_x, mouse_y);
   blit(dest2, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  }

 destroy_bitmap(dest2);
 destroy_bitmap(dest);
 destroy_bitmap(colormap);
 destroy_bitmap(bumpmap);

 return 0;
}
Example #11
0
void Game :: entry ()
{
	
	std::list <Team *> :: iterator team_i;
	
	char key = 0;
	
	while (key != 27)
	{

		this->draw_screen_buffer();
		acquire_screen();
		blit(this->screen_buffer->get_bitmap(), screen, 0, 0, 0, 0, this->screen_buffer->get_width(), this->screen_buffer->get_height());
		release_screen();

		// team turns (run lua scripts)
		for (team_i = this->teams.begin(); team_i != this->teams.end(); team_i++)
			(*team_i)->turn();
	
		// move teams
		for (team_i = this->teams.begin(); team_i != this->teams.end(); team_i++)
			(*team_i)->process_action(TANK_ACTION_MOVE);
		
		// check for flag captures
		this->check_for_flag_captures();
		
		rest((unsigned int) 200);
		
		if (keypressed())
			key = (char) readkey();
		
	}
	
}
Example #12
0
File: datfli.c Project: ifilex/SRC
/* callback to quit out of the FLI player */
static int fli_stopper()
{
   if ((keypressed()) || (mouse_b))
      return 1;
   else
      return 0;
}
Example #13
0
void main(int argc,String *argv) {

  ArgParser a=ArgParser(argc,argv);
  String fname=a.argafter("-i","Font file (.jf)");
  float size=scrhei/2.0;
//  float size=scrhei/2.0*5;

  JBmp j=JBmp(scrwid,scrhei,0);
  j.setupfastsmooth(6);
  JFont font=JFont(fname);
//  String word="retro asymptotic cyberdruid";
  String word=Salphabet();
  int l=1;
  allegrosetup(scrwid,scrhei);
  makepalette(&greypalette);
  randomise();
  while (!keypressed()) {
//    String c=Smid(word,intrnd(1,Slen(word)),1);
    String c=Smid(word,l,1);
    if (myrnd()<0.07)
    font.writeString(Smid(word,intrnd(1,Slen(word)),1),&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255);
    if (myrnd()<0.07)
    font.centerString("retro",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255);
    if (myrnd()<0.07)
    font.centerString("asymptotic",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255);
    if (myrnd()<0.07)
    font.centerString("cyber druid",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255);
    j.fadeby(10);
    j.randomfastsmooth();
    j.writetoscreen();
    //l=(l%Slen(word))+1;
  }

}
Example #14
0
void do_example(int n, char *filenames[]) {
  OGGFILE **ogg = (OGGFILE **)malloc(sizeof(OGGFILE *) * n);
  int remain, i;

  remain = n;
  for (i = 0; i < n; i++) {
    putstr(filenames[i]);
    if ((ogg[i] = open_ogg_file(filenames[i])))
      play_ogg_file(ogg[i], BUFSZ, 255, 128);
    else {
      remain--;
      putstr("Error opening.");
    }
  }

  while ((!keypressed()) && (remain > 0)) {
    for (i = 0; i < n; i++) {
      if ((ogg[i]) && (poll_ogg_file(ogg[i]) != ALOGG_OK)) {
        close_ogg_file(ogg[i]);
        ogg[i] = NULL;
        remain--;
      }
    }
  }

  for (i = 0; i < n; i++)
    close_ogg_file(ogg[i]);

  free(ogg);
}
Example #15
0
// The default callback; requires Allegro's keyboard handler
static int default_callback(BITMAP *tempBuffer)
{
	if(keypressed())
		return 1;

	return 0;
}
void optionsScreen::update()
{
	poll_mouse();
	menu->update();

      while(keypressed())
      {
         int  newkey   = readkey();
         char ASCII    = newkey & 0xff;
         char scancode = newkey >> 8;
 
         // a character key was pressed; add it to the string
         if(ASCII >= 32 && ASCII <= 126)
         {
            // add the new char, inserting or replacing as need be
            if(insert || iter == edittext.end())
               iter = edittext.insert(iter, ASCII);
            else
               edittext.replace(caret, 1, 1, ASCII);
 
            // increment both the caret and the iterator
            caret++;
            iter++;
         }
         // some other, "special" key was pressed; handle it here
         else
            switch(scancode)
            {
               case KEY_DEL:
                  if(iter != edittext.end()) iter = edittext.erase(iter);
               break;
 
               case KEY_BACKSPACE:
                  if(iter != edittext.begin())
                  {
                     caret--;
                     iter--;
                     iter = edittext.erase(iter);
                  }
               break;
 
               case KEY_RIGHT:
                  if(iter != edittext.end())   caret++, iter++;
               break;
 
               case KEY_LEFT:
                  if(iter != edittext.begin()) caret--, iter--;
               break;
 
               case KEY_INSERT:
                  if(insert) insert = 0; else insert = 1;
               break;
 
               default:
 
               break;
            }
      }
}
Example #17
0
void fallingText()
{
      
     BITMAP *blackBackground = NULL;
     blackBackground = load_bitmap("Black Background.bmp", NULL); // Load our picture
     BITMAP *blackBuffer = NULL;
     blackBuffer = create_bitmap(1024,768); //Create an empty bitmap.
     BITMAP *text = NULL;
     text = load_bitmap("Falling Text.bmp", NULL); // Load our picture

     float textPositionY[40];
     float textPositionX[40];
     int i = 0;
     int j = 0;

     for (i = 0; i <= 39; i++)
     {
         textPositionX[i] = rand() %1000 - 500;
         textPositionY[i] = rand() %1000 - 500;
     }

     keypressed();

         while (j <= 2000 && !key[KEY_ESC])
         {
             j++;
             draw_sprite(blackBuffer, blackBackground, 0, 0);
             for (i = 0; i <= 39; i++)
             {
                  draw_sprite(blackBuffer, text, textPositionX[i], textPositionY[i]);
             }
             for (i = 0; i <= 39; i++)
             {
                 textPositionY[i] = textPositionY[i] + 0.01*(textPositionX[i]);
             }
            
             blit(blackBuffer, screen, 0,0,0,0,1024,768);
         }
         j = 0;
         while (j <= 2000 && !key[KEY_ESC])
         {
             j++;
             draw_sprite(blackBuffer, blackBackground, 0, 0);
             for (i = 0; i <= 19; i++)
             {
                  draw_sprite(blackBuffer, text, textPositionX[i], textPositionY[i]);
             }
             for (i = 0; i <= 19; i++)
             {
                 textPositionY[i] = textPositionY[i] - 0.01*(textPositionX[i]);
             }
            
             blit(blackBuffer, screen, 0,0,0,0,1024,768);
         }
        
     
     
 
}
Example #18
0
void MainBoard::mainboard_event() {
    int i;
    bool anykey = false;
//    qDebug() << "MainBoard: New event!";

    QByteArray data = _i2c_file->read(REG_MAX + 1);
    data = data.remove(0, 1);
#if 0
    qDebug() << "Dumping registers: ";
    for(i = 0; i < REG_MAX; i++) {
        qDebug("REG %d: 0x%X", i, data.at(i));
    }
#endif

    /* Obsługa zasilania */
    if ((data[REG_POWER_STATE] & (REG_POWER_IGNITION | REG_POWER_RADIO)) == 0) { /* Radio i zapłon wyłączone */
        if (!_shutdown_timer->isActive()) {
            //qDebug() << "MainBoard: starting shutdown timer";
            _shutdown_timeout = 600; /* 10 minut */
            _shutdown_timer->start();
        }
    }
    else {
        if (_shutdown_timer->isActive()) {
            //qDebug() << "MainBoard: shutdown canceled";
            _shutdown_timer->stop();
        }
    }

    /* Temperatura */
    _calculate_temp((data[REG_TEMP_HIGH] << 7) | (data[REG_TEMP_LOW] & 0x7F));

    /* Klawisze pilota */
    for(i = 0; i < 8; i++) {
        if (data.at(REG_KEY_0 + i) > 0) { /* Klawisz wciśnięty */
            //qDebug("MainBoard: key %x pressed", data.at(REG_KEY_0 + i));
            anykey = true;
            emit keypressed(data.at(REG_KEY_0 + i));
        }
    }

    if (!anykey) {
        emit keypressed(0);
    }
}
Example #19
0
/* let the user input a list of path nodes */
void input_nodes(void)
{
   clear_to_color(screen, makecol(255, 255, 255));

   textout_centre_ex(screen, font, "Click the left mouse button to add path "
		     "nodes", SCREEN_W/2, 8, palette_color[255],
		     palette_color[0]);
   textout_centre_ex(screen, font, "Right mouse button or any key to finish",
		     SCREEN_W/2, 24, palette_color[255], palette_color[0]);

   node_count = 1;

   show_mouse(screen);

   do {
      poll_mouse();
   } while (mouse_b);

   clear_keybuf();

   for (;;) {
      poll_mouse();

      if (mouse_b & 1) {
	 if (node_count < MAX_NODES-1) {
	    nodes[node_count].x = mouse_x;
	    nodes[node_count].y = mouse_y;

	    show_mouse(NULL);
	    draw_node(node_count);
	    show_mouse(screen);

	    node_count++;
	 }

	 do {
	    poll_mouse();
	 } while (mouse_b & 1);
      }

      if ((mouse_b & 2) || (keypressed())) {
	 if (node_count < 3)
	    alert("You must enter at least two nodes",
		  NULL, NULL, "OK", NULL, 13, 0);
	 else
	    break;
      }
   }

   show_mouse(NULL);

   do {
      poll_mouse();
   } while (mouse_b);

   clear_keybuf();
}
Example #20
0
int main()
{
 int exit = 0;
 int snum;
 LINE_LOOP *map = load_map("map.txt", &snum, 0.2);

 init();
 
 float cam_x = 0.0, cam_y = 2.0, cam_z = 30.0, cam_ax = 0.0, cam_ay = 0.0;

 printf("%d %d", sizeof(float), sizeof(float *));

 while(!exit)
  {
   VECTOR cam_dir = vector(SPEED * cos(M_PI * 0.5 - cam_ay * M_PI / 180.0), SPEED * sin(cam_ay * M_PI / 180.0 - M_PI * 0.5));

   int mx, my;
   get_mouse_mickeys(&mx, &my);
   //position_mouse(240, 320);
   
   cam_ay += mx * 0.03;
   cam_ax -= my * 0.03;
   if(cam_ax > 60) cam_ax = 60;
   if(cam_ax < -40) cam_ax = -40;
 
   if(keypressed())
    {
     if(key[KEY_ESC]) { exit = 1; }
     if(key[KEY_W]) { cam_x += cam_dir.x*10.0; cam_z += cam_dir.y*10.0; }
     if(key[KEY_S]) { cam_x -= cam_dir.x*10.0; cam_z -= cam_dir.y*10.0; }
     if(key[KEY_A]) { cam_x += cam_dir.y*10.0; cam_z += -cam_dir.x*10.0; }
     if(key[KEY_D]) { cam_x -= cam_dir.y*10.0; cam_z -= -cam_dir.x*10.0; }
     
     if(key[KEY_LEFT]) { cam_ay -= 0.09; }
     if(key[KEY_RIGHT]) { cam_ay += 0.09; }
     if(key[KEY_PGDN]) { cam_ax -= 0.09; }
     if(key[KEY_PGUP]) { cam_ax += 0.09; }
    }

   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   transform(-cam_x, -cam_y, -cam_z, -cam_ax, cam_ay, 0.0);
   glBegin(GL_QUADS);

    glColor3ub(128, 128, 128); glVertex3f(-300.0, 0.0, 300.0);
     glVertex3f(300.0, 0.0, 300.0);
     glVertex3f(300.0, 0.0, -300.0);
     glVertex3f(-300.0, 0.0, -300.0);
   
   draw_map_3d(map, snum);
   glEnd();
   allegro_gl_flip();
  }

 free_map(map, snum);
 readkey();
 return 0;
}
Example #21
0
/* callback to quit out of the FLI player */
static int fli_stopper(void)
{
   poll_mouse();

   if ((keypressed()) || (mouse_b))
      return 1;
   else
      return 0;
}
Example #22
0
/*
There was going to be a nice fadeout effect using the allegro fade_out and
fade_in functions, but for some reason these screwed up the palette. Oh well.
*/
void end_game(int fade_speed)
{

// fade_out(fade_speed);


 rest(1000 / fade_speed);
 clear_keybuf();

 clear_bitmap(screen);
// set_palette(palet);
 init_palette();
 set_palette(palet);

 int challenge_winner = 0;

 if (arena[0].teams == 0)
  challenge_winner = score_table();
   else
    challenge_winner = score_table_team();

 if (arena[0].challenge_level != 0)
 {
  if (challenge_winner == 0)
  {
   switch(arena[0].challenge_level)
   {
    case 1: information_box("", "Norbert won?", "Hmm.", 0); break;
    case 2: information_box("", "Looks like you need some more practice.", "", 0); break;
    case 3: information_box("", "Sorry, you lose.", "", 0); break;
    case 4: information_box("", "Good, but not great.", "", 0); break;
    case 5: information_box("", "Oh well, better luck next time.", "", 0); break;
    case 6: information_box("", "Almost there. Try again.", "", 0); break;
    case 7: information_box("", "Very good, but not quite good enough.", "", 0); break;
   }
   end_challenge();
  }
 }

 if (arena[0].qstart != QSTART_NONE)
  end_qstart();

    //shutdown_network();

// fade_in(*palet, fade_speed);
// set_palette(*palet);
 do
 {

 } while (keypressed() == 0);

 clear_keybuf();

 //net_init();

}
Example #23
0
void main(int argc,String *argv) {
  
  ArgParser a=ArgParser(argc,argv);
  bool writingframes=a.argexists("-wf","write frames");
  int tol=a.intafter("-t","colour tolerance",8);
  int res=a.intafter("-r","resolution",5);
  a.done();
  
  allegrosetup(scrwid,scrhei);
  makepalette(&greypalette);
  PPsetup(scrwid,scrhei,2.0);
  
  JBmp img=JBmp(scrwid,scrhei);
  
  randomise();
  for (int i=1;i<=5;i++) {
    // int j=intrnd(1,2);
    if (odd(i))
      es.add(new Radial());
    else
      es.add(new Stripey());
    // es.num(es.len)->amp=floatrnd(0,1);
    es.num(es.len)->amp=1;
  }
  
  for (int i=1;i<=es.len;i++)
  for (int j=1;j<=200;j++)
  es.num(i)->evolve();
  
  int frame=0;
  
  while (!keypressed()) {
    
    frame++;
    
    // Make new image
    
    quadify(&img,&effectat,tol,res,20);
    
    // Show new image
    img.writetoscreen();
    
    // Evolve drivers
    for (int i=1;i<=es.len;i++)
    for (int j=1;j<=5;j++) {
      Effect2d *e=es.num(i);
      e->evolve();
      // e->pos=e->cen+V2d::rotate(e->off,e->rotvel*(float)frame);
    }
    
    if (writingframes)
      img.writeframe();
    
  }
  
}
Example #24
0
static int delay(unsigned int len) {
  unsigned int mainstart;

  mainstart = SDL_GetTicks();
  do {
    SDL_Delay(1);
    if (keypressed()) return 1;
  } while (SDL_GetTicks() - mainstart < len);
  return 0;
}
Example #25
0
int main() 
{	
	allegro_init();
	install_keyboard();
	
	set_color_depth(32);
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, width, height, 0, 0);
	
		bialy=makecol(200,200,200);
	czarny=makecol(0,0,0);//ustawienie kodow kolorow
	
	BITMAP *buffer = create_bitmap(width, height);
	clear_to_color(buffer, bialy);
	
	x=width/2;
	y=height/2;//ustawienie mrowki w centrum
	direction=0;//mrowka zwrocona poczatkowo w gore
	
            while (!keypressed()) {             
                  
                  if(getpixel(buffer,x,y)==bialy)//jesli mrowka znajduje sie na polu bialym
                  {
                  //allegro_message("BIALY"); 
                  direction = (direction+3)%4;//obrot w lewo
                  rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,czarny);//zamalowanie pola na czarno                                          
                  }
                  else{
                  direction = (direction+5)%4;//obrot w prawo
                  rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,bialy);//zamalowanie pola na bialo
                  }
                  
                   x += a*moves[direction][0];
                  y += a*moves[direction][1];//przesuniecie mrowki w zadanym kierunku
                  
                  strcpy(napis,"X: ");
                  strcat(napis,itoa(x,str,10));
                  strcat(napis," Y: ");
                  strcat(napis,itoa(y,str,10));
                  strcat(napis," D: ");
                  strcat(napis,itoa(direction,str,10));
                   textout_centre_ex(buffer, font, napis,
                        SCREEN_W / 2, 0,
                        makecol(255, 0, 0), makecol(0, 0, 0));
                  
                  if(x<0.5*a || y<0.5*a || x>width-0.5*a || y>height-0.5*a)break;
                  //ochrona przed wyjsciem mrowki poza ramy ekranu
                  
                  blit(buffer, screen, 0, 0, 0, 0, 640, 700);//wklejenie bufora na ekran
                  rest(10);//odczekanie pomiêdzy kolejnym ruchem
            }
	readkey();
	destroy_bitmap(buffer);
	
	return 0;
}
Example #26
0
int main(int argc, char *argv[])
{
    scew_parser *parser = NULL;
    if (init() != 0) {
        return 1;
    }

    if (argc == 2) {
        if (exists(argv[1])) {
            parser = scew_parser_create();
            scew_parser_ignore_whitespaces(parser, 1);
            scew_parser_load_file(parser, argv[1]);
            maptree = scew_parser_tree(parser);
        } else {
            allegro_message("Cannot load file: %s", argv[1]);
            close_program = 1;
        }
    } else if (argc == 4) {
        maptree = new_map(0, MAP_WIN.w / TILE_W, atoi(argv[1]), 1, argv[2]);
        map_offset = atoi(argv[1]) * TILE_H - EDITOR_WIN_H;
    } else {
        /* print usage */
        allegro_message
            ("Usage:\n\"editor.exe <filename>\" to load a file\n \"editor.exe <height_in_tiles> <default_tile_name> <newmapfile>\" to create a new map");

        close_program = 1;
    }

    while (!close_program) {
        /* get input */
        parse_mouse();
        get_grid_item();
        if (keypressed()) {
            parse_keyboard();
        }

        /* blit virtual screen */
        clear_to_color(vscreen, DEAD_COLOR);
        draw_select_lists(vscreen);
        draw_ctrl_box(vscreen);

        update_screen();
    }

    if (argc == 2) {
        write_map(argv[1], maptree);
        scew_parser_free(parser);
    } else if (argc == 4) {
        write_map(argv[3], maptree);
        scew_tree_free(maptree);
    }
    destroy_bitmap(vscreen);
    cleanup();
    return 0;
}
Example #27
0
void waitforkeypress() {
#ifdef ALLEGRO
    allegro_init ();
    install_keyboard ();
  while (!keypressed()) {
  };
  #endif
//  while (keypressed()) {
//  };
//  readkey();
}
bool go_TestChips()
{
	printf(" Begin Chip %c Test\n", chipPosChar[chipPos]);
	prober.printf("MoveChuckContact");
	tb.mDelay(200);

	while (true)
	{
		int bin = 0;
		bool repeat;
		if (!TestSingleChip(bin,repeat)) break;

		int nRep = settings.errorRep;
		if (nRep > 0 && repeat)
		{
			prober.printf("BinMapDie %i", bin);
			prober.printf("MoveChuckSeparation");
			tb.mDelay(100);
			prober.printf("MoveChuckContact");
			tb.mDelay(200);
			if (!TestSingleChip(bin,repeat)) break;
			nRep--;
		}

		if (keypressed())
		{
			prober.printf("BinMapDie %i", bin);
			printf(" wafer test interrupted!\n");
			break;
		}

		// prober step
		int rsp;
		char *answer = prober.printf("BinStepDie %i", bin);
		if (sscanf(answer, "%i", &rsp)!=1) rsp = -1;
		if (rsp != 0) printf(" RSP %s\n", answer);
		tb.mDelay(100);

		// last chip ?
		if (rsp == 0)   // ok -> next chip
			continue;
		if (rsp == 703) // end of wafer -> return
		{
			prober.printf("MoveChuckSeparation");
			return true;
		}

		printf(" prober error! test stopped\n");
		break;
	}

	prober.printf("MoveChuckSeparation");
	return false;
}
Example #29
0
void gameover()
{
    BITMAP *fin = load_bitmap("media/gameover.bmp", NULL);
    if(fin == NULL)
        ERREUR("Echec chargement fin");
    blit(fin, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
    textprintf_centre_ex(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(0, 0, 0), makecol(255, 0, 0), "   Score : %d   ", score);
    while(keypressed())
        readkey();
    rest(2000);
    readkey();
}
Example #30
0
int input_waiting()
{
   /* check if characters are waiting, so we don't update screen if stuff
      still needs processing */

   if (auto_input_waiting())
      return TRUE;

   if (unget_count > 0)
      return TRUE;

   return keypressed();         /* is keyboard input waiting? */
}