Пример #1
0
void update() {
	if (KEY_DOWN_NOW(BUTTON_SELECT))
			main();
	
	sprintf(string, "Score = %d", score);
	
	for (int i = 0; i < NUMDOTS; i++) {
		if (rectCollides(dots[i].rect, pacman) || dots[i].rect.col<=0) {
			if (dots[i].isGhost && dots[i].rect.col > 0)
				drawEnd();
			else {
				initDot(i);
				score++;
			}
		}
		dots[i].rect.col -= dots[i].del;
	}
	
	// Move Pacman
	if (KEY_DOWN_NOW(BUTTON_DOWN) && pacman.row < SCREENHEIGHT - pacman.height - TEXT_HEIGHT)
		pacman.row++;
	if (KEY_DOWN_NOW(BUTTON_UP) && pacman.row > 0)
		pacman.row--;
	if (KEY_DOWN_NOW(BUTTON_LEFT) && pacman.col > 0)
		pacman.col--;
	if (KEY_DOWN_NOW(BUTTON_RIGHT) && pacman.col < SCREENWIDTH - pacman.width)
		pacman.col++;
}
Пример #2
0
void PrimitiveSet::draw(RenderContext* renderContext)
{
  drawBegin(renderContext);

  drawAll(renderContext);

  drawEnd(renderContext);
}
Пример #3
0
void Shape::draw(RenderContext* renderContext)
{ 
  drawBegin(renderContext);
  SAVEGLERROR;
  
  for(int i=0;i<getElementCount();i++) 
    drawElement(renderContext, i);
    
  SAVEGLERROR;  
  drawEnd(renderContext);
  SAVEGLERROR;
}
Пример #4
0
Файл: cgii.c Проект: chamun/CGII
void
draw(void)
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    /* 3D */
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_COLOR_MATERIAL);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( 60, 1, 0.05, WORLD_SIDE * 2 * 2.4142);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    illumination();

    gluLookAt(compass[P].x, PLAYER_HEIGHT, compass[P].y,
              compass[W].x, PLAYER_HEIGHT, compass[W].y,
              0, 1, 0);

    drawEnv();
    drawCoins();
    drawFixeds();

    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHT0);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);

    /* 2D */

    /* Isso aqui só precisa ser chamado uma vez, e quando a janela muda de
     * tamanho */
    glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, WINDOW_SIZE, WINDOW_SIZE, 0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    if(playing) {
        drawScoreBoard(20,20);
        if(map)
            drawMiniMap(3.5f * MAP_SIZE, 3.5f * MAP_SIZE);
    } else
        drawEnd();

    glutSwapBuffers();
}
Пример #5
0
//Game Loop
bool ce_game::start_game(){
	//Create the tick timer functions
	LOCK_VARIABLE(ticks);
	LOCK_FUNCTION(ticker);
	install_int_ex(ticker, BPS_TO_TIMER(fps));

	//----------GameLoop----------
	while (isPlaying || end_timer > 0 || start_timer > 0){

		//Wait until a tick has happened
		while(ticks == 0){
			rest(1);
		}
		
		//If there is a tick pending update the logic and remve the tick
		while(ticks > 0){

			//Do game logic or decriment end/start timers
			if (isPlaying){
				checkEscape();
				update();
				checkState();
			}else if (start_timer >= 0){
				if (start_timer == 0){
					isPlaying = true;
					start_timer = -1;
				}else{
					start_timer--;
				}
			}else{
				end_timer--;
			}

			ticks--;
		}
		
		//Draw game or start/end screens
		if (start_timer > 0){
			drawStart();
		}else if (isPlaying || end_timer > 150){
			draw();
		}else{
			drawEnd();
		}
	}

	return hasWon;
}
Пример #6
0
void PrimitiveSet::renderZSort(RenderContext* renderContext)
{
  // sort by z-depth
  
  std::multimap<float,int> distanceMap;
  for (int index = 0 ; index < nprimitives ; ++index ) {
    float distance = renderContext->getDistance( getCenter(index) );
    distanceMap.insert( std::pair<float,int>(-distance,index) );
  }

  // render ordered

  drawBegin(renderContext);
  
  for ( std::multimap<float,int>::iterator iter = distanceMap.begin(); iter != distanceMap.end() ; ++ iter ) {
    drawElement( renderContext, iter->second );
  }  
  
  drawEnd(renderContext);
}
Пример #7
0
// Buffer drawing
void Graphics::draw(const GraphicsData& v) {
    drawBegin();
    mBackend->draw(v);
    drawEnd();
}
Пример #8
0
//--------------------------------------------------------------
void pbVertexRender::draw()
{
	drawBegin();
    drawEnd();
	
}