Esempio n. 1
0
void TemplateTrack::drawTemplate(QPainter* painter, QRectF& clip_rect, double scale, bool on_screen, float opacity) const
{
	Q_UNUSED(clip_rect);
	Q_UNUSED(scale);
	
	painter->save();
	painter->setOpacity(opacity);
	drawTracks(painter, on_screen);
	drawWaypoints(painter);
	painter->restore();
}
Esempio n. 2
0
int main(int argc, char **argv) {
    //set up our main SDL objects:
    SDL_Init( SDL_INIT_VIDEO );
    SDL_Surface* screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_HWSURFACE | SDL_DOUBLEBUF );
    SDL_WM_SetCaption( WINDOW_TITLE, 0 );
    SDL_Event event;
    std::vector< Waypoint* >* path = new std::vector< Waypoint* >();
    path->push_back( new Waypoint{ 1.4, 500, 250 } );
    path->push_back( new Waypoint{ 1.4, 400, 400 } );
    path->push_back( new Waypoint{ 1.4, 200, 300 } );
    path->push_back( new Waypoint{ 1.4, 300, 150 } );
    bool gameRunning = true; //lets us exit the game loop
    GoState* goState = new GoState( path );
    Robot* robot = new Robot( goState, 100, 100 );
    MapDrawer* drawer = new MapDrawer( screen );

    double nodeAnimationTheta = 0;



    while (gameRunning) { //the game loop
        //event checker:
        if (SDL_PollEvent(&event)) { //SDL_PollEvent will return 1 if the targeted event has occured
            //quit if we made event an SDL_QUIT event.
            if (event.type == SDL_QUIT) {
                gameRunning = false;
            }
        }

        //clear surfaces background:
        SDL_FillRect(screen, NULL, 0x0);
        drawWaypoints( drawer, path, nodeAnimationTheta );
        robot->draw( drawer );
        robot->update();

        SDL_Flip(screen);
        nodeAnimationTheta+=0.01;
    }

    SDL_Quit();
    return 0;
}
Esempio n. 3
0
/**  This function sets the view to be drawn to the window,
*  and draws everything related to state. 
*/
void GameStatePlay::draw(const float delta_time) {  
	//sf::Context context;

	this->game->game_window.setView(this->_gameView);
	this->game->game_window.clear(sf::Color::Black);

	//Draw map
	mapBackdrop.draw(this->game->game_window);
	this->game->map.draw(this->game->game_window);

	if (show_waypoints)
		drawWaypoints(this->current_waypoints, this->game->game_window);

	//Draw Critter
	//this->mew->draw(this->game->game_window, delta_time);
	if (blacky->isActive)
		this->blacky->draw(this->game->game_window, delta_time);

	//Draw Critter wave
	this->current_wave->drawActivatedCrittersInWave(this->game->game_window, delta_time);
	this->tower_manager.draw(this->game->game_window);

	if(tower_manager.getTower(tileX, tileY) != nullptr) {
		this->game->game_window.draw(tower_manager.getTower(tileX,tileY)->getRangeShape());
	}

	//Draw backdrop for interface
	interfaceBackdrop.draw(this->game->game_window);

	//Draw buttons
	for(std::map<std::string, GameObject>::iterator it = buttonMap.begin() ; it != buttonMap.end() ; ++it)
		it->second.draw(this->game->game_window);

	//Draw Specs of Critters and Player
	this->game->game_window.draw(waveSpecs);
	this->game->game_window.draw(nextWaveSpecs);
	playerSpecs.setString(Game::player.getPlayerSpecs());
	this->game->game_window.draw(playerSpecs);
	//this->game->game_window.draw(towerSpecs);
	//Draw Towers and their Specs

	if(buttonMap["BabyShihTzu_Btn"].spriteContains(localPosition)) {
		towerSpecs.setString(getTower1ButtonSpecs());
		this->game->game_window.draw(towerSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}else if(buttonMap["BabyDalmatian_Btn"].spriteContains(localPosition)) {
		towerSpecs.setString(getTower2ButtonSpecs());
		this->game->game_window.draw(towerSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}else if(buttonMap["BabyBulldog_Btn"].spriteContains(localPosition)) {
		towerSpecs.setString(getTower3ButtonSpecs());
		this->game->game_window.draw(towerSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}
	else if(buttonMap["pauseBtn"].spriteContains(localPosition)) {
		buttonSpecs.setString(getPauseButtonSpecs());
		this->game->game_window.draw(buttonSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}
	else if(buttonMap["unpauseBtn"].spriteContains(localPosition)) {
		buttonSpecs.setString(getUnPauseButtonSpecs());
		this->game->game_window.draw(buttonSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}
	else if(buttonMap["returnToEditorBtn"].spriteContains(localPosition)) {
		buttonSpecs.setString(getReturnToEditorButtonSpecs());
		this->game->game_window.draw(buttonSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}
	else if(buttonMap["startWaveBtn"].spriteContains(localPosition)) {
		buttonSpecs.setString(getStartWaveButtonSpecs());
		this->game->game_window.draw(buttonSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}

	for (int i = 0; i < int(this->current_wave->getContainerOfCritters().size()); ++i) 
	{
		if ( this->current_wave->getContainerOfCritters()[i]->isActive )
			if( this->current_wave->getContainerOfCritters()[i]->spriteContains(localPosition) )
			{
				critterSpecs.setString(this->current_wave->getContainerOfCritters()[i]->getCritterSpecs());
				this->game->game_window.draw(critterSpecs);

			}
	}


	if(tower_manager.getTower(tileX, tileY) != nullptr) {
		towerSpecs.setString(tower_manager.getTower(tileX, tileY)->getTowerSpecs());
		//upgradeTowerSpecs.setString(tower_manager.getTower(tileX, tileY)->getUpgradeTowerSpecs());
		this->game->game_window.draw(towerSpecs);
		//this->game->game_window.draw(upgradeTowerSpecs);
	}
	if(!critterHealth.empty() && !healthClock.empty()){
		for(int i = 0 ; i < int(critterHealth.size()) ; ++i){
			healthTime = healthClock[i].getElapsedTime();
			if(healthTime.asSeconds() > 0.5 )
				critterHealth[i].setString("");
			this->game->game_window.draw(critterHealth[i]);
		}
	}
	if(!effectDamage.empty() && !effectDamageClock.empty()){
		for(int i = 0 ; i < int(effectDamage.size()) ; ++i){
			effectDamageTime = effectDamageClock[i].getElapsedTime();
			if(effectDamageTime.asSeconds() > 0.5 )
				effectDamage[i].setString("");
			this->game->game_window.draw(effectDamage[i]);
		}
	}
	nearestTower.setString("Nearest Tower");
	nearestEnd.setString("Nearest End Point");
	strongest.setString("Strongest Critter");
	weakest.setString("Weakest Critter");
	mostH.setString("Most Health");
	leastH.setString("Least Health");
	slowest.setString("Slowest Critter");
	fastest.setString("Fastest Critter");
	mostCoins.setString("Most Coins");

	this->game->game_window.draw(nearestTower);
	this->game->game_window.draw(nearestEnd);
	this->game->game_window.draw(strongest);
	this->game->game_window.draw(weakest);
	this->game->game_window.draw(mostH);
	this->game->game_window.draw(leastH);
	this->game->game_window.draw(slowest);
	this->game->game_window.draw(fastest);
	this->game->game_window.draw(mostCoins);

	if(fieldTowerSelector == nullptr)
		selectedTowerSpecs.setString("");

	this->game->game_window.draw(selectedTowerSpecs);
}