Ejemplo n.º 1
0
void NetworkGameWidget::initWithGUI(FloboSetTheme &floboSetTheme, LevelTheme &levelTheme, ios_fc::MessageBox &mbox, int gameId, unsigned long randomSeed, Action *gameOverAction, FPServerIGPMessageBox *igpbox, bool hasChatBox)
{
    attachedFloboThemeSet = &floboSetTheme;
    attachedRandom = std::auto_ptr<RandomSystem>(new RandomSystem(randomSeed, 5));
    this->mbox = &mbox;
    attachedLocalGameFactory   = std::auto_ptr<LocalGameFactory>(new LocalGameFactory(attachedRandom.get()));
    attachedNetworkGameFactory = std::auto_ptr<NetworkGameFactory>(new NetworkGameFactory(attachedRandom.get(), mbox, gameId));
    if (igpbox != NULL) {
        localArea = std::auto_ptr<NetworkGameView>(new InternetGameView(attachedLocalGameFactory.get(), 0, attachedFloboThemeSet, &levelTheme,
                                            &mbox, gameId, igpbox));
    }
    else {
        localArea = std::auto_ptr<NetworkGameView>(new NetworkGameView(attachedLocalGameFactory.get(), 0, attachedFloboThemeSet, &levelTheme, &mbox, gameId));
    }
    networkArea = std::auto_ptr<GameView>(new GameView(attachedNetworkGameFactory.get(), 1, attachedFloboThemeSet, &levelTheme));
    this->mbox->addListener(this);
    if (hasChatBox)
        chatBox = std::auto_ptr<ChatBox>(new ChatBox(*this));
    brokenNetworkWidget = std::auto_ptr<StoryWidget>(new StoryWidget("etherdown.gsl"));
    networkIsBroken = false;
    GameWidget2P::initWithGUI(*localArea, *networkArea, levelTheme, gameOverAction);
    controllerA.reset(createLocalPlayer());
    controllerB.reset(new GameNullPlayer(*networkArea));
    setLives(-1);
}
Ejemplo n.º 2
0
void updateTankFlashing() {
	if (isTankHit() && TankFlashTime >= TANK_FLASH_TICKS && tankFlashNum != FLASH_TICKS){
		setExplosionFlag(1);
		tankFlashNum++;
		TankFlashTime = 0;
		TankFlashState = !TankFlashState;
		if (tankFlashNum <= 1)
			flashTank(TankFlashState, true);
		else
			flashTank(TankFlashState, false);
	}
	if (isTankHit() && tankFlashNum == FLASH_TICKS){
		tankFlashNum = 0;
		TankFlashState = true;
		flashTank(TankFlashState, false);
		setTankHit(false);
		setLives(getLives()-1);
		// Take out one of the lives
		int startRow = 5;
		int startCol = 490 + (getLives())*40;
		drawTank(true, startRow , startCol);
		// Check if game over
		if (getLives() == 0) {
			setEndOfGame(true);
		} else {
			setTankPositionGlobal(20); // Reset Tank
			drawTank(false, 0, 0);
		}
	}
	TankFlashTime++;
}
Ejemplo n.º 3
0
void penguin::reset()
{
	setLives(3);
	setX(0);
	setY(HEIGHT/2 + bitmapHeight /2);
	setSpeedX(10.0);
	setSpeedY(10.0);
}
Ejemplo n.º 4
0
    void Paddle::die() {
        setLives(getLives() - 1);
        updateLives();

        if(getLives() > 0) {
            reset();
            updateView(_view);
        }
    }
Ejemplo n.º 5
0
penguin::penguin(char *bitmapPath) : object(bitmapPath)
{
	setCollidable(true);
	setLives(3);
	lives_icon.setBitmap("resources/images/lives.png");
	for(int i=0;i<NUM_BULLETS;i++)
	{
		bullets[i].setImage("resources/images/bullet.png");
	}
}
Ejemplo n.º 6
0
void Game::newGame()
{	
	//Delete all the GameObject's in the vector
	for(int i = 0; i < m_GameObjects.size(); i++)
	{
		delete m_GameObjects.at(i);
		m_GameObjects.at(i) = NULL;
	}

	// Clear the pointers from the vector
	m_GameObjects.clear();

	// Adds a paddle and ball object to the vector
	addGameObject(new Paddle());
	addGameObject(new Ball());

	// Adds Brick objects to the vector
	// Creates 3 rows of bricks to start off
	for(int i = 0; i < GAME_BRICKS_PER_ROW * 3; i++)
	{
		addGameObject(new Brick());
	}

	//Cycle through and reset all the game objects
	for(int i = 0; i < m_GameObjects.size(); i++)
	{
		m_GameObjects.at(i)->reset();
	}

	// Reset the background image colour
	m_Textures[0]->setColor(OpenGLColorRGB(1.0f, 1.0f, 1.0f));

	// Unpause the game
	m_Pause = false;

	m_LeftMouseHeld = false;

	// Set the game over state to false
	m_GameOver = false;

	// Reset lives to 3
	setLives(GAME_STARTING_LIVES);

	// Reset the round
	m_Round = 0;

	// Place the bricks 
	placeBricks();
}
Ejemplo n.º 7
0
void Game::reset()
{
	// Called when the ball is off screen (missed by paddle)
	// Reset the ball object

	// Subtract one life
	setLives(getLives() - 1);
	Ball* ball = (Ball*)getGameObjectByType(GAME_BALL_TYPE);
	if(ball != NULL)
	{
		float prevSpeed = ball->getSpeed();
		ball->reset();
		ball->setSpeed(prevSpeed);
	}

	// Once the player runs out of lives call the gameOver function
	if(getLives() <= 0)
	{
		gameOver();
	}
}
Ejemplo n.º 8
0
    void Paddle::aquire(const Item& item, Ball& ball) {
        switch(item.getType()) {
            case Item::Type::PaddleSize:
                if(getWidth() < 90) {
                    setWidth(getWidth() + 10);
                    setPositionRange(255, 544 - getWidth());

                    if(_position.x - 5 > _positionRange.x)
                        _position.x -= 5;

                    updateView(_view);
                }
                break;

            case Item::Type::ExtraLive:
                setLives(getLives() + 1);
                updateLives();
                break;

            case Item::Type::BallSpeedReduction:
                ball.resetSpeedFactor();
                break;
        }
    }
Ejemplo n.º 9
0
void NetworkGameWidget::initWithoutGUI(ios_fc::MessageBox &mbox, int gameId, unsigned long randomSeed, Action *gameOverAction, FPServerIGPMessageBox *igpbox)
{
    this->mbox->addListener(this);
    //GameWidget::initWithoutGUI(*localArea, networkArea, playercontroller, dummyPlayerController, levelTheme, gameOverAction);
    setLives(-1);
}
Ejemplo n.º 10
0
 Paddle::Paddle(View::ViewPaddle* view) {
     bindView(view);
     reset();
     setLives(3);
     setSpeedFactor(250.0f);
 }
Ejemplo n.º 11
0
void Game::levelUp()
{
	// This function is called when a player clears all bricks from the screen

	// Increase the number of lives by 1
	setLives(getLives() + 1);
	// Increase the rounds
	m_Round++;

	// If the current round is equal to or greater than the max rounds 
	if(m_Round > GAME_MAX_ROUNDS)
	{
		// Start a new game
		newGame();
	}

	// Sets the background image colour based on the current round
	switch(m_Round)
		{
		case 0:
			// Default
			m_Textures[0]->setColor(OpenGLColorRGB(1.0f, 1.0f, 1.0f));
			break;
		case 1:
			// Green
			m_Textures[0]->setColor(OpenGLColorRGB(0.5f, 1.0f, 0.5f));
			break;
		case 2:
			// Orange
			m_Textures[0]->setColor(OpenGLColorRGB(1.0f, 0.5f, 0.0f));
			break;
		case 3:
			// Purple
			m_Textures[0]->setColor(OpenGLColorRGB(0.5f, 0.5f, 0.0f));
			break;
		case 4:
			// Red
			m_Textures[0]->setColor(OpenGLColorRGB(1.0f, 0.5f, 0.5f));
			break;
		case 5:
			// Yellow
			m_Textures[0]->setColor(OpenGLColorRGB(1.0f, 1.0f, 0.0f));
			break;
		}

	// Add another row of bricks
	for(int i = 0; i < GAME_BRICKS_PER_ROW; i++)
	{
		addGameObject(new Brick());
	}


	Ball* ball = (Ball*)getGameObjectByType(GAME_BALL_TYPE);
	if(ball != NULL)
	{
		// Increases the ball's speed by 25% each time this function is called
		// Change GAME_SPEED_MOD in globals to change the speed increase per level
		float prevSpeed = ball->getSpeed();

		// Go through all game objects and reset them
		// Except for the paddle
		for(int i = 0; i < m_GameObjects.size(); i++)
		{
			if(m_GameObjects.at(i)->getType() != GAME_PADDLE_TYPE)
			{
				m_GameObjects.at(i)->reset();
			}
		}

		ball->setSpeed(prevSpeed * GAME_SPEED_MOD);
	}

	// Call the placeBrick function to space bricks
	// For a new round of play
	placeBricks();
}
Ejemplo n.º 12
0
penguin::penguin() : object() 
{
	setCollidable(true);
	setLives(3);
}
Ejemplo n.º 13
0
 void GameProgress::resetLivesToDefault() {
     setLives(DEFAULT_NUM_LIVES);
 }