float KX_BlenderCanvas::GetMouseNormalizedX(int x) { int can_x = GetMouseX(x); return float(can_x)/this->GetWidth(); }
int main (void) { unsigned char MoveDir=0; SetupCpu(); SetupCode(); rfPwrUp(); rfRxMode(); LED1ON; WaitForSwitch(); LED1OFF; //TimerAStart(); /* while(1) { if (CTS) { LED5TOGGLE; } if (!CTS) LED5OFF; if( TimerExpired || IfSwitch() ) { CTS=0; TimerExpired=0; AssembleStartTimerPacket(); rfStandbyMode(); rfSendPacket2Module(&TxPacket[0],32); rfTxMode(); softDelay(65535); rfStandbyMode(); rfRxMode(); LED1TOGGLE; } } */ // MAZE MAPPING CODE AddWall(SOUTH, GetMouseX(), GetMouseY() ); ReserveCurrentCell(); AnalyseCellLR(); AnalyseCellFB(); ReserveCellsAroundHere(); IncrementCellVisits(); SetThisCellMappedByThisMouse(); TxCellInfo(); while (1) { MoveDir = 0; while (!MoveDir) //If unable to get an exit, redo until can get exit { MoveDir=GetExitDir(); LED7ON; } LED7OFF; ReserveCellsAround(MoveDir); Rotate( MoveDir ); DriveToEndOfCurrentCellCorrecting(); MoveToNewCellLogical(MoveDir); // no walls in new cell, so will not correct until LR analysed DriveToStartOfNextCellNOTCorrecting(); AnalyseCellLR(); // analysed, so if walls exist, mouse will correct itself DriveToMiddleOfNewCellCorrecting(); AnalyseCellFB(); IncrementCellCount(); IncrementCellVisits(); TxCellInfo(); ReleaseOldCells(MoveDir); ReleaseWalledCells(); DeadEndBlocking(); if ( IsMazeMapped() ) break; } SetLedsLower(0x55); // count total visits in maze unsigned char x = 0; unsigned char y = 0; unsigned char count = 0; while (y < MAZEY) { while (x < MAZEX) { count += GetVisits(x,y); x++; } y++; x=0; } // SetLedsUpper (count); while (1) { WaitForSwitch(); // SetLedsUpper(GetLargeErrors()); WaitForSwitch(); // SetLedsUpper(GetSmallErrors()); } return 0; }
int egg_tips()//打印egg库版本的初始化提示信息 { HEGG first_egg;//打印初始信息的egg char infor1[]="欢迎来到黄金梅里号~~"; char infor2[]="为了使您“旅途愉快”,请先进行一下电梯参数的参数配置:"; int situ,i/*counter*/; int mouseX,mouseY; int dealwith_click(int num); first_egg=LayEgg(); DrawBitmap("bitmap//开始.bmp"); MovePen(200,670); SetPenColor(BLUE); act_string(infor1,70); MovePen(200,650); SetPenColor(DARK_MAGENTA); act_string(infor2,60); //initialization MovePen(200,590); DrawBitmap("bitmap//scale.bmp"); if(delay==DEFAULT_DELAY && ratio==DEFAULT_RATIO && strategy==DEFAULT_STRATEGY) { MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_R); } switch(delay) { case 500: MovePen(click[3].leftup_x,click[3].leftup_y); DrawBitmap(click[3].bitmap_R); break; case 1000: MovePen(click[4].leftup_x,click[4].leftup_y); DrawBitmap(click[4].bitmap_R); break; case 1500: MovePen(click[5].leftup_x,click[5].leftup_y); DrawBitmap(click[5].bitmap_R); break; case 2000: MovePen(click[6].leftup_x,click[6].leftup_y); DrawBitmap(click[6].bitmap_R); break; case 3000: MovePen(click[7].leftup_x,click[7].leftup_y); DrawBitmap(click[7].bitmap_R); break; } MovePen(click[7+ratio].leftup_x,click[7+ratio].leftup_y); DrawBitmap(click[7+ratio].bitmap_R); MovePen(click[12+strategy].leftup_x,click[12+strategy].leftup_y); DrawBitmap(click[12+strategy].bitmap_R); while((situ=WaitForEvent())!=0) { mouseX=(int)GetMouseX(); mouseY=(int)GetMouseY(); if(situ==KEYDOWN) { for(i=0;i<19;i++) { if(click[i].leftup_x<=mouseX && click[i].leftup_y>=mouseY && click[i].rightdown_x>=mouseX && click[i].rightdown_y<=mouseY) { int r; if((r=dealwith_click(i))==1) { EatEgg(); return 1; } else if(r==-1) { EatEgg(); return -1; } break; } } } } EatEgg(); return 0; }