#include "dxstdafx.h" #include "./HUD.h" HUD::HUD(void):Node() { minutes = 0; seconds = 0; ammoAmount = 0; testAgainstFrustum = false; nodeType |= GameScene::NODE_HUD; messagetimer = messagethreshold = 0; messagedt = 0; youwintimer = youwinthreshold = 0; youwindt = 0; youlosetimer = youlosethreshold = 0; youlosedt = 0; toastedtimer = toastedthreshold = 0; toasteddt = 0; } void HUD::generateHUD() { // Load textures IDirect3DTexture9* tex = 0; if (this->crosshair != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->crosshair)); if (this->radar != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->radar)); if (this->texture0 != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->texture0)); if (this->texture1 != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->texture1)); if (this->texture2 != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->texture2)); if (this->texture3 != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->texture3)); if (this->texture4 != "") Textures.push_back(this->myScene->manager->resManager.loadTexture(this->texture4)); //load fancy font: D3DSURFACE_DESC desc; //calculate scaling factor: float scaling = (float)this->myScene->manager->screenHeight/3; float positionFactorX = (float)this->myScene->manager->screenWidth/100; float positionFactorY = (float)this->myScene->manager->screenHeight/100; //set maximum rotation factor: float maxRotation = 1.0f; //load you win letters: Letter rufezeichen; rufezeichen.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/rufezeichen.dds"); Textures.push_back(rufezeichen.texture); rufezeichen.texture->GetLevelDesc(0, &desc); rufezeichen.scale = scaling/desc.Height; rufezeichen.centerX = desc.Width/2 * rufezeichen.scale; rufezeichen.centerY = desc.Height/2 * rufezeichen.scale; rufezeichen.x = 92*positionFactorX; rufezeichen.y = 50*positionFactorY; rufezeichen.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(rufezeichen); Letter n; n.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/n.dds"); Textures.push_back(n.texture); n.texture->GetLevelDesc(0, &desc); n.scale = scaling/desc.Height; n.centerX = desc.Width/2 * n.scale; n.centerY = desc.Height/2 * n.scale; n.x = 82*positionFactorX; n.y = 50*positionFactorY; n.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(n); Letter i; i.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/i.dds"); Textures.push_back(i.texture); i.texture->GetLevelDesc(0, &desc); i.scale = scaling/desc.Height; i.centerX = desc.Width/2 * i.scale; i.centerY = desc.Height/2 * i.scale; i.x = 72*positionFactorX; i.y = 50*positionFactorY; i.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(i); Letter w; w.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/w.dds"); Textures.push_back(w.texture); w.texture->GetLevelDesc(0, &desc); w.scale = scaling/desc.Height; w.centerX = desc.Width/2 * w.scale; w.centerY = desc.Height/2 * w.scale; w.x = 57*positionFactorX; w.y = 50*positionFactorY; w.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(w); Letter u; u.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/u.dds"); Textures.push_back(u.texture); u.texture->GetLevelDesc(0, &desc); u.scale = scaling/desc.Height; u.centerX = desc.Width/2 * u.scale; u.centerY = desc.Height/2 * u.scale; u.x = 37*positionFactorX; u.y = 50*positionFactorY; u.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(u); Letter o; o.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/o.dds"); Textures.push_back(o.texture); o.texture->GetLevelDesc(0, &desc); o.scale = scaling/desc.Height; o.centerX = desc.Width/2 * o.scale; o.centerY = desc.Height/2 * o.scale; o.x = 23*positionFactorX; o.y = 50*positionFactorY; o.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(o); Letter y; y.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/y.dds"); Textures.push_back(y.texture); y.texture->GetLevelDesc(0, &desc); y.scale = scaling/desc.Height; y.centerX = desc.Width/2 * y.scale; y.centerY = desc.Height/2 * y.scale; y.x = 12*positionFactorX; y.y = 50*positionFactorY; y.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouWin.push_back(y); //load you lose letters: Letter rufezeichen2; rufezeichen2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/rufezeichen.dds"); Textures.push_back(rufezeichen2.texture); rufezeichen2.texture->GetLevelDesc(0, &desc); rufezeichen2.scale = scaling/desc.Height; rufezeichen2.centerX = desc.Width/2 * rufezeichen2.scale; rufezeichen2.centerY = desc.Height/2 * rufezeichen2.scale; rufezeichen2.x = 92*positionFactorX; rufezeichen2.y = 50*positionFactorY; rufezeichen2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(rufezeichen2); Letter e; e.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/e.dds"); Textures.push_back(e.texture); e.texture->GetLevelDesc(0, &desc); e.scale = scaling/desc.Height; e.centerX = desc.Width/2 * e.scale; e.centerY = desc.Height/2 * e.scale; e.x = 86*positionFactorX; e.y = 50*positionFactorY; e.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(e); Letter s; s.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/s.dds"); Textures.push_back(s.texture); s.texture->GetLevelDesc(0, &desc); s.scale = scaling/desc.Height; s.centerX = desc.Width/2 * s.scale; s.centerY = desc.Height/2 * s.scale; s.x = 77*positionFactorX; s.y = 50*positionFactorY; s.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(s); Letter o3; o3.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/o.dds"); Textures.push_back(o3.texture); o3.texture->GetLevelDesc(0, &desc); o3.scale = scaling/desc.Height; o3.centerX = desc.Width/2 * o3.scale; o3.centerY = desc.Height/2 * o3.scale; o3.x = 67*positionFactorX; o3.y = 50*positionFactorY; o3.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(o3); Letter l; l.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/l.dds"); Textures.push_back(l.texture); l.texture->GetLevelDesc(0, &desc); l.scale = scaling/desc.Height; l.centerX = desc.Width/2 * l.scale; l.centerY = desc.Height/2 * l.scale; l.x = 57*positionFactorX; l.y = 50*positionFactorY; l.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(l); Letter u2; u2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/u.dds"); Textures.push_back(u2.texture); u2.texture->GetLevelDesc(0, &desc); u2.scale = scaling/desc.Height; u2.centerX = desc.Width/2 * u2.scale; u2.centerY = desc.Height/2 * u2.scale; u2.x = 37*positionFactorX; u2.y = 50*positionFactorY; u2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(u2); Letter o2; o2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/o.dds"); Textures.push_back(o2.texture); o2.texture->GetLevelDesc(0, &desc); o2.scale = scaling/desc.Height; o2.centerX = desc.Width/2 * o2.scale; o2.centerY = desc.Height/2 * o2.scale; o2.x = 23*positionFactorX; o2.y = 50*positionFactorY; o2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(o2); Letter y2; y2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/y.dds"); Textures.push_back(y2.texture); y2.texture->GetLevelDesc(0, &desc); y2.scale = scaling/desc.Height; y2.centerX = desc.Width/2 * y2.scale; y2.centerY = desc.Height/2 * y2.scale; y2.x = 12*positionFactorX; y2.y = 50*positionFactorY; y2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; YouLose.push_back(y2); //load toasted letters: Letter rufezeichen3; rufezeichen3.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/rufezeichen.dds"); Textures.push_back(rufezeichen3.texture); rufezeichen3.texture->GetLevelDesc(0, &desc); rufezeichen3.scale = scaling/desc.Height; rufezeichen3.centerX = desc.Width/2 * rufezeichen3.scale; rufezeichen3.centerY = desc.Height/2 * rufezeichen3.scale; rufezeichen3.x = 91*positionFactorX; rufezeichen3.y = 50*positionFactorY; rufezeichen3.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(rufezeichen3); Letter d; d.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/d.dds"); Textures.push_back(d.texture); d.texture->GetLevelDesc(0, &desc); d.scale = scaling/desc.Height; d.centerX = desc.Width/2 * d.scale; d.centerY = desc.Height/2 * d.scale; d.x = 82*positionFactorX; d.y = 50*positionFactorY; d.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(d); Letter e2; e2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/e.dds"); Textures.push_back(e2.texture); e2.texture->GetLevelDesc(0, &desc); e2.scale = scaling/desc.Height; e2.centerX = desc.Width/2 * e2.scale; e2.centerY = desc.Height/2 * e2.scale; e2.x = 72*positionFactorX; e2.y = 50*positionFactorY; e2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(e2); Letter t; t.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/t.dds"); Textures.push_back(t.texture); t.texture->GetLevelDesc(0, &desc); t.scale = scaling/desc.Height; t.centerX = desc.Width/2 * t.scale; t.centerY = desc.Height/2 * t.scale; t.x = 61*positionFactorX; t.y = 50*positionFactorY; t.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(t); Letter s2; s2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/s.dds"); Textures.push_back(s2.texture); s2.texture->GetLevelDesc(0, &desc); s2.scale = scaling/desc.Height; s2.centerX = desc.Width/2 * s2.scale; s2.centerY = desc.Height/2 * s2.scale; s2.x = 51*positionFactorX; s2.y = 50*positionFactorY; s2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(s2); Letter a; a.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/a.dds"); Textures.push_back(a.texture); a.texture->GetLevelDesc(0, &desc); a.scale = scaling/desc.Height; a.centerX = desc.Width/2 * a.scale; a.centerY = desc.Height/2 * a.scale; a.x = 38*positionFactorX; a.y = 50*positionFactorY; a.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(a); Letter o4; o4.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/o.dds"); Textures.push_back(o4.texture); o4.texture->GetLevelDesc(0, &desc); o4.scale = scaling/desc.Height; o4.centerX = desc.Width/2 * o4.scale; o4.centerY = desc.Height/2 * o4.scale; o4.x = 25*positionFactorX; o4.y = 50*positionFactorY; o4.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(o4); Letter t2; t2.texture = this->myScene->manager->resManager.loadTexture("./media/textures/letters/t.dds"); Textures.push_back(t2.texture); t2.texture->GetLevelDesc(0, &desc); t2.scale = scaling/desc.Height; t2.centerX = desc.Width/2 * t2.scale; t2.centerY = desc.Height/2 * t2.scale; t2.x = 13*positionFactorX; t2.y = 50*positionFactorY; t2.rotation = (((float)rand()/RAND_MAX)-0.5f) * maxRotation; Toasted.push_back(t2); //create renderer SPTR renderer(new HUDRenderer); renderer->setScene(*this->myScene); this->myScene->connectNodeAndRenderer(*this, renderer); } HUD::~HUD(void) { } void HUD::setTextures(std::string texture0, std::string texture1, std::string texture2, std::string texture3, std::string texture4, float scaleUserPlayer, float scaleAIPlayer) { this->texture0 = texture0; this->texture1 = texture1; this->texture2 = texture2; this->texture3 = texture3; this->texture4 = texture4; this->scaleUserPlayer = scaleUserPlayer; this->scaleAIPlayer = scaleAIPlayer; } /*LPD3DXSPRITE* HUD::getSprite() { return &this->sprite; }*/ void HUD::setCrosshair(std::string crosshair, float scaleX, float scaleY) { this->crosshair = crosshair; this->scaleCrosshairX = scaleX; this->scaleCrosshairY = scaleY; } float HUD::getScaleCrosshairX() { return this->scaleCrosshairX; } float HUD::getScaleCrosshairY() { return this->scaleCrosshairY; } void HUD::setRadar(std::string radar, float scaleX, float scaleY, float RadarOffsetX, float RadarOffsetY) { this->radar = radar; this->scaleRadarX = scaleX; this->scaleRadarY = scaleY; this->RadarOffsetX = RadarOffsetX; this->RadarOffsetY = RadarOffsetY; } float HUD::getScaleRadarX() { return this->scaleRadarX; } float HUD::getScaleRadarY() { return this->scaleRadarY; } float HUD::getRadarOffsetX() { return this->RadarOffsetX; } float HUD::getRadarOffsetY() { return this->RadarOffsetY; } float HUD::getScaleUserPlayer() { return this->scaleUserPlayer; } float HUD::getScaleAIPlayer() { return this->scaleAIPlayer; } void HUD::message(std::string _message, float _seconds, float _dt, bool _bHelp) { this->bHelp = _bHelp; this->messagetimer = 0; this->messagethreshold = _seconds; std::wstring bla(_message.begin(), _message.end()); this->messagestring = bla; this->messagedt = _dt; } void HUD::setTime(int minutes, int seconds) { this->minutes = minutes; this->seconds = seconds; } void HUD::displayWin(float _seconds, float _dt) { this->youwintimer = 0; this->youwinthreshold = _seconds; this->youwindt = _dt; } void HUD::displayLose(float _seconds, float _dt) { this->youlosetimer= 0; this->youlosethreshold = _seconds; this->youlosedt = _dt; } void HUD::displayToasted(float _seconds, float _dt) { this->toastedtimer= 0; this->toastedthreshold = _seconds; this->toasteddt = _dt; } void HUD::setAmmo(int amount) { this->ammoAmount = amount; }