Example #1
0
void violet::HUD::draw(GameState* gameState, Player* player) {
	float health = player->getHealth() / player->MaxHealth();
	float experience = (float) (player->Xp - player->LastLevelXp)
			/ (player->NextLevelXp - player->LastLevelXp);

	VideoMode screen = m_videoManager->getVideoMode();

	drawMessages();
	drawTime(gameState);

	applyEffects(health, player->LevelPoints);

	int bottomBasePoint = m_videoManager->getVideoMode().Height
			- m_videoManager->RegularText->getIndent() * 2;

	drawHealth(health, bottomBasePoint);
	drawExperience(experience, player->LevelPoints, bottomBasePoint);

	drawInventory(player);

	if (gameState->Lost && !gameState->Paused)
		drawEndGameScreen(gameState, player->Xp);

	if (!gameState->Lost)
		if (Info != "")
			m_videoManager->RegularText->draw(Info.c_str(),
					m_videoManager->getVideoMode().Width / 2,
					m_videoManager->RegularText->getIndent(),
					TextManager::CENTER, TextManager::TOP);

	if (gameState->Paused)
		m_videoManager->RegularText->draw(_("PAUSE"), screen.Width / 2,
				screen.Height / 2, TextManager::CENTER, TextManager::MIDDLE);
}
void drawHud()
{
    int16_t oldDrawTransX = drawTransX;
    int16_t oldDrawTransY = drawTransY;
    
    drawTransX = kHudX;
    drawTransY = kHudY;
    
    fillRect(0, 0, kHudWidth, kHudHeight, BLACK);
    
    // gun
    drawImagePtr(IMG_HUD_GUN, kHudGunX, kHudGunY, DM_LIT);
    
    // ammo
    drawAmmo(playerAmmo);
    
    // heart
    drawImagePtr(IMG_HUD_HEART, kHudHeartX, kHudHeartY, DM_LIT);
    
    // health
    drawHealth(playerHealth);
    
    // logo
    drawImagePtr(IMG_HUD_LOGO, kHudLogoX, kHudLogoY, DM_LIT);
    
    drawTransX = oldDrawTransX;
    drawTransY = oldDrawTransY;
}
Example #3
0
bool Interface::draw(LPDDSurface surface, World *world){
	//dprintf(("entered Interface::draw()\n"));
	//HRESULT r = DD_OK;
	drawHealth(surface, world->character->getHealth());
	if(actionMenu->isActive())
		if(!actionMenu->draw(surface)) return false;

	//dprintf(("leaving Interface::draw()\n"));
	return true;
}
Example #4
0
/**
 * This is always called before Smiley is drawn.
 */
void CandyBoss::draw(float dt) {
	
	drawNovas(dt);

	if (!shouldDrawAfterSmiley) {
		drawBartli();
	}

	//Draw the health bar and lives
	if (state != CANDY_STATE_INACTIVE) {
		drawHealth("Bartli");
		for (int i = 0; i < numLives; i++) {
			smh->resources->GetSprite("bartletBlue")->RenderEx(766.0 + 35.0 * i, 75.0, 0.0, 0.43, 0.43);
		}
	}
}
Example #5
0
void FenwarBoss::draw(float dt) 
{
	smh->drawGlobalSprite("playerShadow", x, y + FENWAR_HEIGHT/2.0);

	float flashAlpha;
	if (flashing) 
	{
		flashAlpha = smh->getFlashingAlpha(FLASHING_DURATION / 4.0);
	} 
	else
	{
		flashAlpha = 255.0;
	}
	smh->resources->GetAnimation("fenwar")->SetColor(ARGB(flashAlpha, 255.0, 255.0, 255.0));
	smh->resources->GetAnimation("fenwarFace")->SetColor(ARGB(flashAlpha, 255.0, 255.0, 255.0));

	orbManager->drawBeforeFenwar(dt);
	smh->resources->GetAnimation("fenwar")->Render(smh->getScreenX(x), smh->getScreenY(y - floatingYOffset));
	smh->resources->GetAnimation("fenwarFace")->Render(smh->getScreenX(x), smh->getScreenY(y - floatingYOffset));

	orbManager->drawAfterFenwar(dt);
	bulletManager->draw(dt);
	bombManager->draw(dt);

	//Stun effect
	if (state == FenwarStates::STUNNED_AFTER_LOSING_ORBS) {
		for (int n = 0; n < NUM_STUN_STARS; n++) {
			stunStarAngles[n] += 1.5* PI * dt;
			smh->resources->GetSprite("stunStar")->Render(
				smh->getScreenX(x + cos(stunStarAngles[n])*25), 
				smh->getScreenY(y + sin(stunStarAngles[n])*7) - 40.0 - floatingYOffset);
		}
	}

	if (smh->isDebugOn())
	{
		smh->drawCollisionBox(collisionBox, Colors::RED);
	}

	if (state != FenwarStates::INACTIVE && state != FenwarStates::NEAR_DEATH &&
		state != FenwarStates::RETURN_TO_ARENA)
	{
		drawHealth("Lord Fenwar");
	}
}
Example #6
0
void Game::ComposeFrame()
{	
	spriteobj2->Begin(D3DXSPRITE_ALPHABLEND);
	drawHealth();

	const int baseY = 900;
	//quick function that does this char buffer thing. UP ABOVE
	char buffer[64];
	sprintf(buffer, "Seconds elapsed: %.2f", secondsSinceStart);
	//gfx.FontPrint(fontGaramond36, 50, baseY, buffer, D3DCOLOR_XRGB(255, 255, 255));
	writeText(fontGaramond36, 50, baseY, D3DCOLOR_XRGB(255, 255, 255), buffer);

	char buffer2[64];
	sprintf(buffer, "Squads defeated: %d/%d", squadsDefeatedWave, squadsPerWave);
	gfx.FontPrint(fontTimesNewRoman40, 50, baseY - 50, buffer, D3DCOLOR_XRGB(255, 255, 255));

	char buffer8[64];
	sprintf(buffer, "Squads created: %d/%d", squadsCreatedWave, squadsPerWave);
	gfx.FontPrint(fontTimesNewRoman40, 50, baseY - 100, buffer, D3DCOLOR_XRGB(255, 255, 255));

	char buffer3[64];
	sprintf(buffer, "InsectsNoLevel: %d enemyShipNoLevel: %d", totalInsectCreatedLevel, totalEnemyShipCreatedLevel);
	gfx.FontPrint(fontTimesNewRoman40, 50, baseY - 150, buffer, D3DCOLOR_XRGB(255, 255, 255));

	char buffer5[64];
	sprintf(buffer, "No. Ships Killed Level: %d/%d", totalShipKillsLevel, totalShipCreatedLevel);
	gfx.FontPrint(fontTimesNewRoman40, 50, baseY - 200, buffer, D3DCOLOR_XRGB(255, 255, 255));

	char buffer6[64];
	sprintf(buffer, "No. Ships Killed Wave: %d/%d", totalShipKillsWave, totalShipCreatedWave);
	gfx.FontPrint(fontTimesNewRoman40, 50, baseY - 250, buffer, D3DCOLOR_XRGB(255, 255, 255));

	//char buffer7[64];
	//sprintf(buffer, "Wave Count : %d/%d", wave, wavesPerLevel);
	//gfx.FontPrint(fontTimesNewRoman40, 1600, 800, buffer, D3DCOLOR_XRGB(255, 255, 255));

	//sprintf(buffer, "Missile Ammo: %d", playerShip.missileAmmunition);
	//gfx.FontPrint(fontGaramond36, 1500, 980, buffer, D3DCOLOR_XRGB(255, 255, 255));

	//sprintf(buffer, "Locked on to: %d", noOfLockedOn);
	//gfx.FontPrint(fontTimesNewRoman40, 1200, 1000, buffer, D3DCOLOR_XRGB(255, 255, 255));

	if (!playerShip.ifHit) gfx.Sprite_Transform_Draw(playerShipTexture, playerShip.x - ((PLAYERDIMENSION * PLAYERSHIPSCALE) / 2), playerShip.y - ((PLAYERDIMENSION * PLAYERSHIPSCALE) / 2), 250, 250, 0, 1, playerShip.rotation, PLAYERSHIPSCALE);
	else gfx.Sprite_Transform_Draw(playerShipTexture, playerShip.x - (PLAYERDIMENSION * PLAYERSHIPSCALE) / 2, playerShip.y - (PLAYERDIMENSION * PLAYERSHIPSCALE) / 2, 250, 250, 0, 1, playerShip.rotation, PLAYERSHIPSCALE, SHIPFLASHCOLOR);

	for (int i = 0; i < enemyShipFleet.size(); i++) {
		//MAYBE ORDER DIFFERENTLY. HE IS NOT HIT more THAN HE IS HIT.
		//actually makes not one bit of difference pretty sure because 1 condition is evualuated either way. Stupid trying to be too efficient when we dont truly know much about efficiency yet anyway.
		if (enemyShipFleet[i].ifHit){
			gfx.Sprite_Transform_Draw(enemyShipTexture, enemyShipFleet[i].x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, enemyShipFleet[i].y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, ENEMYDIMENSION, ENEMYDIMENSION, 0, 1, enemyShipFleet[i].rotation, ENEMYSHIPSCALE, D3DCOLOR_XRGB(255, 0, 200));
		}
		else gfx.Sprite_Transform_Draw(enemyShipTexture, enemyShipFleet[i].x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, enemyShipFleet[i].y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, ENEMYDIMENSION, ENEMYDIMENSION, 0, 1, enemyShipFleet[i].rotation, ENEMYSHIPSCALE);
		sprintf(buffer2, "%d", i);
		gfx.FontPrint(fontTimesNewRoman40, enemyShipFleet[i].x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, enemyShipFleet[i].y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, buffer2, D3DCOLOR_XRGB(255, 255, 255));
	}

	//if (weaponChoice == BULLET) gfx.Sprite_Transform_Draw(bulletIconTexture, 1700, 800, 456, 588, 0, 1, 0.0f, 0.5f);
	//else if (weaponChoice == MISSILE) gfx.Sprite_Transform_Draw(missileIconTexture, 1700, 800, 456, 588, 0, 1, 0.0f, 0.5f);
	
	gfx.Sprite_Transform_Draw(weaponHudTexture, 1500, 650, 388, 385, 0, 1, 0.0f, 1.0f);
	//if (weaponChoice == BULLET) gfx.Sprite_Transform_Draw(bulletIconTexture, 1700, 800, 456, 588, 0, 1, 0.0f, 0.5f);
	//else if (weaponChoice == MISSILE) gfx.Sprite_Transform_Draw(missileIconTexture, 1700, 800, 456, 588, 0, 1, 0.0f, 0.5f);

	for (int i = 0; i < insectKamikazeFleet.size(); i++) {
		if (insectKamikazeFleet[i].ifHit) gfx.Sprite_Transform_Draw(insectKamikazeTexture, insectKamikazeFleet[i].x - (ENEMYDIMENSION * INSECTSCALE) / 2, insectKamikazeFleet[i].y - (ENEMYDIMENSION * INSECTSCALE) / 2, ENEMYDIMENSION, ENEMYDIMENSION, insectKamikazeFleet[i].frame, 15, insectKamikazeFleet[i].rotation - PI / 2, INSECTSCALE, D3DCOLOR_XRGB(255, 0, 200));
		else gfx.Sprite_Transform_Draw(insectKamikazeTexture, insectKamikazeFleet[i].x - (ENEMYDIMENSION * INSECTSCALE) / 2, insectKamikazeFleet[i].y - (ENEMYDIMENSION * INSECTSCALE) / 2, ENEMYDIMENSION, ENEMYDIMENSION, insectKamikazeFleet[i].frame, 15, insectKamikazeFleet[i].rotation - PI / 2, INSECTSCALE);
	}

	for (int i = 0; i < AMOUNTOFVECTORS; i++) {
		for (int j = 0; j < arrayOfVectors[i].size(); j++) {
			gfx.Sprite_Transform_Draw(plasmaBulletTexture, arrayOfVectors[i].at(j).x, arrayOfVectors[i].at(j).y, 10, 10, arrayOfVectors[i].at(j).frame, 5, arrayOfVectors[i].at(j).rotation, 5.0f, D3DCOLOR_XRGB(255,255,255));
		}
	}




	if (weaponChoice == MISSILE) {
		for (int i = 0; i < pShipTargets.size(); i++) {
			/*
			Why / 4?????????????????????	
			*/
			sprintf(buffer2, "%d", i);
			gfx.FontPrint(fontTimesNewRoman40, enemyShipFleet[i].x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2 + 20, enemyShipFleet[i].y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2, buffer2, D3DCOLOR_XRGB(255, 0, 0));
			if (pShipTargets[i].inMouseRange) gfx.Sprite_Transform_Draw(missileLockTexture, pShipTargets[i].ship->x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2 - (400 * LOCKONSCALE) / 4,
				pShipTargets[i].ship->y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2 - (400 * LOCKONSCALE) / 4, 400, 400, pShipTargets[i].frame, 8, 0.0f, LOCKONSCALE);
			else if (pShipTargets[i].lockedOn) gfx.Sprite_Transform_Draw(missileLockTexture, pShipTargets[i].ship->x - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2 - (400 * LOCKONSCALE) / 4,
				pShipTargets[i].ship->y - (ENEMYDIMENSION * ENEMYSHIPSCALE) / 2 - (400 * LOCKONSCALE) / 4, 400, 400, pShipTargets[i].frame, 8, 0.0f, LOCKONSCALE);
		}
	}


	






	for (int i = 0; i < enemyBulletVector.size(); i++) {
		//gfx.DrawDisc(enemyBulletVector[i].x, enemyBulletVector[i].y, 5, enemyBulletVector[i].r, enemyBulletVector[i].g, enemyBulletVector[i].b);
		gfx.Sprite_Transform_Draw(plasmaBulletTexture, enemyBulletVector[i].x, enemyBulletVector[i].y, 10, 10, enemyBulletVector[i].frame, 5, enemyBulletVector[i].rotation, 5.0f, D3DCOLOR_XRGB(255, 50, 50));
	}

	for (int i = 0; i < missileVector.size(); i++) {
		gfx.Sprite_Transform_Draw(missileTexture, missileVector[i].x, missileVector[i].y, 215, 126, missileVector[i].frame, 5, missileVector[i].rotation, 0.5f);
	}

	for (int i = 0; i < explosionVector.size(); i++) {
		gfx.Sprite_Transform_Draw(explosionTexture, explosionVector[i].x - (EXPLOSIONDIMENSION * explosionVector[i].scale) / 2, explosionVector[i].y - (EXPLOSIONDIMENSION * explosionVector[i].scale) / 2, 300, 300, explosionVector[i].frame, 12, explosionVector[i].rotation, explosionVector[i].scale, D3DCOLOR_XRGB(explosionVector[i].r, explosionVector[i].g, explosionVector[i].b));
	}

	spriteobj2->End();

	//gfx.DrawLine(cursorX, cursorY, x + 125, y + 125, 0, 255, 0);
	//gfx.DrawDisc(playerShip.x, playerShip.y, 12, 255, 255, 0);
}
Example #7
0
void Game::render() {
	renderMap();
	drawHealth();

	SDL_Flip(m_background);
}
Example #8
0
void Entity::drawStats(sf::RenderWindow* graphics){

	//The health of the entity
	drawHealth(graphics);
	graphics->draw(entity_type_text);
}
Example #9
0
//Update players structs based on keyboard
void updateActions() {
	if (IORD(keys,0) == 8) {
		moveLeft(turn);
		p[turn].moved = TRUE;
	}
	//moves right
	if (IORD(keys,0) == 4) {
		moveRight(turn);
		p[turn].moved = TRUE;
	}
	//turret fire
	if (IORD(keys,0) == 2) {
		//fire power should be 0<power<100
		turretFire(turn, 100, windPower, 0); //need to get power from keyboard
		setPlayerTurn();

	}
	//turret CW
	if (IORD(switches,0) == 1) {
		turretCW(turn);
	}
	//turret CCW
	if (IORD(switches,0) == 2) {
		turretCCW(turn);
	}
	if (IORD(switches,0) == 4) {
		p[pOne].hp = 0;
	}

	if (fLeft == 1) {
		p[turn].moved = TRUE;
		moveLeft(turn);
	}
	if (fRight == 1) {
		p[turn].moved = TRUE;
		moveRight(turn);
	}
	if (fUp == 1) {
		turretCCW(turn);
	}
	if (fDown == 1) {
		turretCW(turn);
	}
	if (fpDown == 1) {
		if (p[turn].power - 1 >= 0)
			p[turn].power--;
	}
	if (fpUp == 1) {
		if (p[turn].power + 1 <= 100)
			p[turn].power++;
	}
	if (fBullet == 1) {
		fBullet = 0;
		p[turn].bulletType = (p[turn].bulletType + 1)%2;
	}
	if (fFire == 1) {
		if (!p[turn].isFalling) {
			alt_up_ps2_disable_read_interrupt(ps2);
			turretFire(turn, p[turn].power, windPower, p[turn].bulletType);
			setPlayerTurn();
			alt_up_ps2_enable_read_interrupt(ps2);
			printf("Before enabled interupt\n");
			alt_up_ps2_clear_fifo(ps2);
			printf("Fifo cleared\n");
			fFire = 0;
			drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
			drawBullet(p[turn].bulletType);
			updateScreen();
			drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
		}
	}
}
Example #10
0
int main(void) {
	while (1) {
		state = 0;
		int setTime = 15;
		numPlayers = 2;
		initScreen();
		clearScreen();
		initCharBuffer();
		clean_up();
		initKeyboard();
		initState0();
		initAI();


		//Bypass the menu system for testing
		if (IORD(keys,0) == 8) {
			initPlayer(pOne, MARIO, "pOne", 50, 100, HUMAN);
			initPlayer(pTwo, LUIGI, "pTwo", 50, 100, COMPUTER);
			state = 2;
		} else {
			while (state == 0) {
				decode_scancode(ps2, &decode_mode, buf, &ascii);
				state_0(decode_mode, buf[0]);
			};
			initState1(pOne);
			if(aOn)file_handle = initAudio(fname);
			if(aOn)alt_irq_register(AUDIO_0_IRQ, &ab, (alt_isr_func) write_fifo);
			if(aOn)		alt_up_audio_enable_write_interrupt(ab->audio);
			while (state == 1) {
				decode_scancode(ps2, &decode_mode, buf, &ascii);
				state_1(decode_mode, buf[0], ascii);
				if(aOn)loop_audio(file_handle, fname, ab);
			};
		}

		//clean_up();
		clearCharBuffer();
		clearScreen();

		//enable keyboard IRQ
		void* keyboard_control_register_ptr = (void*) (KEYBOARD_BASE + 4);
		alt_irq_register(KEYBOARD_IRQ, keyboard_control_register_ptr,
				keyboard_ISR);
		alt_up_ps2_enable_read_interrupt(ps2);

		//Draw field and UI to both buffers
		initField();

		updateField();
		drawName(p[pOne].name, p[pTwo].name, p[pThree].name, p[pFour].name);
		drawGas(p[pOne].gas);
		drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
		drawBullet(p[pOne].bulletType);
		//drawWindIndicator(1);
		updateScreen();

		updateField();
		drawName(p[pOne].name, p[pTwo].name, p[pThree].name, p[pFour].name);
		drawGas(p[pOne].gas);
		drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
		drawBullet(p[pOne].bulletType);
		//drawWindIndicator(1);

		float time;
		alt_timestamp_start();


		int start_timer_flag = 1;
		//printf("NUM PLAYERA %i\n", numPlayers);
		int i;
		while (state == 2) {
			int fallFlag = 1;

			//Checks to see if any players are falling
			while (fallFlag == 1) {
				fallFlag = 0;
				for (i = 0; i < numPlayers; i++) {
					if (p[i].alive) {
						if (p[i].y + TANK_HEIGHT >= SCREEN_HEIGHT-1) {
							p[i].hp = 0;
							p[i].alive = DEAD;
						}
						checkPlayerFalling(i);
						if (p[i].isFalling) {
							undrawPlayer(i);
							updatePlayer(i);
							fallFlag = 1;
						}
					}
				}
				if (fallFlag == 1) {
					updateScreen();
				}
			}

			if(start_timer_flag){
				start_time = (float) alt_timestamp() / (float) alt_timestamp_freq();
				start_timer_flag = 0;
			}
			time = (float) alt_timestamp() / (float) alt_timestamp_freq()-start_time;
			if (time >= setTime) {
				setPlayerTurn();
			}
			if (p[turn].type == HUMAN) {
				runGame();

			} else {
				p[turn].deg = 0;
				aiMain(turn);
				setPlayerTurn();
			}
			printTimer(setTime - time);
			int deadCount = 0;
			for (i = 0; i < numPlayers; i++) {
				if (p[i].alive == DEAD)
					deadCount++;
			}
			if (deadCount == numPlayers - 1) {
				usleep(500000);
				state = 3;
			}
		}

		alt_up_ps2_disable_read_interrupt(ps2);
		if(aOn)alt_up_audio_disable_write_interrupt(ab->audio);

		GameOverScreen();
	}
}