コード例 #1
0
ファイル: bugeatwc.c プロジェクト: 375670450/BugEat
main()
{
   randomize();
   fill_maze_with_wall();
   build_maze(1, 1, RIGHT_BOUND, BOTTOM_BOUND);
   search_target_xy(&tx, &ty);
   memset(mark, 0, sizeof(mark));
   show_maze(0, 0, RIGHT_BOUND+1, BOTTOM_BOUND+1);
   save_sth_under_target();
   draw_target();
   bioskey(0);
   init_bug(1, 1, 0);
   old_8h = getvect(8);
   old_9h = getvect(9);
   setvect(8, int_8h);
   setvect(9, int_9h);
   while(!stop)
   {
      if(move_bug(bug[0].x, bug[0].y, tx, ty) == 1) /* target has been reached */
      {
         bug_cry();
         break;
      }
   }
   setvect(8, old_8h);
   setvect(9, old_9h);
   bioskey(0);
}
コード例 #2
0
ファイル: gui_gtk.c プロジェクト: drhachmann/brtablet
static void draw_target_all(cairo_t *cr, GuiInfoPtr gui_info){
	cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
	int i,j;	
	for(i=0; i<N_ROW; i++){
		for(j=0; j<N_COLUMN; j++){
			if(i==gui_info->current_X && j==gui_info->current_Y){
				cairo_set_line_width(cr, 5);
				cairo_set_source_rgb(cr, 0, 0, 255);
			}else{
				switch(gui_info->recorded[i][j]){
					case NO_RECORDED:
						cairo_set_line_width(cr, 2);
						cairo_set_source_rgb(cr, 0, 0, 0);
						break;
					case RECORDED:
						cairo_set_line_width(cr, 2);
						cairo_set_source_rgb(cr, 255, 0, 0);
						break;
				}
			}
			draw_target(cr, gui_info->point_xy[i][j].x, gui_info->point_xy[i][j].y,\
							gui_info->point_uv[i][j], gui_info->win_width, gui_info->win_height);
		}
	}
}
コード例 #3
0
ファイル: bugeatwc.c プロジェクト: 375670450/BugEat
void interrupt int_9h(void)
{
    unsigned char key;
    key = inportb(0x60);     /* read key code */
    if( key == 0xE0 || key == 0xE1) /* KeyExtend */
       ;
    else if( (key & 0x80) == 0x80 ) /* KeyUP */
    {
       if(key == (ESC|0x80)) /* Esc key is released */
          stop = 1;          /* Set the stop flag */
    }
    else                     /* KeyDown */
    {
       switch(key)
       {
       case UP:
          if(ty-1 <= 0)
             break;
          --ty;
          draw_target();
          break;
       case DOWN:
          if(ty+1 > BOTTOM_BOUND)
             break;
          ++ty;
          draw_target();
          break;
       case LEFT:
          if(tx-1 <= 0)
             break;
          --tx;
          draw_target();
          break;
       case RIGHT:
          if(tx+1 > RIGHT_BOUND)
             break;
          ++tx;
          draw_target();
          break;
       }
    }
    outportb(0x61, inportb(0x61) | 0x80);
    outportb(0x61, inportb(0x61) & 0x7F); /* respond to keyboard */
    outportb(0x20, 0x20); /* End Of Interrupt */
}
コード例 #4
0
ファイル: tx_configure.c プロジェクト: caoqing32/deviation
static void calibrate_touch(void)
{
    if (cp->state == 0 || cp->state == 3) {
        if (GUI_ObjectNeedsRedraw((guiObject_t *)&guic->msg))
            return;
        draw_target(cp->state ? LCD_WIDTH - XCOORD : XCOORD , cp->state ? LCD_HEIGHT - YCOORD : YCOORD + 32);
        cp->state++;
    } else if (cp->state == 1 || cp->state == 4) {
        if (SPITouch_IRQ()) {
            cp->coords = SPITouch_GetCoords();
            cp->state++;
        }
    } else if (cp->state == 2) {
        if (! SPITouch_IRQ()) {
            cp->coords1 = cp->coords;
            GUI_RemoveObj((guiObject_t *)&guic->msg);
            GUI_CreateLabelBox(&guic->msg, LCD_WIDTH - XCOORD - 5, LCD_HEIGHT - YCOORD - 5,
                                            11, 11, &SMALLBOX_FONT, NULL, NULL, "");
            GUI_Redraw(&guic->msg1);
            cp->state = 3;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if (cp->state == 5) {
        if (! SPITouch_IRQ()) {
            s32 xscale, yscale;
            s32 xoff, yoff;
            printf("T1:(%d, %d)\n", cp->coords1.x, cp->coords1.y);
            printf("T2:(%d, %d)\n", cp->coords.x, cp->coords.y);
            xscale = cp->coords.x - cp->coords1.x;
            xscale = (LCD_WIDTH - 2 * XCOORD) * 0x10000 / xscale;
            yscale = cp->coords.y - cp->coords1.y;
            yscale = (LCD_HEIGHT - 32 - 2 * YCOORD) * 0x10000 / yscale;
            xoff = XCOORD - cp->coords1.x * xscale / 0x10000;
            yoff = YCOORD + 32 - cp->coords1.y * yscale / 0x10000;
            printf("Debug: scale(%d, %d) offset(%d, %d)\n", (int)xscale, (int)yscale, (int)xoff, (int)yoff);
            SPITouch_Calibrate(xscale, yscale, xoff, yoff);
            PAGE_RemoveAllObjects();
            PAGE_SetModal(1);
            PAGE_ShowHeader_ExitOnly(_tr("Touch Test"), okcancel_cb);
            GUI_CreateLabelBox(&guic->msg, (LCD_WIDTH - 150) / 2, (LCD_HEIGHT - 25) / 2, 150, 25, &SMALLBOX_FONT, coords_cb, NULL, NULL);
            memset(&cp->coords, 0, sizeof(cp->coords));
            cp->state = 6;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if(cp->state == 6) {
        struct touch t;
        if (SPITouch_IRQ()) {
            t = SPITouch_GetCoords();
            if (memcmp(&t, &cp->coords, sizeof(t)) != 0) {
                cp->coords = t;
                GUI_Redraw(&guic->msg);
            }
        }
    }
}
コード例 #5
0
//Draw the world and all objects
void Game::drawScene(){
	static float hlt_rate = 0.01;		// opacity rate for highlights
	static float hlt =  0.4;			// opacity for highlights
	world.display(camera.get_pos());	// Draw the map

	// Draw fish in the water
	glColor3f(0,0.1,0.2);
	glPushMatrix();
		glTranslatef(0,-1,0);
		bird_system[0].display(dt, camera.get_pos());
	glPopMatrix();

	// Draw birds in the sky
	glColor3f(1,1,1);
	bird_system[1].display(dt, camera.get_pos());

	// Draw water
	glColor4ub(89,173,237,200);
	water_system.display(dt);
	draw_still_water();
	
	glDisable(GL_FOG);
	
	glEnable(GL_FOG);

	glDisable(GL_LIGHTING);

	// Draw the highlight around the selected unit
	glPointSize(4);
	if( current.is_traversable() ){
		vector3f p = current.get_wpos();
		glColor4f(0,0,1,hlt);
		draw_hilite(p);
	}

	// Draw the target around the target tile or unit
	if( target.is_traversable() ){
		vector3f p = target.get_wpos();
		glColor4f(1,0,0,hlt);
		draw_target(p);
	}

	// Draw the highlights for the possible movement area
	if( move_area.size() > 0 ){
		glColor4ub(255,0,93,255*hlt);
		for (int i = 0; i < move_area.size(); ++i){
			vector3f p = move_area[i].get_wpos();
			draw_hilite(p);
		}
	}

	// Draw the hilights for the movement path
	if( move_path.size() > 0 ){
		glColor4f(0,0,1,hlt);
		for (int i = 1; i < move_path.size(); ++i){
			vector3f p = move_path[i].get_wpos();
			draw_hilite(p);
		}
	}

	hlt += hlt_rate;
	if( hlt < 0.4 || hlt > 0.75)
		hlt_rate *= -1;

	draw_skybox();

	glEnable(GL_LIGHTING);
	
	// Draw all the units
	for (int i = 0; i < units.size(); ++i){
		if( units[i].get_team() == 0 )
			glColor3f(0.3,0.3,0.3);
		else
			glColor3f(0.7,0.7,0.7);
		units[i].display(dt,camera.get_pos());	
	}

	draw_hud();
}
コード例 #6
0
ファイル: screen_keyboard.c プロジェクト: OpenGelo/multigcs
void screen_keyboard(ESContext *esContext) {
#ifdef SDLGL
	if (draw_target() != 0) {
		return;
	}
#endif
#ifndef SDLGL
	ESMatrix modelview;
	UserData *userData = esContext->userData;
#endif
	if (show_keyboard != setup.view_mode) {
		return;
	}
	reset_buttons();
	draw_box_f3(esContext, -1.5, -1.0, 0.02, 1.5, 1.0, 0.02, 0, 0, 0, 200);
	draw_title(esContext, "Keyboard");
	char tmp_str[100];
	char tmp_str2[100];
	int n = 0;
#ifndef SDLGL
	esMatrixLoadIdentity(&modelview);
	esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective);
	esMatrixMultiply(&userData->mvpMatrix2, &modelview, &userData->perspective);
#endif
	for (n = 0; n < strlen(new_name) + 1; n++) {
		if (new_name[n] != 0) {
			sprintf(tmp_str2, "%c", new_name[n]);
		} else {
			sprintf(tmp_str2, "[END]");
		}
		sprintf(tmp_str, "set_char_%i", n);
		draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -0.9 + n * 0.08, -0.6, 0.02, 0.06, ALIGN_LEFT, ALIGN_TOP, keyboard_pos_char, n);
		if (n == new_name_cnt) {
			draw_text_button(esContext, "mark", setup.view_mode, "^", FONT_WHITE, -0.9 + n * 0.08, -0.5, 0.02, 0.06, ALIGN_LEFT, ALIGN_TOP, keyboard_pos_char, n);
		}
	}
	draw_text_button(esContext, "rcname_save", setup.view_mode, "[OK]", FONT_WHITE, 0.4, -0.6, 0.02, 0.06, ALIGN_LEFT, ALIGN_TOP, keyboard_name_save, 0);
	draw_text_button(esContext, "rcname_cancel", setup.view_mode, "[CANCEL]", FONT_WHITE, 0.6, -0.6, 0.02, 0.06, ALIGN_LEFT, ALIGN_TOP, keyboard_name_cancel, 0);
	uint8_t x = 0;
	uint8_t y = 0;
	if (type == 0) {
		for (n = 33; n < 150; n++) {
			sprintf(tmp_str2, "%c", n);
			sprintf(tmp_str, "add_char_%i", n);
			draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -1.1 + x * 0.14, -0.3 + y * 0.14, 0.02, 0.06, ALIGN_CENTER, ALIGN_TOP, keyboard_add_char, n);
			if (x > 14) {
				y++;
				x = 0;
			} else {
				x++;
			}
		}
	} else {
		for (n = '0'; n <= '9'; n++) {
			sprintf(tmp_str2, "%c", n);
			sprintf(tmp_str, "add_char_%i", n);
			draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -1.1 + x * 0.14, -0.3 + y * 0.14, 0.02, 0.1, ALIGN_CENTER, ALIGN_TOP, keyboard_add_char, n);
			if (x > 1) {
				y++;
				x = 0;
			} else {
				x++;
			}
		}
		if (type == 2) {
			sprintf(tmp_str2, "%c", '.');
			sprintf(tmp_str, "add_char_%i", '.');
			draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -1.1 + x * 0.14, -0.3 + y * 0.14, 0.02, 0.1, ALIGN_CENTER, ALIGN_TOP, keyboard_add_char, '.');
			if (x > 1) {
				y++;
				x = 0;
			} else {
				x++;
			}
		}
		sprintf(tmp_str2, "%c", '-');
		sprintf(tmp_str, "add_char_%i", '-');
		draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -1.1 + x * 0.14, -0.3 + y * 0.14, 0.02, 0.1, ALIGN_CENTER, ALIGN_TOP, keyboard_add_char, '-');
		if (x > 1) {
			y++;
			x = 0;
		} else {
			x++;
		}
	}
	sprintf(tmp_str2, "[END]");
	sprintf(tmp_str, "add_char_%i", 0);
	draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str2, FONT_WHITE, -1.1 + x * 0.14, -0.3 + y * 0.14, 0.02, 0.06, ALIGN_CENTER, ALIGN_TOP, keyboard_add_char, 0);
	if (keyboard_key[0] != 0) {
		if (strcmp(keyboard_key, "return") == 0) {
			keyboard_name_save("", 0.0, 0.0, 0, 0.0, 0);
		} else if (strcmp(keyboard_key, "backspace") == 0) {
			new_name_cnt--;
		} else if (strcmp(keyboard_key, "delete") == 0) {
			keyboard_add_char("", 0.0, 0.0, 0, 0.0, 0);
		} else if (strcmp(keyboard_key, "up") == 0) {
		} else if (strcmp(keyboard_key, "down") == 0) {
		} else if (strcmp(keyboard_key, "end") == 0) {
		} else if (strcmp(keyboard_key, "home") == 0) {
			new_name_cnt = 0;
		} else if (strcmp(keyboard_key, "escape") == 0) {
			keyboard_name_cancel("", 0.0, 0.0, 0, 0.0, 0);
		} else if (strcmp(keyboard_key, "left") == 0) {
			new_name_cnt--;
		} else if (strcmp(keyboard_key, "right") == 0) {
			new_name_cnt++;
		} else if (strcmp(keyboard_key, "space") == 0) {
			keyboard_add_char("", 0.0, 0.0, 0, ' ', 0);
		} else if (keyboard_key[1] == 0) {
			keyboard_add_char("", 0.0, 0.0, 0, keyboard_key[0], 0);
		}
		keyboard_key[0] = 0;
	}
}
コード例 #7
0
ファイル: main.cpp プロジェクト: lastab/BagChal
void show_possible_movement(int j,int k)
{
    int count=0;
        if( check_up(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k-1;
        draw_target(move_loc[count][0],move_loc[count][1]);
        count++;
    }
        if( check_down(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k+1;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k-1;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_up_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k-1;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_down_left(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k+1;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_down_right(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k+1;
        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
    }   
}    
コード例 #8
0
ファイル: main.cpp プロジェクト: lastab/BagChal
void show_possible_jump_movement(int j,int k)
{
    int count=0;
    if( check_up(j,k)==2 && check_up(j,k-1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k-2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down(j,k)==2 && check_down(j,k+1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k+2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
        if( check_left(j,k)==2 && check_left(j-1,k)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;                
    }
        if( check_right(j,k)==2 && check_right(j+1,k)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==2 && check_up_left(j-1,k-1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k-2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
        if( check_up_right(j,k)==2  && check_up_right(j+1,k-1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k-2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down_left(j,k)==2 && check_down_left(j+1,k+1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k+2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down_right(j,k)==2 && check_down_right(j-1,k+1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k+2;        
        draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
    }
}