Ejemplo n.º 1
0
bool playGame(Affichage A, Damier *map, Snake *snake, Sound sound)
{
	int end = 0;
	bool win = FALSE;
	Position newPos = initPosition();
	Input input = initInput();
	Chrono chrono = initChrono();
	Timer timer = initTimer();
	
	
	setProiesToMap(map);
	
	drawTile(A, TILE_TITLE);
	drawTextChrono(chrono, A);
	drawMap(A, *map, newPosition(MAXCASES/2 + 3,MAXCASES/2), *snake);

	startChrono(&chrono);
	while (1)
	{
		
		setTimer(&timer);
		newPos = updatePositions(map, snake, &input);
		
		if (input.end)
			break;

		if (testPosMap(newPos))
		{
			end = addPositionSnake(map, snake, newPos, sound);
			if (end)
			{
				win = FALSE;
				break;
			}
		}
		
		setPositionsToMap(map, snake);
		drawChrono(chrono, A);
		drawMap(A, *map, newPos, *snake);
		
		if(endChrono(chrono))
		{
			win = FALSE;
			break;
		}
		
		if (endGame(map))
		{
			win = TRUE;
			break;
		}
		
		reguleFPS(&timer);
	}
	
	deleteChrono(&chrono);
	return win;
}
Ejemplo n.º 2
0
 /**
  * \brief   Draws the base map, voronoi points and critical points, lines
  *          and regions on to image. Should be only used for testing the 
  *          output for Topological Mapper.
  * \param   image OpenCV image we are drawing output on 
  */
 void TopologicalMapper::drawOutput(cv::Mat &image) {
   VoronoiApproximator::drawOutput(image);
   drawMap(image, 2 * map_resp_.map.info.width);
   drawConnectedComponents(image, 2 * map_resp_.map.info.width);
   drawCriticalPoints(image, 2 * map_resp_.map.info.width);
   drawMap(image, 3 * map_resp_.map.info.width);
   drawRegionGraph(image, 3 * map_resp_.map.info.width);
   drawMap(image, 4 * map_resp_.map.info.width);
   drawPointGraph(image, 4 * map_resp_.map.info.width);
 }
Ejemplo n.º 3
0
 void TopologicalMapper::saveOutput() {
   cv::Mat image;
   drawMap(image);
   drawVoronoiPoints(image);
   cv::imwrite("graphvoronoi.png", image);
   drawMap(image);
   drawConnectedComponents(image);
   drawCriticalPoints(image);
   cv::imwrite("graphcritical.png", image);
   drawMap(image);
   drawGraph(image, region_graph_);
   cv::imwrite("graphoriginal.png", image);
   drawMap(image);
   drawGraph(image, pass_1_graph_);
   cv::imwrite("graphpass1.png", image);
   drawMap(image);
   drawGraph(image, pass_2_graph_);
   cv::imwrite("graphpass2.png", image);
   drawMap(image);
   drawGraph(image, pass_3_graph_);
   cv::imwrite("graphpass3.png", image);
   drawMap(image);
   drawGraph(image, pass_4_graph_);
   cv::imwrite("graphpass4.png", image);
   drawMap(image);
   drawGraph(image, point_graph_);
   cv::imwrite("graphfinal.png", image);
 }
Ejemplo n.º 4
0
void display(void)
{
	// Clear the color buffer, restore the background
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// Load the identity matrix, clear all the previous transformations
	glLoadIdentity();
	// Set up the camera
	mot_MoveCamera();
	// Collisions with blocks
	doMagic();
	mot_SetCamera();
	// Set light position
	vect_Vector eyePos = mot_GetEyePos(), targetPos = mot_GetTargetPos(), pos;
	pos = vect_Substract(targetPos, eyePos);
	vect_Normalize(&pos);
	pos = vect_Multiply(pos, -1);
	pos = vect_Add(pos, eyePos);
	lightPos[0] = pos.x;
	lightPos[1] = pos.y;
	lightPos[2] = pos.z;
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

	drawMap(Map);

	drawGuides();

	// Swap buffers in GPU
	glutSwapBuffers();
}
Ejemplo n.º 5
0
//Main display function
void display(void)
{

	glClearColor(0.2f, 0.3f, 1.0f, 0.9f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3f(0.0f, 0.0f, 0.0f);

	glPushMatrix();
	glMatrixMode(GL_MODELVIEW);
	glViewport(0, (WINDOW_HEIGHT / 3) * 2, WINDOW_WIDTH, WINDOW_HEIGHT - (WINDOW_HEIGHT / 3) * 2);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0, (GLdouble)WINDOW_WIDTH, (WINDOW_HEIGHT / 3) * 2, (GLdouble)WINDOW_HEIGHT, -1.0, 1.0);

	//draw the user interface **NOT THE MINI MAP**
	drawUI();

	glPopMatrix();
	glPushMatrix();
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

	//draw the actual world, with lighting
	theWorld.Draw(continuousRendering);
	glDisable(GL_LIGHTING);
	glPopMatrix();

	//draw the mini map interface 
	drawMap();
	glutSwapBuffers();
}
Ejemplo n.º 6
0
void drawHUD(ViewCamera& currentView, PlayerController* player, GameWorld* world, GameRenderer* render)
{
	if(player && player->getCharacter()) {
		drawMap(currentView, player, world, render);
		drawPlayerInfo(player, world, render);
	}
}
Ejemplo n.º 7
0
void LabEngine::doMap() {
	static uint16 amigaMapPalette[] = {
		0x0BA8, 0x0C11, 0x0A74, 0x0076,
		0x0A96, 0x0DCB, 0x0CCA, 0x0222,
		0x0444, 0x0555, 0x0777, 0x0999,
		0x0AAA, 0x0ED0, 0x0EEE, 0x0694
	};

	_graphics->_fadePalette = amigaMapPalette;

	updateEvents();
	loadMapData();
	_graphics->blackAllScreen();
	_interface->attachButtonList(&_mapButtonList);
	drawMap(_roomNum, _roomNum, _maps[_roomNum]._pageNumber, true);
	_event->mouseShow();
	_graphics->screenUpdate();
	processMap(_roomNum);
	_event->mouseHide();
	_interface->attachButtonList(nullptr);
	_graphics->fade(false);
	_graphics->blackAllScreen();
	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0);
	freeMapData();
	_event->mouseShow();
	_graphics->screenUpdate();
}
Ejemplo n.º 8
0
void cOutput::drawFrameUnitSelection(Uint32 ticks)
{
    drawMap();
    drawEntities();
    if(pUnitSelectionInputs->doDrawRect){ drawSelectionRectangle(&(pUnitSelectionInputs->DrawRect)); }

    if(selectedNumber > 0)
    {
        drawUnitHud(ticks);
    }
    else if(selectedBuildings > 0)
    {
        ///TODO
        //drawBuildingHud();
    }

    if(drawAoe != -1)
    {
        applyDrawAoe((pMousePosition->X)/TILE_WIDTH,(pMousePosition->Y)/TILE_HEIGHT,drawAoe);
    }
    // Draw the cursor
    cSurface::Draw(mScreen,cursorGraphic[pUnitSelectionInputs->cursorType],pMousePosition->X+CURSOR_OFFSET_X,pMousePosition->Y+CURSOR_OFFSET_Y);

    //Show the new screen
    SDL_Flip(mScreen);
}
Ejemplo n.º 9
0
void setup(void) {
  Serial.begin(9600);
  pinMode(JOYSTICK_BUTTON, INPUT);
  pinMode(RATING_LED_0, OUTPUT);
  pinMode(RATING_LED_1, OUTPUT);
  pinMode(RATING_LED_2, OUTPUT);
  pinMode(RATING_LED_3, OUTPUT);
  pinMode(RATING_LED_4, OUTPUT);

  digitalWrite(JOYSTICK_BUTTON, HIGH);

  tft.initR(INITR_REDTAB);

  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("OK!");

  drawMap();

  // test out reading blocks from the SD card
  if (!card.init(SPI_HALF_SPEED, SD_CS)) {
      Serial.println("Raw SD Initialization has failed");
      while (1) {};  // Just wait, stuff exploded.
  }

  verticalMidpoint = getVertical();
}
Ejemplo n.º 10
0
void navigateToWaypoint(float xtarget, float ytarget)
{
    while(!atTarget(xtarget, x) || (!atTarget(ytarget, y)))
    {
        float distance = calcDistance(xtarget, ytarget);
        float angle = calcAngle(xtarget, ytarget);

        float driveDistance = 0; //initialise
        if (distance < stepDistance)
        {
            driveDistance = distance;
        }
        else
        {
            driveDistance = stepDistance;
        }

        // co-ordinate system is different so cos and sin are swapped - take from current location not origin
        float tempWaypointX = x + (driveDistance * cos(angle));
        float tempWaypointY = y + (driveDistance * sin(angle));


        driveToWaypoint(tempWaypointX, tempWaypointY);
        monteCarlo();

        eraseDisplay();
        drawMap();
        drawParticles();
        wait1Msec(100);

    }

    PlayTone(784, 15);
}
Ejemplo n.º 11
0
BAGamesCommand BAGame::enemyRound(){
    // store information
  ABPoint playerCursor = ABPointMake(6, 4);
  ABPoint selectedTargetTile = ABPointMake(-1, -1);
  bool targetLocked = false;
  bool cursorFlip = true;

  while(true){
    if (!arduboy.nextFrame()) continue;
    if (arduboy.everyXFrames(10)) cursorFlip = !cursorFlip;

    // handle input
    globalInput.updateInput();

    if(globalInput.pressed(B_BUTTON)){
       playSoundSuccess();
       return BAGamesCommandNext;
    }

    // clear screen
    arduboy.clear();

    // Draw map of enemy
    drawMap(player, true);

    arduboy.display();
  }
}
Ejemplo n.º 12
0
void startGame(LifeMap& gameMap) {
    int step;
        
    for(step = 0; gameMap.isChange(); step++) {
        gamePlay::showGamePlayInfo(step, gameMap);
        drawMap(gameMap);
        TCODConsole::root->flush();

        gameMap.nextStep();
        Sleep(delay);

        TCOD_key_t key = TCODConsole::checkForKeypress();
        if(key.c == 'p') {
            gamePlay::showPause();
            TCODConsole::waitForKeypress(true);
        }
        else {
            if(key.vk == TCODK_ESCAPE)
                break;
        }
    }
    
    if(!gameMap.isChange()) {
        gamePlay::showFinish();
        TCODConsole::waitForKeypress(true);
    }

    gamePlay::showScore(step-1, gameMap);
    while(TCODConsole::waitForKeypress(true).vk != TCODK_ESCAPE) {}
}
Ejemplo n.º 13
0
int Model::step() {

	drawMap();
	int res;
	while (1) {
		for(vector<PlayerPtr>::iterator it=players.begin()+1; it!=players.end(); ++it) {
			if((res = players.begin()->get()->turn()) != GAME_RUNNING) 
				return res;
			
			if((res = it->get()->turn()) != GAME_RUNNING)	 //Each player implements his own turn() method (ai or real)
				if (res != GAME_NO_WAY)
					return res;								
				
			drawMap();
		}
	}
}
Ejemplo n.º 14
0
void LEditor::draw()
{
    drawImage(background, 0, 0);

    drawMap();

    SDL_Flip(screen);
}
Ejemplo n.º 15
0
void App::updateDisplay()
{
	//Apply the image
	SDL_BlitSurface(bgIMG, NULL, mainWin.gScreenSurface, NULL);
	drawMap();
	//Update the surface
	SDL_UpdateWindowSurface(mainWin.gWindow);
}
Ejemplo n.º 16
0
Archivo: MCL.c Proyecto: xdanx/dandroid
task main() {
	clearDebugStream();
	nMotorEncoder[LEFT_WHEEL] = 0;
	nMotorEncoder[RIGHT_WHEEL] = 0;

	bPlaySounds = true;
	set_starting_position(84.0, 30.0, 0.0);

	drawMap();

	StartTask(vehicle_compute_position);
	//StartTask(vehicle_draw_position);

	navigate_to_waypoint(104, 30);
	drawParticles();
	navigate_to_waypoint(124, 30);
	drawParticles();
	navigate_to_waypoint(144, 30);
	drawParticles();
	navigate_to_waypoint(180, 30);
	drawParticles();
	navigate_to_waypoint(180, 54);
	drawParticles();
	navigate_to_waypoint(164, 54);
	drawParticles();
	navigate_to_waypoint(126, 54);
	drawParticles();
	// Moved left
	// Going up
	navigate_to_waypoint(126, 74);
	drawParticles();
	navigate_to_waypoint(126, 94);
	drawParticles();
	navigate_to_waypoint(126, 104);
	drawParticles();
	navigate_to_waypoint(126, 124);
	drawParticles();
	navigate_to_waypoint(126, 144);
	drawParticles();
	navigate_to_waypoint(126, 168);
	drawParticles();
	navigate_to_waypoint(126, 148);
	drawParticles();
	navigate_to_waypoint(126, 126);
	drawParticles();
	// From here, move in 20 cm ranges
	navigate_to_waypoint(30, 54);
	drawParticles();
	navigate_to_waypoint(84, 54);
	drawParticles();
	navigate_to_waypoint(84, 30);
	drawParticles();

  StopTask(vehicle_compute_position);
  //StopTask(vehicle_draw_position);

  wait10Msec(60000); // wait 1MIN
}
Ejemplo n.º 17
0
void drawGame(Game *game)
{
	beginDrawing(game->renderer);
	
	drawMap(game->map, game->renderer);
	drawPerso(game->renderer);
	
	endDrawing(game->renderer);
}
Ejemplo n.º 18
0
void Engine::drawGame()
{
    drawMap();
    drawItems();
    drawPlayer();
    drawMonsters();
    drawStatus();
    drawMessageQue();
}
Ejemplo n.º 19
0
int draw(){
	drawOutline();
	drawMap();
	water();
	voidBlock();
	attron(COLOR_PAIR(6));
	mvprintw(12,0,"Block Type:");
	return 0;
}
Ejemplo n.º 20
0
void Interface::draw() {
    
    ofFill(); 
    ofBackground(0, 0, 0);
    ofSetColor(255);
    
    float w = ofGetWidth();
    float h = ofGetHeight();
            
    // draw settings area 
    
    
    // draw path selector area
    drawPathInspector(0, 0, w*0.5, h*0.5);
    
    // draw map 50% 0, 100%, 60%
    drawMap(w*0.5+pad, 0+pad, (w*0.5)-(2*pad), (h*0.5)-(2*pad));
    
    // draw detail inspection view / path editor 
    drawPointInspector(0, h*0.5, w*0.5, h*0.45);
    
    // draw output view 
    //ofSetColor(60);
    //ofRect(w*0.5, h*0.5, w*0.5, h*0.45);
    drawOutput(w*0.5, h*0.5, w*0.5, h*0.45);
    
    // draw simulator control / timeline
    //ofSetColor(40);
    //ofRect(0, h*0.95, w, h*0.05);
    drawTimeline(0, h*0.95, w, h*0.05);
    
    /*for (int i=0; i<data->paths.size(); i++) {
        drawPath(&data->paths[i]);
    }
    
    if (selectedPoint) {
        drawInterpolation(&selectedPoint->bikes, 20., 800., 700., 400.);
    }*/
    
    
    ofSetColor(20, 20, 255);
    if(selectedPath){
        ofDrawBitmapString("Selected path: " + ofToString(selectedPath->i), 20, 20);
        ofDrawBitmapString("   Sum max: " + ofToString(selectedPath->sum_max), 20, 40);
    }
    if(selectedPoint){
        ofDrawBitmapString("Selected point: " + ofToString(selectedPoint->i), 20, 80);
    }
    if(selectedChannel){
        ofDrawBitmapString("Selected channel: " + ofToString(selectedChannel->i), 20, 140);
    }
    
    ofSetColor(255,20,20);
    ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 20, 180);
    
    
}
Ejemplo n.º 21
0
void TIM3_IRQHandler(void)   //TIM5中断
{
	if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
	{
		LCD_Color_Fill(150,10,175,20, White);
		LCD_ShowNum(150,10,adcValue ,Black);
		drawMap();
	}
	TIM_ClearITPendingBit(TIM3, TIM_IT_Update  );  //清除TIMx的中断待处理位:TIM 中断源
}
Ejemplo n.º 22
0
int main() {
	InitGraphics();
	SetWindowTitle("CS106 Pathfinder");
    cout << "This masterful piece of work is a graph extravaganza!" << endl
        << "The main attractions include a lovely visual presentation of the graph" << endl
        << "along with an implementation of Dijkstra's shortest path algorithm and" << endl
        << "the computation of a minimal spanning tree.  Enjoy!" << endl;
	Graph graph;
	Map<coordT> nodeCor;
	string loc1, loc2, image;
	image = loadGraphFile(graph, nodeCor);
	drawMap(graph, nodeCor);
	while (true) {
		int choice = promptForChoice();
		switch (choice) {
			case 1:
				graph.clear();
				nodeCor.clear();
				image = loadGraphFile(graph, nodeCor);
				drawMap(graph, nodeCor);
				break;
			case 2:
				cout << endl;
				loc1 = getLocName("Click on starting location...  ", nodeCor);
				loc2 = getLocName("Click on ending location...  ", nodeCor);
				displayMinPath(graph, nodeCor, loc1, loc2);
				break;
			case 3:
				InitGraphics();
				DrawNamedPicture(image);
				drawVertices(nodeCor);
				displayMST(graph, nodeCor);
				break;
			case 4:
				displayDomSet(graph, nodeCor);
				break;
			case 5: exit(0);
		}
	} 

    return (0);
}
Ejemplo n.º 23
0
void drawPlayArea() {
    clearPlay();

    //mvwprintw(win,2,1,"Encounter: %i",encounter_occurred);
    drawMap();

    wattron(win,COLOR_PAIR(10) | A_BOLD);
    mvwprintw(win,player.y,player.x,player.avatar);
    wattroff(win,COLOR_PAIR(10)| A_BOLD);
    wrefresh(win);
}
Ejemplo n.º 24
0
Archivo: draw.c Proyecto: zear/g-ball
void drawInGame()
{
	char joyInfo[10]; // temporary

	drawBackground(0, 0, 0);	
	drawMap();
	drawEntities();

	//sprintf(joyInfo, "x:%d\ny:%d\n", SDL_JoystickGetAxis(joy, 0), SDL_JoystickGetAxis(joy, 1));
	//drawText(joyInfo, 250, 200, &FontSmall);
}
Ejemplo n.º 25
0
task main()
{
	eraseDisplay();

	drawMap();

	drawParticles();

	wait1Msec(5000);

}
Ejemplo n.º 26
0
void prepareFild() {
    drawGameFrame();

    char color = LifeMap::WHITE_CELL;
    gameMenu::drawGameHelp(color);

    LifeMap gameMap;

    int xPos = LifeMap::widht/2;
    int yPos = LifeMap::height/2;

    while(true) {
        drawMap(gameMap, xPos, yPos, color);
        TCODConsole::root->flush();
        TCOD_key_t key = TCODConsole::waitForKeypress(true);

        switch(key.c) {
            case ' ': gameMap.set(xPos, yPos, color);
                break;
            case 's': // SAVE
                break;
            case 'q': // QUIT DIALOG
                return;
            case 'w': color = LifeMap::WHITE_CELL;
                      gameMenu::drawGameHelp(color);
                break;
            case 'r': color = LifeMap::RED_CELL;
                      gameMenu::drawGameHelp(color);
                break;
            case 'g': color = LifeMap::GREEN_CELL;
                      gameMenu::drawGameHelp(color);
                break;
            case 'b': color = LifeMap::BLUE_CELL;
                      gameMenu::drawGameHelp(color);
                break;
            default:
                switch(key.vk) {
                    case TCODK_ENTER: startGame(gameMap);
                        return;
                    case TCODK_LEFT: xPos = (xPos+LifeMap::widht-1)%LifeMap::widht;
                        break;
                    case TCODK_UP: yPos = (yPos+LifeMap::height-1)%LifeMap::height;
                        break;
                    case TCODK_DOWN: yPos = (yPos+1)%LifeMap::height;
                        break;
                    case TCODK_RIGHT: xPos = (xPos+1)%LifeMap::widht;
                        break;
                    default:
                        break;
                }
        }
    }
}
Ejemplo n.º 27
0
int main(){
    ball b;
    wall w[50];
    int i=0;
    for(;i<15;++i){
        w[i].y=15;
        w[i].x=10+i;
        w[i].flag=URWALL;
    }
    for(;i<30;++i){
        w[i].y=w[14].y+i-15;
        w[i].x=w[14].x;
        w[i].flag=WALL;
    }
    for(;i<50;++i){
        w[i].y=w[29].y;
        w[i].x=w[29].x+i-30;
        w[i].flag=DRWALL;
    }

    initscr();
    raw();
    keypad(stdscr,TRUE);
    noecho();
    curs_set(FALSE);

    initball(&b,DELAY,'O');
    b.direction_x=1;
    drawMap(w,50);

    timeout(DELAY);

    while(1){
        /* getmaxyx(stdscr,max_y,max_x); */
        /* clear(); */

        /* drawMap(NULL,0); */
        /* collision(&b); */
        drawball(&b);

        refresh();

        changedirection(&b);
        updateball(&b);
        /* ch=halfdelay(190); */
        if(quit)
            break;
    }

    endwin();
    exit(EXIT_SUCCESS);
}
Ejemplo n.º 28
0
int main()
{
printf("\n\n\n\t使用2468移动,5落子\n"); 
	usleep(1666000);
	clrscr();
	while(!kbhit())
	{
	redraw();
    	drawMap();
	Run();
	}
    return 0;
}
void start(char* path){
	for(int i = 0; i < mapSizeX; i++){
		vMap[i] = new int[mapSizeY];
	}
	//time(0)
	srand(0);
	generationMap(vMap);
	//generationMap(heigthMap);
	for(int i = 1; i< mapSizeY; i+=10){
		drawIncision(vMap, i);
	}
	drawMap(path, vMap);
}
Ejemplo n.º 30
0
void drawMenu(Map *menu) {
	drawMap(MIDGROUND, menu);

	int c0 = SELECT_MENU(getInfoGame()->choiceMenu, 0);
	int c1 = SELECT_MENU(getInfoGame()->choiceMenu, 1);
	int c2 = SELECT_MENU(getInfoGame()->choiceMenu, 2);
	int c3 = SELECT_MENU(getInfoGame()->choiceMenu, 3);

	drawString("Start game", TILE_SIZE * 4 + TILE_SIZE / 2, 3 * TILE_SIZE + TILE_SIZE / 4, 255, c0, c0, 0);
	drawString("Edit map", TILE_SIZE * 4 + TILE_SIZE / 2, 5 * TILE_SIZE + TILE_SIZE / 4, 255, c1, c1, 0);
	drawString("Option", TILE_SIZE * 4 + TILE_SIZE / 2, 7 * TILE_SIZE + TILE_SIZE / 4, 255, c2, c2, 0);
	drawString("Exit", TILE_SIZE * 4 + TILE_SIZE / 2, 9 * TILE_SIZE + TILE_SIZE / 4, 255, c3, c3, 0);
}