コード例 #1
0
ファイル: PongGame.cpp プロジェクト: rzuniga64/cplusplus
void PongGame::draw() {
    drawNet();
    leftPaddle->draw();
    rightPaddle->draw();
    ball->draw();
    drawScore(leftScoreX, scoreY, leftScore);
    drawScore(rightScoreX, scoreY, rightScore);
}
コード例 #2
0
	/* check to see if there are three cards selected 
    * and if they are if they are a winning combination
    */
   bool checkForWinner(){
	   int c1_color, 
		   c1_number, 
		   c1_shape, 
		   c2_color, 
		   c2_number, 
		   c2_shape,
		   c3_color,
		   c3_number,
		   c3_shape,
		   count=0;
	   ltime=0;
	   for(int i=0;i<12;i++){
		  if(dek.isSelected(i)){
			 if(count==0){
				dek.getCardAttribute(i, c1_color, c1_shape, c1_number);
				count++;
			 }else if(count==1){
				dek.getCardAttribute(i, c2_color, c2_shape, c2_number);
				count++;
			 }else if(count==2){
				dek.getCardAttribute(i, c3_color, c3_shape, c3_number);
				count++;
			 }
		  }
	   }
       if(count!=3){
		   score-=30;
		   return false;
	   }else{
	       // std::cout << c1_color << c2_color << c3_color << c1_shape << c2_shape << c3_shape << c1_number << c2_number << c3_number << std::endl;        
   		   // I decided to calculate the score on the fly here, it is pretty messy
		   if(((c1_color == c2_color) && (c2_color == c3_color)) || ((c1_color != c2_color) && (c2_color != c3_color) && (c1_color != c3_color))){
			   if(((c1_number == c2_number) && (c2_number == c3_number)) || ((c1_number != c2_number) && (c2_number != c3_number) && (c1_number != c3_number))){
				  if(((c1_shape == c2_shape) && (c2_shape == c3_shape)) || ((c1_shape != c2_shape) && (c2_shape != c3_shape) && (c1_shape != c3_shape))){
					 // if the shapes are teh same add 5 else add 10
					 if((c1_shape == c2_shape) && (c2_shape == c3_shape)) score+=5;
					 else score+=10;
					 
					 // if the colors are the same add 5, else add 10
					 if((c1_color == c2_color) && (c2_color == c3_color)) score+=5;
					 else score+=10;
					 
					 // if the numbers are same add 5 else add 10
					 if((c1_number == c2_number) && (c2_number == c3_number)) score+=5;
					 else score+=10;
					 
					 drawScore();
                return true;
				  }
			   }
		   }
		   score-=30;
         drawScore();
		   return false;
	   }
	}
コード例 #3
0
ファイル: kyra_mr.cpp プロジェクト: AdamRi/scummvm-pink
void KyraEngine_MR::scoreIncrease(int count, const char *str) {
	int drawOld = 1;
	_screen->hideMouse();

	showMessage(str, 0xFF, 0xF0);
	const int x = getScoreX(str);

	for (int i = 0; i < count; ++i) {
		int oldScore = _score;
		int newScore = ++_score;

		if (newScore > _scoreMax) {
			_score = _scoreMax;
			break;
		}

		drawScoreCounting(oldScore, newScore, drawOld, x);
		if (_inventoryState)
			drawScore(0, 215, 191);
		_screen->updateScreen();
		delay(20, true);

		snd_playSoundEffect(0x0E, 0xC8);
		drawOld = 0;
	}

	_screen->showMouse();
}
コード例 #4
0
//--------------------------------------------------------------
void ofApp::draw()
{
	// TODO
	// Draw all game entities (bullets? players? effects?)
	for(int i = 0; i < asteroids.size(); i++) asteroids[i]->draw(debug);
	//for (Bullet* bullet : bullets) bullet->draw(debug);
	for (SpaceShip* player : players) player->draw(debug);	

	if(debug)
	{
		ofPushStyle();
		ofSetColor(255);
		ofDrawBitmapString(ofToString(ofGetFrameRate()), 20, 20);
		ofPopStyle();
	}
	drawScore();

	if (players.size() == 0) {
		ofPushStyle();
		ofSetColor(ofColor(255));

		ofDrawBitmapString("OMG! THE GAME IS OVER!", (ofGetWidth()/2)-100, (ofGetHeight())/2);
		if(ofToInt(Player1Score) > ofToInt(Player2Score)){ofDrawBitmapString("PLAYER 1 WINS!", (ofGetWidth()/2)-100, (ofGetHeight()/2)+20);}
		else{ofDrawBitmapString("PLAYER 2 WINS!", (ofGetWidth()/2)-100, (ofGetHeight()/2)+20);}
		ofDrawBitmapString("https://youtu.be/HaoySOGlZ_U?t=58s", (ofGetWidth()/2)-100, (ofGetHeight()/2)+40);
		ofDrawBitmapString("EXIT WITH ESC. BYE!", (ofGetWidth()/2)-100, (ofGetHeight()/2)+60);
		ofPopStyle();
	}

	
}
コード例 #5
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void refreshScore(tScore score)
{
    if (score == gScoreBar)
        return;
    
    gScoreBar = score;
    drawScore(score);
}
コード例 #6
0
ファイル: Game.cpp プロジェクト: marcorivm/opengl-pacman
void Game::draw(void)
{
	glViewport(x,y, width * 0.7, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1.5,28.5, 31.5, -1.5, -512, 512);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity() ;

	for (int i = 0; i < 31; i++)
	{
		for (int j = 0; j < 28; j++)
		{
			
			glPushMatrix();
				glTranslatef(j,i,0);
				switch (gameboard[i][j])
				{
				case 'd':
					dot->draw();
					break;
				case 'u':
					powerup->draw();
					break;
				case '0':
				case '9':
					 break;
				default:
					wallmanager->draw(gameboard[i][j]);
					break;
				}
			glPopMatrix();
		}
	}
	pacman->draw();
	ambusher->draw();
	chaser->draw();
	fickle->draw();
	stupid->draw();

	glViewport(width * 0.7 + x, 0 + y, width * 0.3, height);	
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-150,150, 500, -500, -512, 512);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
	
	glPushMatrix();
		glTranslatef(-50, -500, 0);
		drawScore();
		drawLives();
		drawLevel();
		//drawAuthor();
	glPopMatrix();
}
コード例 #7
0
ファイル: game_state.cpp プロジェクト: chadaustin/isugamedev
void
GameState::draw() {
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-.1, 1.1, 1.2, -.1, -1, 1);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  glClear(GL_COLOR_BUFFER_BIT);

  if (m_balls <= 0) {
    drawGameOver();
    return;
  }

  glColor3f(1, 1, 1);
  glBegin(GL_LINE_STRIP);
  glVertex2d(0, 0);
  glVertex2d(1, 0);
  glVertex2d(1, 1);
  glVertex2d(0, 1);
  glVertex2d(0, 0);
  glEnd();

  // draw the paddle
  glBegin(GL_QUADS);
  glVertex2d(m_paddle - .1, .95);
  glVertex2d(m_paddle + .1, .95);
  glVertex2d(m_paddle + .1, .98);
  glVertex2d(m_paddle - .1, .98);
  glEnd();

  // draw the ball
  glBegin(GL_POINTS);
  glVertex2d(m_ball.position.x, m_ball.position.y);
  glEnd();

  glBegin(GL_QUADS);

  // draw the blocks
  Block::List::iterator i = m_blocks.begin();
  for (; i != m_blocks.end(); ++i) {
    glColor(i->color);
    const Point2d& ul = i->location.upper_left;
    const Point2d& lr = i->location.lower_right;
    glVertex2d(ul.x, ul.y);
    glVertex2d(lr.x, ul.y);
    glVertex2d(lr.x, lr.y);
    glVertex2d(ul.x, lr.y);
  }

  glEnd();

  drawScore();
}
コード例 #8
0
//--------------------------------------------------------------
void testApp::draw(){
  ofRectangle rect;
  rect.set(0, 0, 600, 450);
  _bgLoop.draw(rect);
  _logoLoop.draw(rect);
  for (unsigned int i = 0; i < _stairs.size(); i++){
    _stairs[i]->draw(rect.x, rect.y, rect.width, rect.height);
  }
  drawScore(_easeScore);
}
コード例 #9
0
ファイル: Game.cpp プロジェクト: wmolicki/riverride
void CGame::drawBottomBar()
{
	//gray bar
	SDL_Rect menu = {0, 450, 800, 150 };
	SDL_SetRenderDrawColor(Window::mRenderer, 171, 171, 171, 0);
	SDL_RenderFillRect(Window::mRenderer, &menu);
	drawLives();
	drawScore();
	drawFuelGauge();
}
コード例 #10
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void drawBoard(void)
{
    tSquare square;
    
    for (square = MIN_SQUARE; square <= MAX_SQUARE; square++) {
        refreshSquare(square);
    }
    
    selectSquare(gSelectedSquare);
    moveMouseToSquare(gSelectedSquare);
    drawScore(gScoreBar);
}
コード例 #11
0
ファイル: main.cpp プロジェクト: mg-hannah/invaders
void drawScreen(void) {

    int x,y;
    SDL_Rect pos;

    // Draw the ship
    ship->draw();

    // Draw the aliens  
    for (x = 0; x < 5; x++) { 
        for (y = 0; y < 5; y++) { 
            aliens[x][y]->draw(screen);
        }
    }
    
    // Draw the missiles
    if (ship->missile->visible) {
        SDL_BlitSurface(ship->missile->img, NULL, screen, &ship->missile->pos);
    }

   
    for (y = 0; y < 5; y++) { 
        for (x = 0; x < 5; x++) { 
            if (aliens[x][y]->missile->visible) {
                SDL_BlitSurface(aliens[x][y]->missile->img, NULL, screen, &aliens[x][y]->missile->pos);
            }
        }
    }

    // Draw the shields
    for (x = 0; x < 4; x++) {
        shield[x]->draw();
    }

    // Draw the score-board
    drawScore();

    // Draw the player 'lives'
    pos.y = SCREEN_HEIGHT-ship->getHeight()-2;
    for (x=1; x < ship->getLives()+1; x++) {
        pos.x = SCREEN_WIDTH-(x*((ship->getWidth()+2)));
        SDL_BlitSurface(ship->getImage(), NULL, screen, &pos);
    }

    // Game over message
    if (gameOver) {
        drawGameOverMessage();
    }
}
コード例 #12
0
void Pong::render() {
    fbo.begin();
    ofClear(0);

    ofSetColor(255,255);

    drawCenter();
    drawScore();

    ofRect(ball);
    ofRect(player1);
    ofRect(player2);

    fbo.end();
}
コード例 #13
0
ファイル: draw.cpp プロジェクト: PolygonAndPixel/SpaceFighter
bool drawGame()
{
    arduboy.clear();
    drawScore();
    drawLives();
    drawEnemies();
    if(player.alive)
        drawPlayer();
    drawSupply();
    drawBullets();
    drawStars();
    bool finished = drawExplosions();
    arduboy.display();
    return finished;
}
コード例 #14
0
ファイル: Game.cpp プロジェクト: poseidon4o/NN-aim
void Game::draw()
{
	m_sdl->clear();
	for (int i = 0; i < 2; ++i)
		m_players[i]->draw(m_sdl);
	for (int i = 0; i < 2; ++i)
	{
		if (m_bullets[i].active)
			m_sdl->drawTex(m_texBullet, m_bullets[i].pos);
	}
	m_sdl->drawLine(Vector2(playerFieldWidth, 0.f), Vector2(playerFieldWidth, height), 0xff, 0xff, 0xff);
	m_sdl->drawLine(Vector2(playerFieldWidth + bufferZoneSize, 0.f), Vector2(playerFieldWidth + bufferZoneSize, height), 0xff, 0xff, 0xff);

	drawScore();
	m_sdl->update();
}
コード例 #15
0
ファイル: View.cpp プロジェクト: ggobbe/pacman-3d
// Définit le modèle pour affichage à l'écran
void View::display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Initialisation du buffer de couleur à la couleur de fond


	// Viewport contenant les informations sur la partie en cours
	viewportInfos();
	if(model->getLifes() < 0) {
		model->stopGame();
		gameOver();
	}
	else {
		drawScore();
		drawLifes();
	}

	// Viewport contenant les contrôles souris (boutons)
	viewportControls();
	drawMouseControls();
	drawButton("Reset",100);
	drawButton("Close",150);
	drawButton("View", 200);



	// Viewport contenant le plateau de jeu
	glEnable(GL_DEPTH_TEST);

	initLights();

	viewportWorld(); // Définit une viewport et ses caractéristiques de projection
	drawWorld();
	drawPills();
	drawPacMan();
	drawGhosts();

	glDisable(GL_LIGHT0);
	glDisable(GL_LIGHT1);
	glDisable(GL_LIGHT2);
	glDisable(GL_LIGHT3);
	glDisable(GL_LIGHTING);	// nuit !
	glDisable(GL_DEPTH_TEST);


	glutSwapBuffers(); // Car on travaille en mode "double buffer", cf. main.cpp
}
コード例 #16
0
void ofApp::draw()
{
	// DRAWING TIME
	// just render everything the server sent: players, asteroids, the scores and the powerup !
	for(int i = 0; i < asteroids.size(); i++) asteroids[i]->draw(debug);
	for (SpaceShip* player : players) player->draw(debug);	
	powerup.draw(debug);

	if(debug)
	{
		ofPushStyle();
		ofSetColor(255);
		ofDrawBitmapString(ofToString(ofGetFrameRate()), 20, 20);
		ofPopStyle();
	}

	drawScore();
}
コード例 #17
0
void WorldDrawer3d::displayCallbackFunction(){
	//Render objects
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	// Save the initial ModelView matrix before modifying ModelView matrix
	glPushMatrix();

	// Tramsform view
	glTranslatef(1.5f, 0, -eyeDistance);
	glRotatef(viewAngleY, 1, 0, 0);   // Rotate left or right
	glRotatef(viewAngleX, 0, 1, 0);   // Rotate up or down

	// Draw cs_basis coord system
	cs_basis.draw(2);

	// Draw objects in cs_basis
	for(unsigned int j=0;j<cs_basis.objects.size();j++){
		cs_basis.objects[j]->draw();
	}

	// Draw each used coord system
	for(unsigned int i = 0; i < cs_used.size(); ++i)
	{
		//draw used coord system
		cs_used[i]->draw(1);

		//draw objects
		for(unsigned int j = 0; j < cs_used[i]->objects.size(); ++j)
		{
			cs_used[i]->objects[j]->draw();
		}
	}

	// Restore the ModelView matrix after drawing objects
	glPopMatrix();


	// Draw text here
	drawScore(-25, 22, 3, Color(0.961f, 0.871f, 0.702f));
	drawWin(-25, 20, 3, Color(0.961f, 0.871f, 0.702f));

	//swap buffers
	glutSwapBuffers();
}
コード例 #18
0
ファイル: ballduino.c プロジェクト: benjmyers/Ballduino
/* Game play loop */
void  loop(){
  
  if (continueGame){                                                      // If the game is still in play
    drawFrame();                                                          // Draw the frame
    drawScore();                                                          // Draw the score
    movePaddle();                                                         // Update the location of the paddle
    boolean paddleCollision = checkPaddleCollision();                     // Determine if the ball has hit the paddle or block
    boolean blockCollision = checkBlockCollision();
    if(score == numBlocks)                                                // If the score is equivalent to the number of blocks, game is over
      winner();                                                           // Display message to user
    else{                                                                 // The game is still in play
      if(paddleCollision || blockCollision)                               // Redraw screen to draw over any collisions
        drawFrame();
      delay(50);                                                          // Slight delay
      continueGame = updatePos();                                         // Update the position of the ball
    }
  }
  else                                                                    // The game is over, the ball fell off the screen. Display message to user.
    gameOver();
}
コード例 #19
0
ファイル: exampleGame.c プロジェクト: McCzarny/Snake
/*****************************************************************************
 *
 * Description:
 *    Check if time to update score
 *
 ****************************************************************************/
static void
checkScore(void)
{
  tS32 i,j,k;
  
  for (j=0; j<BOARD_HEIGHT; j++)
  {
    //check if one row is full
    if(full(j))
    {
      //if so, erase that row...
      for(k=j; k>0; k--)
        for(i=0; i<BOARD_WIDTH; i++)
          board[i][k] = board[i][k-1];
          
      //and update score
      score++;
      drawScore();
    }
  }
}
コード例 #20
0
ファイル: main.cpp プロジェクト: kujenga/dodge
void onDisplay()
{
    // draw here
    glClearColor(0.4f, 0.7f, 0.9f, 0.5f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    drawGround();
    
    if (_gameMode == selection) {
        // show
        drawSelection();
        
        glutSwapBuffers();
        return;
    }
    
    for (int i = 0; i < NUM_BLOCKS; i++) {
        float px = 0.9;
        float py = _player->yOffset;
        if (_blocks[i]->hasCollided(px - PLAYER_SIZE, py + PLAYER_SIZE, px + PLAYER_SIZE, py - PLAYER_SIZE)) {
            if (_alive) {
                _alive = false;
                _deathTime = glutGet(GLUT_ELAPSED_TIME) * 0.001;
            }
        } else {
            _blocks[i]->draw();
        }
        
    }
    if (_alive) {
        _player->draw(_weightedMousePos);
    } else {
        float t_death = glutGet(GLUT_ELAPSED_TIME) * 0.001 - _deathTime;
        _player->drawDeath(_weightedMousePos, t_death);
    }
    
    drawScore();
    
    glutSwapBuffers();
}
コード例 #21
0
ファイル: CColossNormal.cpp プロジェクト: kretzmoritz/Archive
void CColossNormal::run()
{
	getInput();
	scaleButtons();
	drawButtons();

	if(!getBoss())
	{
		drawScore();
	}
	
	tweenBlock();

	// Check for block collision
	hasBlockFinished();

	glGraphics->Draw(this);
	CColoss::run(); // Call to super function

	// Boss interface functionality
	manageBossInterface();
}
コード例 #22
0
ファイル: gltron.c プロジェクト: BackupTheBerlios/gltron-svn
void drawGame() {
  GLint i;
  gDisplay *d;
  Player *p;

  polycount = 0;
  glClearColor(.0, .0, .0, .0);
  glDepthMask(GL_TRUE);
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glDepthMask(GL_FALSE);

  for(i = 0; i < vp_max[ game->settings->display_type]; i++) {
    p = &(game->player[ game->settings->content[i] ]);
    if(p->display->onScreen == 1) {
      d = p->display;
      glViewport(d->vp_x, d->vp_y, d->vp_w, d->vp_h);
      drawCam(p, d);
      drawScore(p, d);
      if(game->settings->show_ai_status)
	if(p->ai->active == 1)
	  drawAI(d);
    }
  }

  if(game->settings->show_2d > 0)
    drawDebugTex(game->screen);
  if(game->settings->show_fps)
    drawFPS(game->screen);

  /*
  if(game->settings->show_help == 1)
    drawHelp(game->screen);
  */

  /* printf("%d polys\n", polycount); */
}
コード例 #23
0
ファイル: UI.cpp プロジェクト: ChrisVasShiver/NSPacman
void UI::update(std::vector<GameObjectStruct> objects)
{
	// Clear the current renderer.
	SDL_RenderClear(renderer);

	// Draw the walls.
	drawBackground(map);

	// Draw the score.
	drawScore();

	// Draw the lives.
	drawLives();

	// Loop through all the objects and draw them.
	for(auto &element : objects)
	{
		SDL_Rect dst = {element.x*24, element.y*24, 24,24};
		SDL_RenderCopy(renderer, sheet, &clips[element.type][element.dir], &dst);
	}

	// Update the screen.
	SDL_RenderPresent(renderer);
}
コード例 #24
0
ファイル: game.c プロジェクト: johnlobo/Amsthrees
//////////////////////////////////////////////////////////////////
// game
//
//
//
// Returns:
//    void
//
void game(void) {
    u8 moved;
    u8 *pvmem;
    u8 dir = 0;


    initGame();

    // Clear Screen
    clearScreen();

    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 61, 72);
    cpct_drawSprite(logo_small, pvmem, 15, 55);

    //drawFrame(2, 1, 49, 182);
    drawTable();
    drawText("NEXT", 62, 2, 0);
    printCells();
    highestCardGame = getHighestCard();
    drawText("HIGHEST", 59, 138, 0);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
    cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

    moved = 0;
    // Loop forever
    while (1) {
        delay(24);

        rotatedCells = 0;

        if ((cpct_isKeyPressed(Joy0_Right)) || (cpct_isKeyPressed(keys.right))) {
            if (rotateCellsRight() > 0) {
                dir = RIGHT;
                addRandomCellTurn(RIGHT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Left)) || (cpct_isKeyPressed(keys.left))) {
            if (rotateCellsLeft() > 0) {
                dir = LEFT;
                addRandomCellTurn(LEFT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Down)) || (cpct_isKeyPressed(keys.down))) {
            if (rotateCellsDown() > 0) {
                dir = DOWN;
                addRandomCellTurn(DOWN);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Up)) || (cpct_isKeyPressed(keys.up))) {
            if (rotateCellsUp() > 0) {
                dir = UP;
                addRandomCellTurn(UP);
                moved = 1;
            }

        } else if ( cpct_isKeyPressed(keys.music)) {
            if (!playing) {
                activateMusic();
            } else {
                deActivateMusic();
            }
        } else if (cpct_isKeyPressed(keys.abort))
            break;

        if (moved) {
            //Empty the rotated cells buffer after ending the animation
            //cpct_waitVSYNC();

            if (changedCards.number > 0) {
                animate(dir);
                resetChangedCards();

                highestCardGame = getHighestCard();
                pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
                cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

                // Play sound Effect
                cpct_akp_SFXPlay(3, 14, 50 + (highestCardGame * 2), 1, 0, AY_CHANNEL_A);

            }

            moved = 0;
            if (anyMovesLeft() == 0) {
                cpct_akp_stop();
                cpct_akp_musicInit(song05);
                cpct_akp_musicPlay();
                drawScore();
                wait4UserKeypress();
                drawFrame(14, 60, 68, 130);
                drawText("NO MORE MOVES", 20, 70, 1);
                drawText("GAME OVER", 22, 90, 1);
                sprintf(aux_txt, "SCORE  %d", score);
                drawText(aux_txt, 22, 110, 1);
                delay(200);
                wait4UserKeypress();
                setHighScore(score);
                drawScoreBoard();
                cpct_akp_stop();
                cpct_akp_musicInit(song02);
                cpct_akp_musicPlay();
                break;
            }
        }

    }
}
コード例 #25
0
ファイル: noiz2sa.c プロジェクト: kazuya-watanabe/noiz2sa
static void draw() {
  switch ( status ) {
  case TITLE:
    // Draw background.
    drawBackground();
    drawFoes();
    drawBulletsWake();
    blendScreen();
    // Draw forground.
    drawBullets();
    drawScore();
    drawTitleMenu();
    break;
  case IN_GAME:
    // Draw background.
    drawBackground();
    drawBonuses();
    drawFoes();
    drawBulletsWake();
    drawFrags();
    blendScreen();
    // Draw forground.
    drawShots();
    drawShip();
    drawBullets();
    drawScore();
    break;
  case GAMEOVER:
    // Draw background.
    drawBackground();
    drawFoes();
    drawBulletsWake();
    drawFrags();
    blendScreen();
    // Draw forground.
    drawShots();
    drawBullets();
    drawScore();
    drawGameover();
    break;
  case STAGE_CLEAR:
    // Draw background.
    drawBackground();
    drawBonuses();
    drawFrags();
    blendScreen();
    // Draw forground.
    drawShots();
    drawShip();
    drawScore();
    drawStageClear();
    break;
  case PAUSE:
    // Draw background.
    drawBackground();
    drawBonuses();
    drawFoes();
    drawBulletsWake();
    drawFrags();
    blendScreen();
    // Draw forground.
    drawShots();
    drawShip();
    drawBullets();
    drawScore();
    drawPause();
    break;
  }
}
コード例 #26
0
ファイル: menu.cpp プロジェクト: Fyre91/scummvm
// Never set the current input handler to the CPauseMenu.
PauseMenu::PauseMenu() : GameMenu(kPauseMenuID), _pauseBackground(0), _saveButton(0), _restoreButton(0),
		_walkthroughButton(0), _continueButton(0), _soundFXLevel(0), _ambienceLevel(0), _quitButton(0),
		_largeSelect(0), _smallSelect(0) {
	PegasusEngine *vm = (PegasusEngine *)g_engine;

	_pauseBackground.initFromPICTFile("Images/Pause Screen/PausScrn.pict", true);

	if (!vm->isDemo()) {
		Surface numbers;
		numbers.getImageFromPICTFile("Images/Pause Screen/Numbers.pict");
		vm->_gfx->setCurSurface(_pauseBackground.getSurface());
		drawScore(GameState.getTotalScore(), kMaxTotalScore,
				Common::Rect(kPauseScoreLeft, kPauseScoreTop, kPauseScoreRight, kPauseScoreBottom), &numbers);
		vm->_gfx->setCurSurface(vm->_gfx->getWorkArea());
	}

	_pauseBackground.setDisplayOrder(kPauseMenuOrder);
	_pauseBackground.moveElementTo(kPauseLeft, kPauseTop);
	_pauseBackground.startDisplaying();
	_pauseBackground.show();

	if (!vm->isDemo()) {
		_saveButton.initFromPICTFile("Images/Pause Screen/SaveGame.pict");
		_saveButton.setDisplayOrder(kSaveGameOrder);
		_saveButton.moveElementTo(kSaveGameLeft, kSaveGameTop);
		_saveButton.startDisplaying();

		_restoreButton.initFromPICTFile("Images/Pause Screen/Restore.pict");
		_restoreButton.setDisplayOrder(kRestoreOrder);
		_restoreButton.moveElementTo(kPauseRestoreLeft, kPauseRestoreTop);
		_restoreButton.startDisplaying();

		_walkthroughButton.initFromPICTFile("Images/Pause Screen/Walkthru.pict");
		_walkthroughButton.setDisplayOrder(kWalkthruOrder);
		_walkthroughButton.moveElementTo(kWalkthruLeft, kWalkthruTop);
		_walkthroughButton.startDisplaying();

		if (GameState.getWalkthroughMode())
			_walkthroughButton.show();
	}

	_continueButton.initFromPICTFile("Images/Pause Screen/Continue.pict");
	_continueButton.setDisplayOrder(kContinueOrder);
	_continueButton.moveElementTo(kPauseContinueLeft, kPauseContinueTop);
	_continueButton.startDisplaying();

	_soundFXLevel.setDisplayOrder(kSoundFXOrder);
	_soundFXLevel.setBounds(Common::Rect(kSoundFXLeft, kSoundFXTop, kSoundFXRight, kSoundFXBottom));
	_soundFXLevel.startDisplaying();
	_soundFXLevel.show();
	_soundFXLevel.setSoundLevel(vm->getSoundFXLevel());

	_ambienceLevel.setDisplayOrder(kAmbienceOrder);
	_ambienceLevel.setBounds(Common::Rect(kAmbienceLeft, kAmbienceTop, kAmbienceRight, kAmbienceBottom));
	_ambienceLevel.startDisplaying();
	_ambienceLevel.show();
	_ambienceLevel.setSoundLevel(vm->getAmbienceLevel());

	_quitButton.initFromPICTFile("Images/Pause Screen/Quit2MM.pict");
	_quitButton.setDisplayOrder(kQuitToMainMenuOrder);
	_quitButton.moveElementTo(kQuitLeft, kQuitTop);
	_quitButton.startDisplaying();

	_largeSelect.initFromPICTFile("Images/Pause Screen/SelectL.pict", true);
	_largeSelect.setDisplayOrder(kPauseLargeHiliteOrder);
	_largeSelect.startDisplaying();

	_smallSelect.initFromPICTFile("Images/Pause Screen/SelectS.pict", true);
	_smallSelect.setDisplayOrder(kPauseSmallHiliteOrder);
	_smallSelect.startDisplaying();

	_menuSelection = (vm->isDemo()) ? kPauseMenuContinue : kPauseMenuSave;

	updateDisplay();
}
コード例 #27
0
ファイル: Main.cpp プロジェクト: madmaurice/zombieattack
int main(int argc, char** argv) {

  sf::RenderWindow App(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32),
      "Olivier in zombie land");

  App.SetFramerateLimit(60);
  bool game_over = false;

  sf::Image BackgroundImage;
  sf::Sprite BackgroundSprite;

  if(!BackgroundImage.LoadFromFile("../resources/backgrounds/Floor.png")) {
    return EXIT_FAILURE;
  }
  BackgroundSprite.SetImage(BackgroundImage);

  sf::Image predDeathImg;
  sf::Sprite predDeathSprite;
  if(!predDeathImg.LoadFromFile("../resources/sprites/predDeath.png")) {
    return EXIT_FAILURE;
  }
  predDeathSprite.SetImage(predDeathImg);
  predDeathSprite.Resize(predDeathImg.GetWidth() * 2, predDeathImg.GetHeight() * 2);
  predDeathSprite.SetPosition(50, 300);

  std::vector<Object*> objects;

  Player *player = new Player; 
  objects.push_back(player);


  SpatialHash grid;

  sf::Font MyFont;
  if (!MyFont.LoadFromFile("../resources/fonts/comics.ttf", 50)) {
    std::cout << "Fail" << std::endl;
    return EXIT_FAILURE;
  }

  sf::Font megaFont;
  if (!megaFont.LoadFromFile("../resources/fonts/megaman_2.ttf", 50)) {
    std::cout << "Fail megaman font" << std::endl;
    return EXIT_FAILURE;
  }

  sf::String waveText;
  waveText.SetFont(megaFont);
  waveText.SetColor(sf::Color::Red);
  waveText.SetSize(75.f);
  waveText.SetPosition(225, SCREEN_HEIGHT/2 - waveText.GetSize());

  float waveTime = 0;
  int waveNumber = 0;
  bool newWave = true;

  int numBoss = 1;
  int killPerWave = 15;
  int killThisWave = 0;

  sf::String Timer, KillCount, HP, GameOverString, Score;


  Timer.SetFont(MyFont);
  Timer.SetColor(sf::Color(0, 0, 255));
  Timer.SetSize(50.f);
  Timer.SetPosition(SCREEN_WIDTH/2 - Timer.GetSize()/2 - 75, 10.f);

  KillCount.SetFont(MyFont);
  KillCount.SetColor(sf::Color(255, 0, 0));
  KillCount.SetSize(50.f);
  KillCount.SetPosition(SCREEN_WIDTH - 250.f, 10.f);

  HP.SetFont(MyFont);
  HP.SetColor(sf::Color(0, 255, 0));
  HP.SetSize(50.f);
  HP.SetPosition(25.f, 10.f);

  float running_time = 0.0;
  float last_time = 0.0;

  std::srand(std::time(NULL));

  int spawn_rate = 1;
  float spawn_time = 0.0;

  sf::SoundBuffer predBuffer;
  sf::Sound predSound;

  if (!predBuffer.LoadFromFile("../resources/sfx/predator.ogg")) {
    std::cout << "Error loading sfx" << std::endl; 
  }
  predSound.SetBuffer(predBuffer);

  //Title stuff
  Title title(App);

  GameState gameState = INTRO;

  
  //Title loop
  while (App.IsOpened()) {

    //Process events
    sf::Event Event;

    //Window closed
    while (App.GetEvent(Event)) 
    {
      if(Event.Type == sf::Event::Closed)
        App.Close();

      //Escape key pressed
      if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))	
        App.Close();
    }

    if (title.showTitle())
    {
      App.Clear();
      title.update();
      App.Display();
      continue;
    }
    else
    {
      gameState = WAVE;
      break;
    }
  }


  Music::GetInstance().playNormal();

  ParticleSystem particleSystem(SCREEN_WIDTH, SCREEN_HEIGHT);
  particleSystem.setDissolve( true );
  particleSystem.setDissolutionRate( 1 );
	//particleSystem.setGravity(2.0f, 1.2f );

  //Peaking
  Peak peaker(App);

  //Effect
  EffectSystem& effectSystem = EffectSystem::GetInstance();

  //Start game loop
  while (App.IsOpened()) {

    //Process events
    sf::Event Event;

    //Window closed
    while (App.GetEvent(Event)) 
    {
      if(Event.Type == sf::Event::Closed)
        App.Close();

      //Escape key pressed
      if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))	
        App.Close();

      if(Event.Key.Code == sf::Key::F1) {

        sf::Image Screen = App.Capture();
        Screen.SaveToFile("../screenshots/screenshot.jpg");
      }      
    }

    if (player->getHealth() > 0)
    {
        float ElapsedTime = App.GetFrameTime();
        running_time += ElapsedTime;


        switch (gameState)
        {
            case INTRO:
                break;
            case WAVE:
            {
                if (newWave)
                {
                  waveNumber++;
                  waveTime = running_time;
                  newWave = false;

                  std::stringstream wave;
                  wave << waveNumber;
                  waveText.SetText("Wave " + wave.str());

                  killPerWave += 10 * waveNumber;
                  killThisWave = 0;
                }

                if (killThisWave > killPerWave && gameState == WAVE)
                {
                    gameState = BOSS;

                    //Create Boss
                    for (int i = 0; i < numBoss; i++) {
                      objects.push_back(new Boss(particleSystem, sf::Randomizer::Random(200, 600), sf::Randomizer::Random(200, 500), 40));
                    }

                    newWave = true;
                    if (!player->isRageMode())
                    {
                      Music::GetInstance().stop();
                      Music::GetInstance().playBoss();
                    }
                    break;
                }

                if (!player->isRageMode() && Music::GetInstance().getSong() != "dark_encounter.ogg")
                {
                  Music::GetInstance().stop();
                  Music::GetInstance().playNormal();
                }

                //Increase spawn rate every 30 seconds
                if (running_time - spawn_time > 30) {
                    spawn_rate++;
                    spawn_time = running_time;
                }

                //Spawn Enemy every 2 seconds
                if (running_time - last_time > 2.0) {
                    for (int i = 0; i < spawn_rate; i++) {

                    objects.push_back(new Enemy(particleSystem, rand() % (SCREEN_WIDTH-100) + 40, rand() % (SCREEN_HEIGHT-100) + 40));
                    }
                    last_time = running_time;
                }

                grid.setup(objects);

                //Get elapsed time

                //Handle input
                player->handleInput(App, ElapsedTime, objects, grid);

                App.Draw(BackgroundSprite);

                //Draw body part over floor
                effectSystem.drawBg(App);

                drawScore(App, player, KillCount, Timer, HP, Score, static_cast<int> (running_time));

                player->update(App);
                player->draw(App);

                //Move and draw all object (except bullets)
                for (unsigned int i = 0; i < objects.size(); ++i) {

                    //Aggro is only for enemy
                    objects[i]->aggro(*player, ElapsedTime, objects, grid.getNearby(objects[i]), running_time);

                    //Don't draw player here
                    if (!objects[i]->isPlayer())
                    App.Draw(objects[i]->getSprite());
                }

                //Draw then move bullets
                for(unsigned int i = 0; i < player->bullets.size(); ++i) {
                    App.Draw(player->bullets[i]->getSprite());
                    player->bullets[i]->move(ElapsedTime, objects, grid.getNearby(player->bullets[i]), player->bullets, i);
                    //player->bullets[i]->drawEdge(App);
                }

                //Check if player kill a zombie
                for(unsigned int i = 0; i < objects.size(); ++i) {
                    if (!objects[i]->alive(objects, i, running_time))
                    {
                        player->addKill();
                        killThisWave++;
                    }
                }

                break;
            }
            case BOSS:
                if (newWave)
                {
                  waveTime = running_time;
                  newWave = false;
                  waveText.SetText("BOSS");
                }

                if (!player->isRageMode() && Music::GetInstance().getSong() != "vbogey.ogg")
                {
                  Music::GetInstance().stop();
                  Music::GetInstance().playBoss();
                }

                grid.setup(objects);

                //Handle input
                player->handleInput(App, ElapsedTime, objects, grid);

                App.Draw(BackgroundSprite);

                //Draw body part over floor
                effectSystem.drawBg(App);

                drawScore(App, player, KillCount, Timer, HP, Score, static_cast<int> (running_time));

                player->update(App);
                player->draw(App);

                //Move and draw all object (except bullets)
                for (unsigned int i = 0; i < objects.size(); ++i) {

                    //Aggro is only for enemy
                    objects[i]->aggro(*player, ElapsedTime, objects, grid.getNearby(objects[i]), running_time);

                    //Don't draw player here
                    if (!objects[i]->isPlayer())
                    App.Draw(objects[i]->getSprite());
                }

                //Draw then move bullets
                for(unsigned int i = 0; i < player->bullets.size(); ++i) {
                    App.Draw(player->bullets[i]->getSprite());
                    player->bullets[i]->move(ElapsedTime, objects, grid.getNearby(player->bullets[i]), player->bullets, i);
                    //player->bullets[i]->drawEdge(App);
                }
                
                //Check if player kill a zombie
                for(unsigned int i = 0; i < objects.size(); ++i) {
                    if (!objects[i]->alive(objects, i, running_time))
                    {
                        player->addKill();
                    }
                }

                //if objects contain only player
                if (objects.size() == 1)
                {
                  gameState = WAVE;
                  newWave = true;

                  //Increase number of Boss every 5 waves
                  if (waveNumber % 5 == 0)
                  {
                    numBoss++;
                  }
                  if (!player->isRageMode())
                  {
                    Music::GetInstance().stop();
                    Music::GetInstance().playNormal();
                  }
                }

                break;
        }

        grid.clear();

        particleSystem.remove();
        particleSystem.update();
        particleSystem.render();

        effectSystem.update(App.GetFrameTime());
        effectSystem.draw(App);

        App.Draw(particleSystem.getSprite());

        //Peaking
        peaker.update();

        if (running_time - waveTime <= 1.5)
        {
          App.Draw(waveText);
        }

        //Diplay window contents on screen
        App.Display();
    }

    //Dead
    else
    {
      if (player->playDeath(App))
      {
        App.Display();
      }
      else if (game_over)  {
        App.Clear();
        App.Draw(predDeathSprite);
        App.Draw(GameOverString);
        App.Draw(Timer);
        App.Draw(KillCount);
        App.Draw(Score);
        App.Display();
      }

      else {
        game_over = true;
        Music::GetInstance().stop();

        //play game over song
        Music::GetInstance().playGameOver();

        //Stay there until credit end
        showCredits(App);

        GameOverString.SetFont(MyFont);
        GameOverString.SetColor(sf::Color(255, 255, 0));
        GameOverString.SetSize(100.f);
        GameOverString.SetPosition(SCREEN_WIDTH/2 -
            GameOverString.GetSize()/2 - 225,
            SCREEN_HEIGHT/2 - 200);

        GameOverString.SetText("Game Over");

        Timer.SetFont(MyFont);
        Timer.SetColor(sf::Color(255, 255, 0));
        Timer.SetSize(50.f);
        Timer.SetPosition(SCREEN_WIDTH/2 - Timer.GetSize()/2 - 75,
            SCREEN_HEIGHT/2);

        KillCount.SetFont(MyFont);
        KillCount.SetColor(sf::Color(255, 255, 0));
        KillCount.SetSize(50.f);
        KillCount.SetPosition(SCREEN_WIDTH/2 - KillCount.GetSize()/2 - 80,
            SCREEN_HEIGHT/2 + 100);

        Score.SetFont(MyFont);
        Score.SetColor(sf::Color(255, 255, 0));
        Score.SetSize(50.f);

        Score.SetPosition(SCREEN_WIDTH/2 - KillCount.GetSize()/2 - 80,
            SCREEN_HEIGHT/2 + 200);

        Music::GetInstance().stop();
        predSound.Play();
      }    
    }
  }
  return 0;      
}
コード例 #28
0
ファイル: lines.c プロジェクト: VWarlock/OldLines
void drawScore1() {
  char buf[6];
  buf[5] = 0;
  i2s(buf, score);
  drawScore(score, buf);
}
コード例 #29
0
ファイル: menu.cpp プロジェクト: Fyre91/scummvm
void DeathMenu::drawAllScores() {
	Surface numbers;
	numbers.getImageFromPICTFile("Images/Death Screens/Numbers.pict");

	Common::Rect scoreBounds;
	GameScoreType caldoriaTotal = 0;

	switch (_deathReason) {
	case kDeathCardBomb:
	case kDeathShotBySinclair:
	case kDeathSinclairShotDelegate:
	case kDeathNuclearExplosion:
	case kDeathGassedInNorad:
	case kDeathWokeUpNorad:
	case kDeathArrestedInNorad:
	case kDeathSubDestroyed:
	case kDeathRobotThroughNoradDoor:
	case kDeathRobotSubControlRoom:
	case kDeathWrongShuttleLock:
	case kDeathArrestedInMars:
	case kDeathRunOverByPod:
	case kDeathDidntGetOutOfWay:
	case kDeathReactorBurn:
	case kDeathDidntFindMarsBomb:
	case kDeathDidntDisarmMarsBomb:
	case kDeathNoMaskInMaze:
	case kDeathNoAirInMaze:
	case kDeathGroundByMazebot:
	case kDeathMissedOreBucket:
	case kDeathDidntLeaveBucket:
	case kDeathRanIntoCanyonWall:
	case kDeathRanIntoSpaceJunk:
	case kDeathDidntStopPoison:
	case kDeathArrestedInWSC:
	case kDeathHitByPlasma:
	case kDeathShotOnCatwalk:
	case kPlayerWonGame:
		caldoriaTotal += kMaxCaldoriaTSAScoreAfter;
		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5,
				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5 + kDeathScreenScoreHeight);
		drawScore(GameState.getGandhiScore(), kMaxGandhiScore, scoreBounds, &numbers);

		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
		drawScore(GameState.getWSCScore(), kMaxWSCScore, scoreBounds, &numbers);

		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
		drawScore(GameState.getNoradScore(), kMaxNoradScore, scoreBounds, &numbers);

		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
		drawScore(GameState.getMarsScore(), kMaxMarsScore, scoreBounds, &numbers);
		// fall through
	case kDeathFallOffCliff:
	case kDeathEatenByDinosaur:
	case kDeathStranded:
	case kDeathShotByTSARobots:
		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert,
				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert + kDeathScreenScoreHeight);
		drawScore(GameState.getPrehistoricScore(), kMaxPrehistoricScore, scoreBounds, &numbers);
		// fall through
	case kDeathUncreatedInCaldoria:
	case kDeathUncreatedInTSA:
		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop, kDeathScreenScoreLeft + kDeathScreenScoreWidth,
				kDeathScreenScoreTop + kDeathScreenScoreHeight);
		caldoriaTotal += kMaxCaldoriaTSAScoreBefore;
		drawScore(GameState.getCaldoriaTSAScore(), caldoriaTotal, scoreBounds, &numbers);

		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6,
				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6 + kDeathScreenScoreHeight);

		drawScore(GameState.getTotalScore(), kMaxTotalScore, scoreBounds, &numbers);
		break;
	}
}
コード例 #30
0
void drawGameScreen() {
    clear();
    //draw exterior of game
    drawBox(10, 3, 44, 34, 0);
    
    //draw path walls
    drawBox(10, 7, 11, 3, 0);
    drawBox(18, 7, 4, 14, 0);
    drawBox(18, 18, 16, 3, 0);
    drawBox(31, 7, 4, 14, 0);
    drawBox(31, 7, 18, 3, 0);
    drawBox(46, 7, 4, 24, 0);
    drawBox(19, 28, 30, 3, 0);
    drawBox(19, 28, 4, 9, 0);

    //fix up the corners
    clearPath();
    fixCorners();

    //add beginning and ending chars
    mvaddch(8, 8, '>');
    mvaddch(37, 21, ACS_DARROW);

    //draw and fill the purchase portion of the screen
    attron(COLOR_PAIR(0));
    drawPurchaseArea();
    basicSetupScreen(1);
    updateScore(0);
    attroff(COLOR_PAIR(0));
    drawTowerExplain();

    //load arrays for drawing
    TowerArray* theTowerList = getTowerArray("assets/towersLevel1.txt");
    Path* thePath = getPathArray("assets/path.txt");
    UnitListHeader * unitList = malloc(sizeof(UnitListHeader));
    int moneyAmount = STARTINGMONEY;
    initializeList(unitList);
    drawUnitTypes(unitList);
    int theScore = 0;

    drawTowers(theTowerList);

    //go to entering unit purchases (gives control back to user)
    selectUnitsInterface(thePath,unitList,&moneyAmount,theTowerList,&theScore);

    //get lowest score of highscores
    ScoreHead scores;
    scores.size = 0;
    scores.first = NULL;
    ScoreNode * currScore = NULL;
    readScores(&scores);
    currScore = scores.first;
    int numScores = 1;
    int highestScore = 0;

    while ((currScore->next != NULL) && (numScores < 9)) { 
        numScores += 1;
        currScore = currScore->next;
    }

    highestScore = -1;
    if (numScores > 8 && currScore != NULL) {
        highestScore = currScore->score;
    }

    char * enterName;
    if (theScore > highestScore) {
        enterName = drawScore(theScore,1);
        if (enterName != NULL) {
            addScore(&scores, enterName, theScore);
            writeScores(&scores);
        }
    } else {
        drawScore(theScore,0);
    }

    if (scores.size > 0) destroyScores(&scores);

}