void HitCheckerkActorGimmick::Update(void){
	//hit check battle actor and attack
	int gimmick_count(_accessor->GetGimmickCount());

	int player_count(_accessor->GetPlayerCount());
	for(int i=0; i<player_count; i++){
		BattleActor* player(_accessor->GetPlayer(i));
		for(int j = 0; j<gimmick_count; j++){
			Gimmick* gimmick(_accessor->GetGimmick(j));
			
			bool hit(HitCheck(player, gimmick));

			if(hit){
				HitActor(player, gimmick);
			}
		}
	}

	int enemy_count(_accessor->GetEnemyCount());
	for(int i=0; i<enemy_count; i++){
		BattleActor* enemy(_accessor->GetEnemy(i));
		for(int j = 0; j<gimmick_count; j++){
			Gimmick* gimmick(_accessor->GetGimmick(j));

			bool hit(HitCheck(enemy, gimmick));

			if(hit){
				HitActor(enemy, gimmick);
			}
		}
	}
}
예제 #2
0
    void MissileEnemyWave::Spawn()
    {
        const float MIN_SPAWN_GAP = 0.3f;
        const float MAX_SPAWN_GAP = 0.6f;
        const float SPAWN_Y_BASE = 500.0f;
        const float SPAWN_Y_GAP  = 100.0f;

        if (m_enemiesSpawned < m_enemyCount && m_nextSpawnTime <= GAME.GetTime()) {
            float x;
            float y;
            juzutil::Vector3 dir;

            if (m_enemiesSpawned % 2 == 0) {
                x = Game::GAME_SCREEN_RIGHT;
                dir.Set(-1.0f, 0.0f, 0.0f);
            } else {
                x = Game::GAME_SCREEN_LEFT;
                dir.Set(1.0f, 0.0f, 0.0f);
            }

            y = SPAWN_Y_BASE + SPAWN_Y_GAP * m_enemiesSpawned;

            MissileEnemyPtr enemy(new MissileEnemy(GAME.GetPhrase(PhraseBook::PL_MEDIUM),
                                                   juzutil::Vector3(x, y, 0.0f),
                                                   dir));
            m_enemies.push_back(enemy);
            GAME.AddEntity(enemy);

            ++m_enemiesSpawned;
            m_nextSpawnTime = RAND.Range(MIN_SPAWN_GAP, MAX_SPAWN_GAP) + GAME.GetTime();
        }
    }
예제 #3
0
    void AccelEnemyWave::Spawn ()
	{
		const float MIN_SPAWN_X = 200.0f;
		const float MAX_SPAWN_X = 800.0f;
		const float SPAWN_Y = 1000.0f;

		const float MAX_SPAWN_GAP = 3.0f;
		const float MIN_SPAWN_GAP = 1.0f;
		const float MIN_SPEED = 50.0f;
		const float MAX_SPEED = 150.0f;
		const float PROGRESS_CEILING = 0.75f;

        if (m_enemiesSpawned < m_enemyCount && m_nextSpawnTime <= GAME.GetTime()) {
			const float progress = std::min(PROGRESS_CEILING, GAME.GetProgress()) / PROGRESS_CEILING;
			const float speed = RangeFromRatio(MIN_SPEED, MAX_SPEED, progress);
			const float gap = RangeFromRatioInverse(MIN_SPAWN_GAP, MAX_SPAWN_GAP, progress);

            float x = RAND.Range(MIN_SPAWN_X, MAX_SPAWN_X);

            if (m_enemiesSpawned++ % 2 == 0) {
                x *= -1;
            }

            AccelEnemyPtr enemy(new AccelEnemy(GAME.GetPhrase(PhraseBook::PL_SHORT),
				                               juzutil::Vector3(x, SPAWN_Y, 0.0f),
											   speed));
            m_enemies.push_back(enemy);
            GAME.AddEntity(enemy);

            m_nextSpawnTime = GAME.GetTime() + gap;
        }
    }
int main()
{
	std::cout << "Welcome to my first text based RPG game." << std::endl;
	std::cout << "I hope this is something you enjoy playing. You can press Q at anytime to quit the game." << std::endl;

	Entity enemy(1,1,1,1,1,1,1,"Enemy", Class::Archer, Race::Dwarf);
	enemy.PickUp(Item("Sword", 12));

	enemy.DisplayInventory();


	//Insert Main Game Loop here.
	//Check for input if the Q button is detected then end then game.

	//char input;
	//while (GameManager::GetIsRunning())
	//{
	//	//While the game is running detect input
	//	std::cin >> input;
	//}
	//char something;
	//std::cin >> something;
	//std::cout << something;

	*/
	Entity enemy = Entity(2, 2, 2, 2, 2, 2, 0, "Enemy", Class::Archer, Race::Dwarf);
	enemy.PickUp(Item("Sword", 12));
	enemy.DisplayInventory();
    return 0;
}
예제 #5
0
void EnemyList::spawnNewRandom(double playerX, double playerY, GLuint* enemyTextureID)
{
	double enemyX = playerX + RandomGen().getRand(20, -20);
	double enemyY = playerY + RandomGen().getRand(20, 18);
	CompShip enemy(0, enemyX, enemyY, enemyTextureID);
	addNewEnemy(enemy);
	//std::cout << "ADDED NEW ENEMY: " << enemyList.size() << std::endl;
}
예제 #6
0
void CAgentManager::remove_links		(CObject *object)
{
	corpse().remove_links		(object);
	enemy().remove_links		(object);
	explosive().remove_links	(object);
	location().remove_links		(object);
	member().remove_links		(object);
	memory().remove_links		(object);
	brain().remove_links		(object);
}
예제 #7
0
void CAgentManager::update_impl			()
{
	VERIFY						(!member().members().empty());

	memory().update				();
	corpse().update				();
	enemy().update				();
	explosive().update			();
	location().update			();
	member().update				();
	brain().update				();
}
예제 #8
0
void World::spawnEnemies()
{
    while (!mEnemySpawnPoints.empty() &&
           mEnemySpawnPoints.back().y > getBattleField().top)
    {
        SpawnPoint spawn = mEnemySpawnPoints.back();
        std::unique_ptr<Aircraft> enemy(new Aircraft(spawn.type, mTextures, mFonts));
        
        enemy->setPosition(spawn.x, spawn.y);
        enemy->setRotation(180.f);
        
        mSceneLayers[Air]->attachChild(std::move(enemy));
        mEnemySpawnPoints.pop_back();
    }
}
void BattleCommanderStateDirection::CheckPointingActor(void){
	Cursor3D* cursor3d(_accessor->GetCursor3D());
	if(!cursor3d->GetVisible()){
		_pointing_actor = nullptr;
		return;
	}

	D3DXVECTOR3 cursor_position(cursor3d->GetPosition());
	HitSphere cursor_hit(nullptr, cursor_position, 5.0f);
	
	//敵と味方を全部辿って、当たっている奴の中で一番近いやつを指す
	_pointing_actor = nullptr;
	float min_length(1000.0f);

	int player_count(_accessor->GetPlayerCount());
	for(int i=0; i<player_count; i++){
		BattleActor* player(_accessor->GetPlayer(i));
		Hit* player_hit(player->GetCursorHit());

		bool hit(player_hit->HitCheck(&cursor_hit));
		if(hit){
			D3DXVECTOR3 player_position(player->GetPosition());
			D3DXVECTOR3 v(player_position - cursor_position);
			float length(D3DXVec3Length(&v));
			if(min_length > length){
				min_length = length;
				_pointing_actor = player;
			}
		}
	}

	int enemy_count(_accessor->GetEnemyCount());
	for(int i=0; i<enemy_count; i++){
		BattleActor* enemy(_accessor->GetEnemy(i));
		Hit* enemy_hit(enemy->GetCursorHit());

		bool hit(enemy_hit->HitCheck(&cursor_hit));
		if(hit){
			D3DXVECTOR3 enemy_position(enemy->GetPosition());
			D3DXVECTOR3 v(enemy_position - cursor_position);
			float length(D3DXVec3Length(&v));
			if(min_length > length){
				min_length = length;
				_pointing_actor = enemy;
			}
		}
	}
}
void gameClass::spawnEnemies()
{
	for (int i = 0; i < mapLevel[currentLevel].spawns.size(); i++) {
		int counter = 0;
		
		if (mapLevel[currentLevel].spawns[i].tile.isOnScreen(renderingPort)) {
			
			bool eraseFlag = true;
			while (eraseFlag == true && counter < 10) { // try to spawn an enemy 10 times, if not possible (because of collisions), then stop attempt to spawn	

				int spawnX = mapLevel[currentLevel].spawns[i].tile.getPos().x;
				int spawnY = mapLevel[currentLevel].spawns[i].tile.getPos().y;
				glm::vec2 size(mapLevel[currentLevel].getTileWidth(), mapLevel[currentLevel].getTileHeigth());

				enemyClass enemy("skull", 									// creature name
					1,														// nr of actions which require animation
					resourceManagerClass::GetTexture("skull"),				// sprite
					Constants::enemyHealth,									// health
					Constants::enemySpeed,									// speed
					Constants::enemyPower,									// attack power
					{ spawnX + 10, spawnY },								// starting position
					{ size.x + 10 , size.y + 10 },								// size
					270,													// rotation
					{ 8, 30 },												// collisionOffsetXY
					{ -8, 5 },												// collisionOffsetZW
					{ 1,1,1 }													// color
				);

				eraseFlag = false;
				for (int i = 0; i < enemies.size(); i++) {

					if (enemy.tile == enemies[i].tile) {
						eraseFlag = true;
						counter++;
						break;

					}

				}
				if (!eraseFlag) {
					enemies.push_back(enemy);
					//SoundEngine->play2D("audio/Sound Effect (3).wav", GL_FALSE);
				}
			}
		}
	}
}
예제 #11
0
void
World::spawnEnemies() {
    // TODO: wrap up condition into a bool method
    while ( !mEnemySpawnPoints.empty() && mEnemySpawnPoints.back().y > getBattlefieldBounds().top ) {
        SpawnPoint spawn = mEnemySpawnPoints.back();

        std::unique_ptr<Aircraft> enemy( new Aircraft( spawn.type, mTextures, mFonts ) );
        enemy->setPosition( spawn.x, spawn.y );
        enemy->setRotation( 180.0f );

        if ( mNetworkedWorld ) {
            enemy->DisablePickups();
        }
        mSceneLayers[UpperAir]->AttachChild( std::move( enemy ) );
        mEnemySpawnPoints.pop_back();
    }
}
예제 #12
0
void World::spawnEnemies() {
    // Spawn all enemies entering the view area (including distance) this frame
    while (!mEnemySpawnPoints.empty()
            && mEnemySpawnPoints.back().y > getBattlefieldBounds().top) {
        SpawnPoint spawn = mEnemySpawnPoints.back();

        std::unique_ptr<Aircraft> enemy(new Aircraft(spawn.type, mTextures, mFonts));
        enemy->setPosition(spawn.x, spawn.y);
        enemy->setRotation(180.f);
        if (mNetworkedWorld) enemy->disablePickups();

        mSceneLayers[UpperAir]->attachChild(std::move(enemy));

        // Enemy is spawned, remove from the list to spawn
        mEnemySpawnPoints.pop_back();
    }
}
예제 #13
0
//initialize the random enemies
std::vector<sf::RectangleShape> CreateEnemies(std::vector<sf::RectangleShape>& enemies, int difficulty, float rectX, float rectY)
{

	sf::RectangleShape enemy;

	for (int i = 1; i < difficulty; ++i)
	{

		sf::RectangleShape enemy(sf::Vector2f(rectX, rectY));

		enemy.setFillColor(sf::Color(255, 0, 0, 255));

		enemy = RectanglePosition(enemy, 800, 600);

		enemies.push_back(enemy);

	}

	return enemies;
}
예제 #14
0
    void SeekerEnemyWave::Spawn()
    {
        if (m_enemiesSpawned < m_enemyCount && GAME.GetTime() >= m_nextSpawnTime) {
            const float xGap = SEEKERENEMYWAVE_MAX_SPAWN_X / static_cast<float>(m_enemyCount - 1);
            const float x = xGap * (m_enemyCount - m_enemiesSpawned) + xGap / 2.0f;

            SeekerEnemyPtr enemy(new SeekerEnemy(GAME.GetPhrase(PhraseBook::PL_MEDIUM),
                                                 juzutil::Vector3(x, SEEKERENEMYWAVE_SPAWN_Y, 0.0f)));
            m_enemies.push_back(enemy);
            GAME.AddEntity(enemy);

            enemy.reset(new SeekerEnemy(GAME.GetPhrase(PhraseBook::PL_MEDIUM),
                                        juzutil::Vector3(-x, SEEKERENEMYWAVE_SPAWN_Y, 0.0f)));
            m_enemies.push_back(enemy);
            GAME.AddEntity(enemy);

            m_enemiesSpawned += 2;
            m_nextSpawnTime = GAME.GetTime() + SEEKERENEMYWAVE_SPAWN_GAP;
        }
    }
예제 #15
0
파일: Game.cpp 프로젝트: Qata/Wibbly
Game::Game(string path, Highscores * highscores) : Screen(path)
{
	Game::highscores = highscores;
	Game::keyboard = keyboard;
	Map::init("Maps/map1.mta");
	msurf_MapSurface = Map::createMapSurface("map.png");
	msurf_Screen = 0;
	mui_TurnCounter = 0;

	player = shared_ptr<Player>(new Player("player_walk1.png", 1, 18, 32, true));
	m_Entities.push_front(player);
	for (auto i = 0; i < 1; i++)
	{
		shared_ptr<Pickup> pickup(new Pickup(32, true, TOME));
		shared_ptr<Enemy> enemy(new Enemy("enemy.png", 32, true));
		m_Entities.push_front(pickup);
		m_Entities.push_front(enemy);
		m_Enemies.push_back(enemy);
	}
}
예제 #16
0
파일: World.cpp 프로젝트: chehob/SFMLDev
void World::Impl::SpawnEnemies()
{
	// Spawn all enemies entering the view area (including distance) this frame
	while ( !mEnemySpawnPoints.empty()
		&& mEnemySpawnPoints.back().y > pContainer->GetBattlefieldBounds().top )
	{
		SpawnPoint spawn = mEnemySpawnPoints.back();

		b2Body * body = CreateBody( b2_dynamicBody, sf::Vector2f( spawn.x, spawn.y ), sf::Vector2f( 1.f, 1.f ) );

		std::unique_ptr<Aircraft> enemy( new Aircraft( spawn.type, mTextures, mFonts, body ) );
		enemy->setPosition( spawn.x, spawn.y );
		enemy->setRotation( 180.f );

		mSceneLayers[ UpperAir ]->AttachChild( std::move( enemy ) );

		// Enemy is spawned, remove from the list to spawn
		mEnemySpawnPoints.pop_back();
	}
}
void HitCheckerAttackActor::Update(void){
	//hit check battle actor and attack
	AttackAccessor* attack_accessor(_accessor->GetAttackAccessor());
	int attack_count(attack_accessor->GetCount());

	int player_count(_accessor->GetPlayerCount());
	for(int i=0; i<player_count; i++){
		BattleActor* player(_accessor->GetPlayer(i));
		for(int j = 0; j<attack_count; j++){
			Attack* attack(attack_accessor->Get(j));
			//scope check
			if(!attack->IsScopingPlayer()){
				continue;
			}

			bool hit(HitCheck(player, attack));

			if(hit){
				HitActor(player, attack);
			}
		}
	}

	int enemy_count(_accessor->GetEnemyCount());
	for(int i=0; i<enemy_count; i++){
		BattleActor* enemy(_accessor->GetEnemy(i));
		for(int j = 0; j<attack_count; j++){
			Attack* attack(attack_accessor->Get(j));
			//scope check
			if(!attack->IsScopingEnemy()){
				continue;
			}

			bool hit(HitCheck(enemy, attack));

			if(hit){
				HitActor(enemy, attack);
			}
		}
	}
}
void HitCheckerActorField::Update(void){
	ModelField* field(_accessor->GetModelField());

	int player_count(_accessor->GetPlayerCount());
	for(int i=0; i<player_count; i++){
		BattleActor* player(_accessor->GetPlayer(i));

		D3DXVECTOR3 position(player->GetPosition());
		position.y = max(field->GetHeight(position.x, position.z), position.y);
		player->SetPosition(position);
	}

	int enemy_count(_accessor->GetEnemyCount());
	for(int i=0; i<enemy_count; i++){
		BattleActor* enemy(_accessor->GetEnemy(i));

		D3DXVECTOR3 position(enemy->GetPosition());
		position.y = max(field->GetHeight(position.x, position.z), position.y);
		enemy->SetPosition(position);
	}
}
예제 #19
0
int main()
{
	//---random!
	std::srand(time(NULL));
	double random = std::rand() % 360+1;

	std::list<Enemy*> enemy_list;
	/*std::list<Enemy*>::iterator itr_enemy_list;
	Enemy enemy1(100, 50), enemy2(50, 100);
	enemy_list.push_back(&enemy1);
	enemy_list.push_back(&enemy2);*/
	//itr_enemy_list = enemy_list.begin();
	
	//---scene loading
	sf::Clock scene_timer;
	std::vector<float[3]> scene_script;
	float a[3];
	a[0] = 1000.f;
	a[1] = 100.f;
	a[2] = 100.f;
	scene_script.push_back(a);
	a[0] = 1500.f;
	//scene_script.push_back(a);

	//---realtime editor
	//sf::Thread editor(&editor_wrapper, &ship);
	//editor.launch();

	//---fps counter
	int frame_count = 0;
	SimpleText text_fps("FPS: ");
	std::stringstream text_fps_number;
	sf::Clock fps_clock;
	fps_clock.restart();

	sf::Event ev;

	//---window setup
	sf::RenderWindow window(sf::VideoMode(640, 800, 32), "Kickstart My Tart");
	window.setFramerateLimit(60);
	window.setKeyRepeatEnabled(false);

	Ship ship("ship_train.png", window);

	//-----------------------------------MAIN LOOP
	scene_timer.restart();
	while (window.isOpen()) {
		window.clear();
		
		//---events
		while (window.pollEvent(ev))
			if (ev.type == sf::Event::Closed || (ev.type == sf::Event::KeyPressed && ev.key.code == sf::Keyboard::Escape))
				window.close();
				//editor.terminate();

		//---scene
		if (scene_timer.getElapsedTime().asMilliseconds() > scene_script.front()[0]) {
			Enemy enemy(scene_script.front()[1], scene_script.front()[2]);
			enemy_list.push_back(&enemy);
			scene_script.pop_back();
		}


		//---drawing
		if (!enemy_list.empty()) {
			std::for_each(enemy_list.begin(), enemy_list.end(), std::bind2nd(std::mem_fun<void, Enemy>(&Enemy::update), &random));
			std::for_each(enemy_list.begin(), enemy_list.end(), std::bind2nd(std::mem_fun<void, Enemy>(&Enemy::draw), &window));
		}
		/*(*itr_enemy_list)->draw(window);
		++itr_enemy_list;
		(*itr_enemy_list)->draw(window);
		itr_enemy_list = enemy_list.begin();*/

		ship.update();
		ship.draw(window);
		
		//---fps
		frame_count++;
		if(fps_clock.getElapsedTime().asMilliseconds() > 1000.0f) {
			fps_clock.restart();
			text_fps_number.str("");
			text_fps_number << frame_count;
			text_fps.update("FPS: "+text_fps_number.str(), window);
			frame_count = 0;
			//TESTING
			random = std::rand()%360+1;
		}
		else
			text_fps.update(window);

		window.display();
	}
	return EXIT_SUCCESS;
}
예제 #20
0
void EnemyList::checkCollisions(PlayerProjectiles& playerProjectiles)
{
	for (unsigned int i = 0; i < enemyList.size(); i++)
	{
		Point enemy(enemyList[i].getCompX(), enemyList[i].getCompY());
		for (unsigned int j = 0; j < playerProjectiles.getSize(); j++)
		{
			Bullet* b = playerProjectiles.getBullet(j);
			Point bulPoint(b->getX(), b->getY());
			if (enemyList[i].enemyType == 0 && Collision().checkCollision(playerProjectiles.getVector()[j].box, enemy, 0.97))
			{
				b->destroy();
				enemyList[i].enemyHP--;
				Explosion explosion;
				if (enemyList[i].enemyHP <= 0)
				{
					enemyList[i].destroyed = true;
					if (enemyList[i].enemyType == 0)
					{
						explosion = Explosion(enemyList[i].compX, enemyList[i].compY, 1, explosionTextureID);
					}
					else
					{
						explosion = Explosion(enemyList[i].compX, enemyList[i].compY, 2, explosionTextureID);
					}
					
					explosionList.addExplosion(explosion);
				}
			}
			else if (enemyList[i].enemyType == 1 && Collision().isIntersect(enemyList[i].box,
				enemy,
				b->box,
				bulPoint,
				28,
				minTransDist))
			{
				b->destroy();
				enemyList[i].enemyHP--;
				if (enemyList[i].enemyHP <= 0)
				{
					enemyList[i].destroyed = true;
					Explosion explosion(enemyList[i].compX, enemyList[i].compY, 1, explosionTextureID);
					explosionList.addExplosion(explosion);
				}
			}
		}

		for (unsigned int j = 0; j < enemyList.size(); j++)
		{
			Point p2(enemyList[j].getCompX(), enemyList[j].getCompY());
			if (i != j && Collision().isIntersect(enemyList[i].box, enemy, enemyList[j].box, p2, 28, minTransDist))
			{
				if (enemyList[i].enemyType == 1)
				{
					enemyList[j].setMinTransDist(minTransDist.pointX, minTransDist.pointY);
				}
				else if (enemyList[j].enemyType == 1)
				{
					enemyList[i].setMinTransDist(minTransDist.pointX, minTransDist.pointY);
				}
				else
				{
					enemyList[i].setMinTransDist(minTransDist.pointX * 0.5, minTransDist.pointY * 0.5);
					enemyList[j].setMinTransDist(-minTransDist.pointX * 0.5, -minTransDist.pointY * 0.5);
				}
			}
		}

		Point playerPos(playerShipX, playerShipY);
		//std::cout << playerPos.pointX << "\t" << playerPos.pointY << "\t" << enemy.pointX << "\t" << enemy.pointY << std::endl;
		BoundingQuad lineBox(playerPos, playerPos, enemy, enemy);
		bool result = true;
		for (unsigned int j = 0; j < asteroidMapListRef->asteroidField.size(); j++)
		{
			Point p2(asteroidMapListRef->asteroidField[j].getRoidX(), asteroidMapListRef->asteroidField[j].getRoidY());
			if (Collision().isIntersect(enemyList[i].box, 
				enemy,
				asteroidMapListRef->asteroidField[j].box, 
				p2,
				28,
				minTransDist))
			{
				enemyList[i].setMinTransDist(minTransDist.pointX * 2, minTransDist.pointY * 2);
				enemyList[i].turnAround();
			}
			if (!Collision().hasLineOfSight(enemy, playerPos, lineBox, asteroidMapListRef->asteroidField[j].box, p2, 28))
			{
				result = false;
			}
		}
		enemyList[i].setLOS(result);
	}

	for (unsigned int i = 0; i < playerProjectiles.getSize(); i++)
	{
		Bullet* b = playerProjectiles.getBullet(i);
		Point p1(b->getX(), b->getY());
		
		for (unsigned int j = 0; j < asteroidMapListRef->asteroidField.size(); j++)
		{
			Point p2(asteroidMapListRef->asteroidField[j].getRoidX(), asteroidMapListRef->asteroidField[j].getRoidY());
			if (Collision().isIntersect(b->box, p1, asteroidMapListRef->asteroidField[j].box, p2, 40, minTransDist))
			{
				Explosion explosion(b->box.pointsN[2].pointX, b->box.pointsN[2].pointY, 0.3, explosionTextureID);
				explosionList.addExplosion(explosion);
				b->destroyed = true;
			}
		}
	}
}
예제 #21
0
void Game::add_enemy(TilePos t)
{
    std::shared_ptr<Entity> enemy (new Enemy(t));
    entities.push_back(enemy);
}
예제 #22
0
	void add_enemy(Vector pos) {
		enemies.push_back(enemy(pos, &tanks[0].pos, &shots, bg_collision));
	}
예제 #23
0
int Game::Run(RenderWindow &win, VideoMode &vMode)
{
	Music m;
	SoundBuffer playerShootBuffer;
	SoundBuffer meteorBuffer;
	meteorBuffer.LoadFromFile("..\\Resources\\meteorexplosion.ogg");
	playerShootBuffer.LoadFromFile("..\\Resources\\playerShoot.ogg");
	Sound playerSound;
	Sound meteorSound;
	meteorSound.SetBuffer(meteorBuffer);
	playerSound.SetBuffer(playerShootBuffer);
	playerSound.SetLoop(false);
	meteorSound.SetLoop(false);
	m.OpenFromFile("..\\Resources\\asteroid.ogg");
	
	m.SetLoop(true);
	m.SetVolume(100);
	PlayerShip ship(player_ship, 2, vMode);
	EnemyShip enemy(enemy_ship, vMode);
	Collision col;
	Event events;
	Image bg1;
	Image bg2;
	Image bg3;
	bg1.LoadFromFile("..\\Resources\\bg.jpg");
	Image stars;
	string abc = "..\\Resources\\star.png";
	stars.LoadFromFile(abc);
	Sprite sp(bg1);
	Sprite sp2(bg1);
	Sprite sp3(bg1);
	Sprite spStar[10];
	Clock clock;
	srand((unsigned)time(0)); 
	for(int i = 0; i<10; i++)
	{
		spStar[i].SetImage(stars);
		//spStar[i].SetPosition
	}
	spStar[0].SetPosition(0,100);
	spStar[1].SetPosition(70,200);
	spStar[2].SetPosition(200,300);
	spStar[3].SetPosition(320,400);
	spStar[4].SetPosition(460,500);
	spStar[5].SetPosition(260,300);
	spStar[6].SetPosition(160,400);
	spStar[7].SetPosition(400,200);
	spStar[8].SetPosition(760,100);
	spStar[9].SetPosition(800,600);
	

	int lowestx, highestx, lowesty, highesty, rangex, rangey, random_integerx, random_integery;
	float time1 = 0;
	float time2 = 0;
	bool start = false;

	



	
	//Sprite spStar1(stars);
	//spStar1.SetPosition(spStar.GetPosition().x, spStar.GetPosition().y - spStar.GetSize().y);
	sp.Resize((float)vMode.Width, (float)vMode.Height);
	sp2.Resize((float)vMode.Width, (float)vMode.Height);
	sp2.SetPosition(sp.GetPosition().x, sp.GetPosition().y - sp.GetSize().y);
	sp3.SetPosition(sp2.GetPosition().x, sp2.GetPosition().y - sp2.GetSize().y);
	//spStar.Resize((float)vMode.Width, (float)vMode.Height);
	bool key = false;
	bool down = false;
	Bullet *bul;
	Meteor* met[METEORCOUNT];
	for(int i = 0; i<METEORCOUNT; i++)
	{
		met[i] = new Meteor(meteor, vMode);
	}
	met[0]->SetPosition(200,-400);
	met[1]->SetPosition(420,-200);
	met[2]->SetPosition(720,-400);
	met[3]->SetPosition(520,-600);
	met[4]->SetPosition(320,-400);
	/*met[5]->SetPosition(620,-400);
	met[6]->SetPosition(100,-400);
*/
	int bulletCount = 0;
	vector<Bullet*> bulletVector;
	vector<Meteor*> meteorVector;
	for(int i = 0; i<METEORCOUNT; i++)
	{
		meteorVector.push_back(met[i]);
	}
	bool fired = false;
	bool pressed = false;
	int count;
	bool change = false;
	//win.UseVerticalSync(true);
	//win.SetFramerateLimit(60);
	int type = pistol;
	Image sunImg;
	sunImg.LoadFromFile("..\\Resources\\Sun.png");
	Sprite sunSp(sunImg);
	sunSp.SetPosition(500,2000);
	//void* user;
	//int score = 0;
//	enemys e(vMode);
	
	//Thread thread(Thread::FuncType Move,void* enemy, void* &win, void* ship);
	m.Play();
	while(win.IsOpened())
	{
		
		while(win.GetEvent(events))
		{
			if(events.Type == Event::Closed)
			{
				win.Close();
				return -1;
			}
				if((events.Type == Event::KeyPressed) && (events.Key.Code == Key::Escape))
				{
					
					return 0;
				}
				if(ship.IsDestroyed() && ((events.Type == Event::KeyPressed) && (events.Key.Code == Key::Return)))
		{
			return 0;
		}
		}

		
		if(win.GetInput().IsKeyDown(Key::Up) && !ship.IsDestroyed())
		{	
			ship.Throttled();
		}
		if(!win.GetInput().IsKeyDown(Key::Up)&& !ship.IsDestroyed())
		{	
			ship.NoThrottle();
			key = false;
		}

		if(!win.GetInput().IsKeyDown(Key::Right) && !win.GetInput().IsKeyDown(Key::Up) && !ship.IsDestroyed())
		{	
			ship.NoThrottle();
		}
		if(!win.GetInput().IsKeyDown(Key::Left)&& !win.GetInput().IsKeyDown(Key::Up) && !ship.IsDestroyed())
		{	
			ship.NoThrottle();
		}
		if(win.GetInput().IsKeyDown(Key::Right) && !ship.IsDestroyed())
		{
			ship.Right();
			if(ship.GetPositionX()<=vMode.Width)
			{
				//ship.SetSpeed(100);
			ship.AddVelocity(300,0);
			ship.MoveSide(win.GetFrameTime());
			}
		}
		if(win.GetInput().IsKeyDown(Key::Left) && !ship.IsDestroyed())
		{
			ship.Left();
			if(ship.GetPositionX()>=0)
			{
			ship.AddVelocity(-300,0);
			//ship.SetSpeed(-100);
			ship.MoveSide(win.GetFrameTime());
			}
		}

		if(win.GetInput().IsKeyDown(Key::LShift))
		{
			ship.TellDestroyed();
			//ship.Destroyed();
			//win.Close();
		}
		if(win.GetInput().IsKeyDown(Key::B))
		{
			
		}
		if(win.GetInput().IsKeyDown(Key::Space) && !ship.IsDestroyed()&&!pressed)
		{
			playerSound.Play();
			bul = new Bullet(bullets, vMode, &ship, type);	
			//bul->ChangeType(type);
			//bul->ChangeType(pistol);
			bulletVector.push_back(bul);
			count = bulletVector.size();
			//cout<<count;

			pressed = true;
		}
		if(!win.GetInput().IsKeyDown(Key::Space))
		{
			pressed = false;
		}
		
		if(win.GetInput().IsKeyDown(Key::N))
		{
			
			type = laser;
			for(int i = 0; i< METEORCOUNT; i++)
			{
				met[i]->SetDestroyed();
			}
		
		}
		win.Clear();
		
		
		

		ship.MoveUp(win.GetFrameTime());
		
		if(enemy.GetPositionY()>ship.GetPositionY()-500)
		{
			enemy.MoveUp(&win, ship);
			//enemy.NavigatorUp(&win, ship);
		}	//ship.Simulate(win.GetFrameTime(), key, down);
		for(int i = 0; i<10; i++)
		{
			if(spStar[i].GetPosition().y>ship.GetPositionY() + 50)
			{
				 
					lowesty=(int)ship.GetPositionY(), highesty=(int)ship.GetPositionY()-600; 
					rangey=(highesty-lowesty)+1; 
					random_integery;
	
					random_integery = lowesty+int(rangey*rand()/(RAND_MAX + 1.0)); 
					//cout << random_integery << endl;

					lowestx=0, highestx=800; 
					rangex=(highestx-lowestx)+1; 
					random_integerx;
	
					random_integerx = lowestx+int(rangex*rand()/(RAND_MAX + 1.0)); 
					//cout << random_integerx << endl;
				 
	
					spStar[i].SetPosition((float)random_integerx, (float)random_integery);
			}
		}

		for(int i = 0; i<METEORCOUNT; i++)
		{
			if(ship.GetPositionY()<=-2000)//Score compare
			{
				met[i]->ChangeSpeed();	
			}
			met[i]->Update(win.GetFrameTime());
			if(met[i]->GetPositionY()>ship.GetPositionY() + 50)
			{
					lowesty=(int)ship.GetPositionY() - 600, highesty=(int)ship.GetPositionY()-1200; 
					rangey=(highesty-lowesty)+1; 
					random_integery;
	
					random_integery = lowesty+int(rangey*rand()/(RAND_MAX + 1.0)); 
					//cout << random_integery << endl;

					lowestx=0, highestx=720; 
					rangex=(highestx-lowestx)+1; 
					random_integerx;
	
					random_integerx = lowestx+int(rangex*rand()/(RAND_MAX + 1.0)); 
				//	cout << random_integerx << endl;
					if(met[i]->IsDestroyed())
					{
						met[i]->SetAlive();
					}
					met[i]->SetPosition(random_integerx, random_integery);
					if(!ship.IsDestroyed())
					{
					ship.IncreaseScore();
					ship.UpdateScore();
					}
			}
			met[i]->UpdateAI();
		}

		

		
		if(enemy.IsFired())
		{
			
		if(col.PixelPerfectTest(enemy.GetBullet(), ship.GetSprite()))
				{
					
					//ship.TellDestroyed();
					ship.DecreaseHealth();
					if(ship.GetHealth()<=0)
					{
						ship.TellDestroyed();
					}
					enemy.BulletReset();
					enemy.NotAttacking();
				}
		}
		if(!meteorVector.empty())
		{
		for(int i = 0; i<METEORCOUNT; i++)
		{
			if(col.CircleTest(enemy.GetBullet(), meteorVector[i]->GetSprite()))
				{
					//win.Close();
					
					//ship.TellDestroyed();
					met[i]->SetDestroyed();
					meteorSound.Play();
					enemy.BulletReset();
				}
			if(col.CircleTest(ship.GetSprite(), meteorVector[i]->GetSprite()))
				{
					//win.Close();
					
					ship.TellDestroyed();
					met[i]->SetDestroyed();
					
				}
			if(col.CircleTest(ship.GetSprite(), sunSp))
				{
					//win.Close();
					
					ship.TellDestroyed();
					//met[i]->SetDestroyed();
				}

			
			if(col.PixelPerfectTest(enemy.GetSprite(), meteorVector[i]->GetSprite()))
				{
					//win.Close();
					
					enemy.DecreaseHealth(10);
					met[i]->SetDestroyed();
					meteorSound.Play();
				}
			if(col.PixelPerfectTest(enemy.GetSprite(), sunSp))
				{
					//win.Close();
					
					enemy.DecreaseHealth(20);
					//met[i]->SetDestroyed();
				}
			//
			if(col.PixelPerfectTest(meteorVector[i]->GetSprite(), enemy.GetNavigator2())||(col.PixelPerfectTest(meteorVector[i]->GetSprite(), enemy.GetNavigator3())||(col.PixelPerfectTest(sunSp, enemy.GetNavigator3()) )))
				{
					//win.Close();
					enemy.MoveLeft(1, &win, ship);
					
				}
			else if(col.PixelPerfectTest(meteorVector[i]->GetSprite(), enemy.GetNavigator1())||(col.PixelPerfectTest(meteorVector[i]->GetSprite(), enemy.GetNavigator4())||(col.PixelPerfectTest(sunSp, enemy.GetNavigator4()) )))
				{
					//win.Close();
					enemy.MoveRight(&win, ship);
					
				}
			
			else
			{
				enemy.Attacking();
				enemy.UpdatePlayerPosition(ship.GetSprite().GetPosition(), &win);
			}

			
		
			
			 
			if(!bulletVector.empty())
			{
			for(int j = 0; j< (int)bulletVector.size(); j++)
			{
				//if((bulletVector[j]->GetSprite().GetPosition().x >= meteorVector[i]->GetSprite().GetPosition().x && bulletVector[j]->GetSprite().GetPosition().x < meteorVector[i]->GetSprite().GetPosition().x +meteorVector[i]->GetSprite().GetSize().x ) && (bulletVector[j]->GetSprite().GetPosition().y >= meteorVector[i]->GetSprite().GetPosition().y && bulletVector[j]->GetSprite().GetPosition().y <  meteorVector[i]->GetSprite().GetPosition().y + meteorVector[i]->GetSprite().GetSize().x))
				//{
				//	//win.Close();
				//	bulletVector[j]->Hit();
				//	meteorVector[i]->SetDestroyed();
				//	delete bulletVector[j];
				//	bulletVector.erase(bulletVector.begin() + j);
				//}
				if(col.PixelPerfectTest(enemy.GetBullet(), ship.GetSprite()))
				{
					//ship.TellDestroyed();
					/*ship.DecreaseHealth();
					if(ship.GetHealth()<=0)
					{
						ship.TellDestroyed();
					}*/
				}
				if(col.PixelPerfectTest(bulletVector[j]->GetSprite(), enemy.GetSprite()))
				{
					enemy.DecreaseHealth();
					meteorSound.Play();
					bulletVector[j]->Hit();
					delete bulletVector[j];
					bulletVector.erase(bulletVector.begin() + j);
				}
				else if(col.PixelPerfectTest(bulletVector[j]->GetSprite(), meteorVector[i]->GetSprite()))
				{
					bulletVector[j]->Hit();
					meteorVector[i]->SetDestroyed();
					meteorSound.Play();
					delete bulletVector[j];
					bulletVector.erase(bulletVector.begin() + j);
				}

				
				//if(col.BoundingBoxTest(bulletVector[j]->GetBulletSprite(), meteorVector[i]->GetSprite()))//collision condition should be checked here bullet and other ships
				//{
				//	cout<<i<<"T";
				//	cout<<j<<"T";
				//	win.Close();
				//	bulletVector[j]->Hit();

				//}
			}
		}
		}
		}
		ship.UpdateAI();
		if(enemy.GetPositionY()>ship.GetPositionY()-700)
		enemy.UpdateAI();
		if(enemy.IsDestroyed())
		{
			lowestx=200, highestx=620; 
			rangex=(highestx-lowestx)+1; 
			random_integerx;
			random_integerx = lowestx+int(rangex*rand()/(RAND_MAX + 1.0)); 
			enemy.EnemyReset(random_integerx, ship);
			if(!ship.IsDestroyed())
			{
			ship.IncreaseScore(10);
			ship.UpdateScore();
			}
		}
		//win.Draw(sp);
		//win.Draw(sp2);
		//win.Draw(sp3);
		ship.UpdateHealth();
		Drawing drawing;
		drawing.win = &win;
		drawing.ship = &ship;
		drawing.enemy = &enemy;
		drawing.Bulletvectors = bulletVector;
		drawing.MeteorCounts = METEORCOUNT;
		for(int i = 0; i<5; i++)
		drawing.met[i] = met[i];
		win.Draw(sunSp);
		for(int i = 0; i< 10; i++)		win.Draw(spStar[i]);
		//win.Draw(spStar1);
		//ship.UpdateScore();
//		DrawingTHread(drawing);
		ship.Draw(&win);
		//score.SetPosition(100,100);
		//win.Draw(score);
		if(enemy.GetPositionY()>ship.GetPositionY()-700)
			enemy.Draw(&win, ship);
		
		for(int i = 0; i<METEORCOUNT; i++)
		{
			
			met[i]->Draw(&win);
		}
		
		if(!bulletVector.empty())
		{
			
		for(int i = 0; i<(int)bulletVector.size();i++)
		{
			//d.Bulletvectors[i]->ChangeType(type);
			bulletVector[i]->Fired();
			bulletVector[i]->Draw(&win, &ship);
			bulletVector[i]->UpdateBullet(win.GetFrameTime());
			
			
			
			bulletVector[i]->UpdateAI();
			//if(d.Bulletvectors[i]->GetPositiony()<=ship.GetPositionY()-500) win.Close();
			if(bulletVector[i]->GetPositiony()<ship.GetPositionY()-600)
			{
				delete bulletVector[i];
				bulletVector.erase(bulletVector.begin()+i);
				//count = d.Bulletvectors.size();
				//cout<<count<<"\n";

			}
		}
		}	
		
		win.SetView(ship.GetView());
		
		
		win.Display();
	}
	return 1;
}
예제 #24
0
int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
	displayWindow = SDL_CreateWindow("Space Invaders", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 500, 500, SDL_WINDOW_OPENGL);
	SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
	SDL_GL_MakeCurrent(displayWindow, context);
	#ifdef _WINDOWS
		glewInit();
	#endif

	ShaderProgram* program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl");
	glViewport(0, 0, 500, 500);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	Matrix modelMatrixMain;
	Matrix modelMatrixOver;
	Matrix viewMatrix;
	Matrix projectionMatrix;
	projectionMatrix.setOrthoProjection(-2.0, 2.0, -2.0f, 2.0f, -1.0f, 1.0f);

	GLuint textSheet = LoadTexture(RESOURCE_FOLDER"font1.png");
	GLuint spriteSheet = LoadTexture(RESOURCE_FOLDER"sheet.png");
	SheetSprite playerSprite(program, spriteSheet, 112.0f / 1024.0f, 866.0f / 1024.0f, 112.0f / 1024.0f, 75.0f / 1024.0f, 0.15, GL_CLAMP);
	SheetSprite playerShotSprite(program, spriteSheet,	809.0f / 1024.0f, 437.0f / 1024.0f, 19.0f / 1024.0f, 30.0f / 1024.0f, 0.1, GL_CLAMP);
	SheetSprite enemySprite(program, spriteSheet, 423.0f / 1024.0f, 728.0f / 1024.0f, 93.0f / 1024.0f, 84.0f / 1024.0f, 0.15, GL_CLAMP);
	SheetSprite enemyShotSprite(program, spriteSheet, 856.0f / 1024.0f, 421.0f / 1024.0f, 9.0f / 1024.0f, 54.0f / 1024.0f, 0.1, GL_CLAMP);
	
	Ship player(program, playerSprite, playerShotSprite, 0.0f, -0.95f, 1.0f, false);
	std::vector<Ship> enemies;
	for (int row = 0; row < 4; row++){
		for (int col = 0; col < 8; col++) {
			if (row == 0){
				Ship enemy(program, enemySprite, enemyShotSprite, -1.5f + (col * 0.4f), 1.5f, 0.0, true);
				enemies.push_back(enemy);
			}
			else if (row == 1){
				Ship enemy(program, enemySprite, enemyShotSprite, -1.5f + (col * 0.4f), 1.0, 0.0, true);
				enemies.push_back(enemy);
			}
			else if (row == 2){
				Ship enemy(program, enemySprite, enemyShotSprite, -1.5f + (col * 0.4f), 0.5f, 0.0, true);
				enemies.push_back(enemy);
			}
			else if (row = 3){
				Ship enemy(program, enemySprite, enemyShotSprite, -1.5f + (col * 0.4f), 0.0f, 0.0, true);
				enemies.push_back(enemy);
			}
		}
	}
	int enemiesAlive = enemies.size();

	SDL_Event event;
	bool done = false;
	while (!done) {
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) {
				done = true;
			}
		}
		glClear(GL_COLOR_BUFFER_BIT);

		program->setViewMatrix(viewMatrix);
		program->setProjectionMatrix(projectionMatrix);
		glUseProgram(program->programID);

		switch (gameState)
		{
		case INTRO:
			program->setModelMatrix(modelMatrixMain);
			modelMatrixMain.identity();
			modelMatrixMain.Translate(-1.4f, -0.5, 0.0f);
			DrawText(program, textSheet, "Press Enter To Start", 0.15, 0.0005f);
			program->setModelMatrix(modelMatrixOver);
			modelMatrixOver.identity();
			modelMatrixOver.Translate(-1.625f, 0.5, 0.0f);
			DrawText(program, textSheet, "SPACE INVADERS", 0.25, 0.0005f);
			if (keys[SDL_SCANCODE_RETURN]) { 
				gameState = GAME;
			}
			break;
		case GAME:
			if (player.alive && enemiesAlive > 0){
				player.Update(player.xPos, player.sprite, player.bullet, player.alive, enemiesAlive);
				for (int i = 0; i < 32; i++) enemies[i].Update(player.xPos, player.sprite, player.bullet, player.alive, enemiesAlive);
			}
			
			break;
		}

		SDL_GL_SwapWindow(displayWindow);
	}

	SDL_Quit();
	return 0;
}
      void TestModelControler::attackAllEnemies()
      {
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies entering") ;
        // 1. build a model
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestModelControler::attackAllEnemies")) ;
        model->init() ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies inited") ;

        Kernel::Object* team1 = model->createObject() ;
        team1->addTrait(new Model::Team("team1")) ;
        Kernel::Object* team2 = model->createObject() ;
        team2->addTrait(new Model::Team("team2")) ;

        Kernel::Object* universe = model->createObject() ;
        universe->addTrait(new Model::Universe()) ;
        universe->addTrait(new Model::Positioned()) ;

        Kernel::Object* system = universe->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;

        Kernel::Object* observer = system->createObject() ;
        observer->addTrait(new Model::Observer()) ;
        observer->addTrait(new Model::Player()) ;
        observer->addTrait(new Model::Active()) ;
        observer->addTrait(new Model::Positioned(Model::Position::Meter(400,1500,-1000))) ;
        observer->addTrait(new Model::Oriented(Model::Orientation(::Ogre::Quaternion(::Ogre::Degree(-90),::Ogre::Vector3::UNIT_X)))) ;

        Kernel::ObjectReference ship1 ;
        {
          Kernel::Object* ship = Model::createShip(system) ;
          ship->getTrait<Model::Positioned>()->setPosition(Model::Position::Meter(0,0,0)) ;
          ship->addTrait(new Model::Transponder(team1)) ;
          Kernel::Object* agent = Model::createAI(ship) ;
          agent->getTrait<Model::WithObjectives>()->addObjective(Model::Objective::attackAllEnemies()) ;
          ship1 = ship ;
        }

        // the attacked enemy ship
        Kernel::Object* enemy_ship = system->createObject() ;
        enemy_ship->addTrait(new Model::Positioned(Model::Position::Meter(500,0,-1000))) ;
        enemy_ship->addTrait(new Model::Massive(Model::Mass::Kilogram(1000))) ;
        enemy_ship->addTrait(new Model::Oriented()) ;
        enemy_ship->addTrait(new Model::Mobile()) ;
        enemy_ship->addTrait(new Model::Solid(Model::Mesh("default_ship.mesh"))) ;
        enemy_ship->addTrait(new Model::Transponder(team2)) ;
        enemy_ship->addTrait(new Model::Destroyable(Model::Energy::Joule(1))) ;
        enemy_ship->addTrait(new Model::Dragger(Kernel::Parameters::getValue<float>("Model","DraggerCoeeficient",0.01))) ;
        {
          Kernel::Object* st1 = enemy_ship->createObject() ;
          st1->addTrait(new Model::Stabilizer(0,Kernel::Parameters::getValue<float>("Model","StabilizerForce",10),0)) ;
          st1->addTrait(new Model::Component()) ;

          Kernel::Object* st2 = enemy_ship->createObject() ;
          st2->addTrait(new Model::Stabilizer(Kernel::Parameters::getValue<float>("Model","StabilizerForce",10),0,0)) ;
          st2->addTrait(new Model::Component()) ;

          Kernel::Object* st3 = enemy_ship->createObject() ;
          st3->addTrait(new Model::Stabilizer(0,0,Kernel::Parameters::getValue<float>("Model","StabilizerForce",10))) ;
          st3->addTrait(new Model::Component()) ;
        }

        Kernel::ObjectReference enemy(enemy_ship) ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies created") ;

        Kernel::Timer timer ;
        Kernel::Timer global_timer ;

        while (global_timer.getSecond() < 10)
        {
          float seconds = timer.getSecond() ;
          if (seconds > 0)
          {
            timer.reset() ;
            model->update(seconds) ;
          }
        }

        // enemy is destroyed
        CPPUNIT_ASSERT(!enemy) ;
        InternalMessage("Demonstration","Demonstration::TestModelControler::attackAllEnemies leaving") ;
      }
예제 #26
0
void fightSmiley(chara *hero, int ind, int enN){

    char ene[1020] = "";
    char ename[20];
    chara bad;
    bad.xp = 0;

    enemy(ene, &bad, ename, enN);

    int hp = hero->hp;
    int enehp = (bad.hp)*ind;
    char f1 = 'X';
    char f2 = ' ';
    char f3 = ' ';
    char f4 = ' ';
    char texto[30];

    sprintf(texto, "an evil %s has appeared ", ename);

    int choice = 3;

    while(enehp > 0 && hp > 0){
        clear();
        refresh();
        printw("%s", ene);
        printw("|--------------------------------------------------------------------------|\n");
        printw("||                                       +---------------------------------|\n");
        printw("|| %s          | %c attack                      |-|\n", texto, f1);
        printw("|| hp = %2d                               | %c magic                       |-|\n", hp, f2);
        printw("|| enemy hp = %2d                         | %c healing magic               |-|\n", enehp, f3);
        printw("||                                       | %c guard                       |-|\n", f4);
        printw("||                                       +---------------------------------|\n");
        printw("|--------------------------------------------------------------------------|\n");
        printw("+--------------------------------------------------------------------------+\n");
        switch(arrkeys()){
            case 'x':
                endwin();
                exit(0);
                break;
            case 'u':
                choice = (choice+1)%4;
                break;
            case 'd':
                choice -= 1;
                if(choice < 0){
                    choice = 3;
                }
                break;
            case 'q':
                switch(choice){
                    case 3:
                        sprintf(texto, "you've attacked evil %s ", ename);
                        enehp-=(hero->st-(bad.def));
                        hp -= -(hero->def-(bad.st+rand()%5));
                        break;
                    case 2:
                        strcpy(texto, "you've used magic!          ");
                        enehp -= (hero->sp-(bad.sp+rand()%15));
                        hp -= -(hero->def-(bad.st+rand()%5));
                        break;
                    case 1:
                        sprintf(texto, "you used healing magic      ");
                        hp = hp + hero->sp/2;
                        hp -= -(hero->def-(bad.st+rand()%5));
                        break;
                    case 0:
                        strcpy(texto, "you  guard to reduce damage ");
                        hp -= -((hero->def*2)-(bad.st+rand()%5));
                        break;
                }
                break;
        }
        switch(choice){
            case 3:
                f1 = 'X';
                f2 = ' ';
                f3 = ' ';
                f4 = ' ';
                break;
            case 2:
                f1 = ' ';
                f2 = 'X';
                f3 = ' ';
                f4 = ' ';
                break;
            case 1:
                f1 =' ';
                f2 =' ';
                f3 ='X';
                f4 =' ';
                break;
            case 0:
                f1 =' ';
                f2 =' ';
                f3 =' ';
                f4 ='X';
                break;
        }

        if(hp > (hero->hp)){
            hp = hero->hp;
        }

    }

    if(hp <= 0){

        clear();
        refresh();

        printw("                                            \n");
        printw("  /$$$$$$   /$$$$$$  /$$      /$$ /$$$$$$$$ \n");
        printw(" /$$__  $$ /$$__  $$| $$$    /$$$| $$_____/ \n");
        printw("| $$  \\__/| $$  \\ $$| $$$$  /$$$$| $$       \n");
        printw("| $$ /$$$$| $$$$$$$$| $$ $$/$$ $$| $$$$$    \n");
        printw("| $$|_  $$| $$__  $$| $$  $$$| $$| $$__/    \n");
        printw("| $$  \\ $$| $$  | $$| $$\\  $ | $$| $$       \n");
        printw("|  $$$$$$/| $$  | $$| $$ \\/  | $$| $$$$$$$$ \n");
        printw(" \\______/ |__/  |__/|__/     |__/|________/ \n");
        printw("                                            \n");
        printw("                                            \n");

        x_sleep(100);
        refresh();

        printw("                                            \n");
        printw("  /$$$$$$  /$$    /$$ /$$$$$$$$ /$$$$$$$    \n");
        printw(" /$$__  $$| $$   | $$| $$_____/| $$__  $$   \n");
        printw("| $$  \\ $$| $$   | $$| $$      | $$  \\ $$   \n");
        printw("| $$  | $$|  $$ / $$/| $$$$$   | $$$$$$$/   \n");
        printw("| $$  | $$ \\  $$ $$/ | $$__/   | $$__  $$   \n");
        printw("| $$  | $$  \\  $$$/  | $$      | $$  \\ $$   \n");
        printw("|  $$$$$$/   \\  $/   | $$$$$$$$| $$  | $$   \n");
        printw(" \\______/     \\_/    |________/|__/  |__/   \n");
        printw("                                            \n");
        printw("                                            \n");
        printw("                                            \n");

        x_sleep(100);
        refresh();
        x_pause();
        endwin();
        exit(0);

    }

    else{

        hero->xp += (rand()%900)/hp;

        if (hero->xp >= 100){
            hero->hp += rand()%10;
            hero->st += rand()%3;
            hero->sp += rand()%4;
            hero->def += rand()%5;
            hero->xp = 0;
        }

        clear();
        refresh();

        printw("+--------------------------------------------------------------------------+\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("|                                                                          |\n");
        printw("+--------------------------------------------------------------------------+\n");
        printw("                                                                            \n");
        printw("|--------------------------------------------------------------------------|\n");
        printw("||                                       +---------------------------------|\n");
        printw("|| you've defeated the evil %s       |                               |-|\n", ename);
        printw("|| CONGRATULATIONS!                      |                               |-|\n");
        printw("||                                       |                               |-|\n");
        printw("||                                       +---------------------------------|\n");
        printw("|--------------------------------------------------------------------------|\n");
        printw("+--------------------------------------------------------------------------+\n");

        refresh();
        x_pause();

        clear();
        refresh();

        printw("                                                                \n");
        printw("__/\\\\\\________/\\\\\\_______/\\\\\\\\\\_______/\\\\\\________/\\\\\\_         \n");
        printw(" _\\///\\\\\\____/\\\\\\/______/\\\\\\///\\\\\\____\\/\\\\\\_______\\/\\\\\\_        \n");
        printw("  ___\\///\\\\\\/\\\\\\/______/\\\\\\/__\\///\\\\\\__\\/\\\\\\_______\\/\\\\\\_       \n");
        printw("   _____\\///\\\\\\/_______/\\\\\\______\\//\\\\\\_\\/\\\\\\_______\\/\\\\\\_      \n");
        printw("    _______\\/\\\\\\_______\\/\\\\\\_______\\/\\\\\\_\\/\\\\\\_______\\/\\\\\\_     \n");
        printw("     _______\\/\\\\\\_______\\//\\\\\\______/\\\\\\__\\/\\\\\\_______\\/\\\\\\_    \n");
        printw("      _______\\/\\\\\\________\\///\\\\\\__/\\\\\\____\\//\\\\\\______/\\\\\\__   \n");
        printw("       _______\\/\\\\\\__________\\///\\\\\\\\\\/______\\///\\\\\\\\\\\\\\\\\\/___  \n");
        printw("        _______\\///_____________\\/////__________\\/////////_____ \n");

        x_sleep(100);
        refresh();

        printw("__/\\\\\\______________/\\\\\\__/\\\\\\\\\\\\\\\\\\\\\\__/\\\\\\\\\\_____/\\\\\\_        \n");
        printw(" _\\/\\\\\\_____________\\/\\\\\\_\\/////\\\\\\///__\\/\\\\\\\\\\\\___\\/\\\\\\_       \n");
        printw("  _\\/\\\\\\_____________\\/\\\\\\_____\\/\\\\\\_____\\/\\\\\\/\\\\\\__\\/\\\\\\_      \n");
        printw("   _\\//\\\\\\____/\\\\\\____/\\\\\\______\\/\\\\\\_____\\/\\\\\\//\\\\\\_\\/\\\\\\_     \n");
        printw("    __\\//\\\\\\__/\\\\\\\\\\__/\\\\\\_______\\/\\\\\\_____\\/\\\\\\\\//\\\\\\\\/\\\\\\_    \n");
        printw("     ___\\//\\\\\\/\\\\\\/\\\\\\/\\\\\\________\\/\\\\\\_____\\/\\\\\\_\\//\\\\\\/\\\\\\_   \n");
        printw("      ____\\//\\\\\\\\\\\\//\\\\\\\\\\_________\\/\\\\\\_____\\/\\\\\\__\\//\\\\\\\\\\\\_  \n");
        printw("       _____\\//\\\\\\__\\//\\\\\\_______/\\\\\\\\\\\\\\\\\\\\\\_\\/\\\\\\___\\//\\\\\\\\\\_ \n");
        printw("        ______\\///____\\///_______\\///////////__\\///_____\\/////__\n");
        printw("                                                                \n");
        printw("                                                                \n");

        x_sleep(100);
        refresh();
        x_pause();

    }

}
예제 #27
0
파일: Game.cpp 프로젝트: Qata/Wibbly
int Game::run()
{
	int retVal = 0;

	if (Map::mapData->running())
	{
		changeScreenSize(msurf_MapSurface, msurf_Screen, gfx::getScreenWidth(), gfx::getScreenHeight());
		gfx::blit(msurf_Screen());	
		double completed = Map::mapData->getState();

		boxRGBA(gfx::getScreen(), gfx::getScreenWidth() / 24, gfx::getScreenHeight() / 20, (gfx::getScreenWidth() / 3 * 2), gfx::getScreenHeight() / 10, 50, 50, 50, 255);
		boxRGBA(gfx::getScreen(), gfx::getScreenWidth() / 24, gfx::getScreenHeight() / 20, (int)(completed * (gfx::getScreenWidth() / 3 * 2)), gfx::getScreenHeight() / 10, 255, 50, 50, 255);
		rectangleRGBA(gfx::getScreen(), gfx::getScreenWidth() / 24, gfx::getScreenHeight() / 20, (gfx::getScreenWidth() / 3 * 2), gfx::getScreenHeight() / 10, 255, 50, 50, 255);
		gfx::drawText((int)(completed * 100), gfx::getScreenWidth() / 20, gfx::getScreenHeight() / 20 + gfx::getFontHeight() / 3);
	}
	else
	{
		changeScreenSize(msurf_MapSurface, msurf_Screen, gfx::getScreenWidth(), gfx::getScreenHeight());

		Surface screen(SDL_ConvertSurface(msurf_Screen(), msurf_Screen->format, msurf_Screen->flags));

		if (input::keyHeld('i'))
		{
			shared_ptr<Enemy> enemy(new Enemy("enemy.png", 32, true));
			m_Enemies.push_back(enemy);
			m_Entities.push_front(enemy);
		}

		if (input::keyHeld('k'))
		{
			if (m_Enemies.size())
			{
				m_Enemies.begin()->get()->setState(false);
			}
		}

		if (!std::all_of(m_Enemies.begin(), m_Enemies.end(), [](shared_ptr<Entity> en){return en->getState();}))
		{
			//There are dead enemies in the array
			for (auto iter = m_Enemies.rbegin(); iter != m_Enemies.rend(); iter++)
			{
				Enemy * enemy = (*iter).get();
				if (!enemy->getState())
				{
					enemy->yield();
					m_Enemies.remove(*iter);
					m_Entities.remove(*iter);
				}
			}
		}

		if (player->move(screen, 0))
		{
			mui_TurnCounter++;
			for (auto iter = m_Enemies.begin(); iter != m_Enemies.end(); iter++)
			{
				shared_ptr<Enemy> enemy = (*iter);
				enemy->move(player.get());
			}
		}

		for (auto iter = m_Entities.begin(); iter != m_Entities.end(); iter++)
		{
			shared_ptr<Entity> entity = (*iter);
			if (entity->collide(player.get()))
			{
				player->addInventoryItem((Pickup *)entity.get());
			}
			entity->update(screen->w, screen->h, Map::width(), Map::height());
			entity->draw(screen, screen->w / Map::width());
		}

		//drawFog(screen);
		
		gfx::blit(screen(), nullptr, &screen->clip_rect);

		drawCursor(screen->w);

		gfx::drawText((string)"Turn: " + turnString(), 0, 0);
	}

	if (input::keyHeld(SDLK_ESCAPE))
	{
		sound::stopMusic();
		gfx::showCursor();
		retVal = MENU;
	}

	return retVal;
}
예제 #28
0
파일: endgame.c 프로젝트: ageneau/scid
int pawns(void)
{

extern int wpf[10];
extern int bpf[10];
int result;
int color;
int wbest=32, bbest=32;
static int passed[16] =
	{ 0, 100, 75, 50, 30, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

static int kbonus_[80] =
{
  0,  0,  1,  2,  3,  3,  2,  1,  0, 0,
  0, 10, 11, 12, 13, 13, 12, 11, 10, 0,
  0, 20, 21, 22, 23, 23, 22, 21, 20, 0,
  0, 30, 31, 32, 33, 33, 32, 31, 30, 0,
  0, 40, 41, 42, 43, 43, 42, 41, 40, 0,
  0, 50, 51, 52, 53, 53, 52, 51, 50, 0,
  0, 50, 51, 52, 53, 53, 52, 51, 50, 0,
  0, 42, 45, 47, 48, 48, 47, 45, 42, 0
}; const int * kbonus = kbonus_-20;

if( Totmat == P_VALUE )  /* KPK routine */
{
	int wk, wp, bk, wtm;

	if( Color==WHITE ) wtm=1; else wtm=0;

	if( L[WKP].next != 0 )
	{	wk = WKP; wp = L[WKP].next; bk = BKP;
		result = onepawn(wk,wp,bk,wtm);
	}
	else
	{	wk = Th[BKP]; wp = Th[L[BKP].next]; bk = Th[WKP];
		wtm = !wtm;
		result = -onepawn(wk,wp,bk,wtm);
	}

	if(Color==WHITE) return result; else return -result;
} 

#define bonus(x) ( color==WHITE ? (x) : -(x) )

result = kbonus[WKP]-kbonus[Th[BKP]];

for( color=1; color!=3; color++ )
{
	int step = ( color==WHITE ? 10 : -10 );
	int best = 32;
	unsigned pawn = PAWN+color;
	unsigned xpawn = PAWN+enemy(color);
	unsigned kp = L[color].next;
	unsigned xkp = L[enemy(color)].next;
	int * pf = ( color==WHITE ? wpf : bpf );
	int s;  /* square */
	int i;

	for( i=1; i!=9; i++ ) pf[i]=0;

	for( s = L[kp].next; s != 0; s = L[s].next )
	{
		int b, togo;
		int blocks = 0;
		int cannotmove;
		int protected;
		int stepstosquare;

		pf[s%10]++;

		/* doubled pawn */
		if( pf[s%10] > 1 ) result -= bonus(8);

		if( B[s+step] ) cannotmove = 1;
		else
		{
			int f=0;
			if( B[s+step+step+1] == xpawn ) f++;
			if( B[s+step+step-1] == xpawn ) f++;
			if(f)
			{
				if( B[s+1] == pawn ) f--;
				if( B[s-1] == pawn ) f--;
				cannotmove = (f>0);
			} else cannotmove=0;
		}

		if(cannotmove) result -= bonus(6);

		protected = ( B[s-step-1]==pawn || B[s-step+1]==pawn );

		/* lets make kings active */
		if( ! protected )
		{
			int di = dist[120*xkp+s].max;
			if(cannotmove) b = bonus( 32-4*di );
			else b = bonus( 16-2*di );
			if(di==1)
			{ if(cannotmove) b+=30; else b+=20; }

			result -= b;
		}

		if( B[s+step] == xpawn ) goto end_passed;
		for( i=s+step+step; B[i]!=3; i+=step )
		{
			if( B[i] ) blocks++;
			if( B[i]==xpawn || B[i-1]==xpawn || B[i+1]==xpawn )
				goto end_passed;
		}

		/*** BEGIN: passed pawn evaluation ***/

		i -= step;                  /* the queening square */
		togo = blocks+abs(s-i)/10;  /* steps to queen */
		b = bonus(passed[togo]);
		result += b;

		/* protected passer -> more bonus */
		if( protected ) result += b+b;

		/* out of enemy's king square */
		stepstosquare=(int)(dist[xkp*120+i].max)-togo+(Color==color);

		if( stepstosquare>1 )
		{
			result += b+b;
			if( togo < best ) best = togo;
		}

		/* distance from enemy king */
		b = dist[xkp*120+s+step].max * (12-togo);
		result += bonus(b);

		/*** END: passed pawn evaluation ***/

		end_passed:;

		/*** some points for advancement ***/
		result += (s/10-4-color)*2;
	}
	if( color == WHITE ) wbest=best; else bbest=best;
}
예제 #29
0
파일: level.cpp 프로젝트: AlexStopar/Bound
void playLevel(SDL_Renderer* renderer, SDL_Window* window)
{
	TextureStorage::getInstance().setDifficultyBackground(renderer);
	bool isScoreRecording = false;
	bool isHighScore = false;
	bool isPaused = false;
	std::random_device rd;
	std::mt19937 eng(rd());
	std::uniform_int_distribution<> randomX(2 * WALL_WIDTH, SCREEN_WIDTH - (2 * WALL_WIDTH));
	std::uniform_int_distribution<> randomY(2 * WALL_WIDTH, SCREEN_HEIGHT - (2 * WALL_WIDTH));
	std::uniform_int_distribution<> randomVortex(0, VORTEX_LIMIT);
	std::string inputText = "";

	SDL_Event e;

	Player player(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, PLAYER_WIDTH, PLAYER_HEIGHT, PLAYER_VEL);
	Collectible collectible(randomX(eng), randomY(eng), resolveCoinWidth(), COIN_HEIGHT, 0);
	Skull skull(0, 0, SKULL_WIDTH, SKULL_HEIGHT, 0);

	std::vector<SDL_Rect> walls = getBoundaries();
	SoundPlayer::getInstance().playMusic();

	while (!isQuitting)
	{
		if (player.isDead)
		{
			SoundPlayer::getInstance().stopMusic();
			if (!isScoreRecording)
			{
				isScoreRecording = HighScore::getInstance().checkAndAddNewScore(score, gameDifficulty);
				if (isScoreRecording)
				{
					isHighScore = true;
					SoundPlayer::getInstance().playHighScore();
				}
			}			
		}
		while (SDL_PollEvent(&e) != 0)
		{
			if (!isPaused) SDL_EventState(SDL_KEYUP, SDL_ENABLE);
			if (e.type == SDL_QUIT)
			{
				isQuitting = true;
				isResetting = false;
				reset();
			}		
			else if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE) toggleFullscreen(window);
			else if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_RETURN && !player.isDead)
			{
				SoundPlayer::getInstance().pauseMusic();
				SoundPlayer::getInstance().playPause();
				if (isPaused) isPaused = false;
				else
				{
					isPaused = true;
					SDL_EventState(SDL_KEYUP, SDL_IGNORE);
				}
					
			}
			if (isPaused) SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
			if (!player.isDead)
			{
				if (!isPaused) player.handleEvent(e);
			}
			else 
			{
				if (e.type == SDL_TEXTINPUT)
				{
					if (inputText.size() < 3 && e.text.text[0] != ',') inputText += e.text.text;
				}
				else if (e.type == SDL_KEYDOWN)
				{
					if (e.key.keysym.sym == SDLK_n && !isHighScore)
					{
						isResetting = false;
						reset();
						return;
					}
					else if (e.key.keysym.sym == SDLK_y && !isHighScore)
					{
						isResetting = true;
						reset();
						return;
					}	
					else if (e.key.keysym.sym == SDLK_BACKSPACE)
					{
						if (inputText.size() != 0) inputText.pop_back();
					}
					else if (e.key.keysym.sym == SDLK_RETURN)
					{
						if (isHighScore) HighScore::getInstance().addInitials(inputText);
						isHighScore = false;
					}
				}
			}
			SDL_EventState(SDL_KEYDOWN, SDL_ENABLE);
		}
		if (!isPaused)
		{
			if (!player.isDead) player.move(walls, enemies, skull);
			else skull.move(walls);
			for (std::vector<Enemy>::iterator it = enemies.begin(); it != enemies.end(); ++it) {
				it->move(walls);
			}

			if (!collectible.isHit)
			{
				prevX = collectible.getX();
				prevY = collectible.getY();
			}

			collectible.move(player, randomX(eng), randomY(eng));
		}

		SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
		SDL_RenderClear(renderer);

		TextureStorage::getInstance().bgTexture.render(0, 0, renderer);
		renderWalls(renderer, walls);
		
		for (std::vector<Enemy>::iterator it = enemies.begin(); it != enemies.end(); ++it) {
			it->render(renderer);
		}
		collectible.render(renderer);

		if (!player.isDead) player.render(renderer);
		else skull.render(renderer);

		TextDraw::getInstance().renderHUD(renderer);
		if (collectible.isHit)
		{
			time++;
			TextDraw::getInstance().renderScoreGain(prevX, prevY, renderer);
			prevX++;
			prevY--;
			if (time == 20)
			{
				time = 0;
				Enemy enemy(randomX(eng), randomY(eng), ENEMY_WIDTH, ENEMY_HEIGHT, ENEMY_VEL * (int)gameDifficulty, EnemyType::SPIKEBALL);
				if (randomVortex(eng) > VORTEX_LIMIT / (int)gameDifficulty)
				{
					Enemy vortex(randomX(eng), randomY(eng), ENEMY_WIDTH, ENEMY_HEIGHT, 0, EnemyType::VORTEX);
					while (checkCollision(vortex.getHitbox(), player.getHitbox()))
					{
						vortex.setX(randomX(eng));
						vortex.setY(randomY(eng));
						vortex.setHitbox();
					}
					enemies.push_back(vortex);
				}
				while (checkCollision(enemy.getHitbox(), player.getHitbox()))
				{
					enemy.setX(randomX(eng));
					enemy.setY(randomY(eng));
					enemy.setHitbox();
				}
				enemies.push_back(enemy);
				collectible.isHit = false;
			}
		}
		if (player.isDead) TextDraw::getInstance().renderGameOver(renderer, isHighScore, inputText);
		if (isPaused)TextDraw::getInstance().renderPause(renderer);
		SDL_RenderPresent(renderer);
		frameCount++;
		if (frameCount == DISPLAY_LIMIT) frameCount = 0;
	}
}
예제 #30
0
int main( int argc, char* args[] )
{
    //Initialize
    init();
    update=new Timer();
    update->start();

    SDL_Surface * game_over = IMG_Load( "game_over.png" );


    Background background(screen);
    Player player(screen);
    Enemy enemy(screen);
    Enemy enemy2(screen);
    Llama Llama(screen);

    SDL_Event event;
    //Quit flag
    bool quit = false;
    while( quit == false )
    {
        //If there's an event to handle
        if( SDL_PollEvent( &event ) )
        {
            //If a key was pressed
            if( event.type == SDL_KEYDOWN )
            {
                //Set the proper message surface
                switch( event.key.keysym.sym )
                {
                    case SDLK_ESCAPE: quit = true; break;
                    case SDLK_UP:
                        if (! player.isJumping){
                            player.jump(); break;
                        }


                }
            }
            //If the user has Xed out the window
            else if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        background.logic();
        player.logic();
        enemy.logic();
        enemy2.logic2();
        Llama.logic();

        if(player.x-enemy.x<50
           && player.x-enemy.x>-50
           && player.y-enemy.y<50
           && player.y-enemy.y>-50
            or player.x-Llama.x<50
           && player.x-Llama.x>-50
           && player.y-Llama.y<50
           && player.y-Llama.y>-50)
        {
            player.perder();
        }

        if(player.x-enemy2.x<50
           && player.x-enemy2.x>-50
           && player.y-enemy2.y<50
           && player.y-enemy2.y>-50
           or player.x-Llama.x<50
           && player.x-Llama.x>-50
           && player.y-Llama.y<50
           && player.y-Llama.y>-50)
        {
           player.perder();
        }

        if (player.murio)
                break;
        background.render();
        player.render();
        enemy.render();
        enemy2.render();
        Llama.render();

        frameCap();

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }

    }

    while( quit == false )
    {
        //If there's an event to handle
        if( SDL_PollEvent( &event ) )
        {
            //If a key was pressed
            if( event.type == SDL_KEYDOWN )
            {
                //Set the proper message surface
                switch( event.key.keysym.sym )
                {
                    case SDLK_ESCAPE: quit = true; break;
                }
            }
            //If the user has Xed out the window
            else if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        //SDL_Rect offset;
        offset.x = 0;
        offset.y = 0;


        SDL_BlitSurface( game_over, NULL, screen, &offset );

        frameCap();

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }
    }

    //SDL_Quit();

    return 0;
}