1 /////////////////////////////////////////
2 //
3 // OpenLieroX
4 //
5 // code under LGPL, based on JasonBs work,
6 // enhanced by Dark Charlie and Albert Zeyer
7 //
8 //
9 /////////////////////////////////////////
10
11
12 // Bonus class
13 // Created 5/8/02
14 // Jason Boettcher
15
16
17 #include "LieroX.h"
18 #include "CBonus.h"
19 #include "DeprecatedGUI/Graphics.h"
20 #include "GfxPrimitives.h"
21 #include "WeaponDesc.h"
22 #include "CViewport.h"
23 #include "CGameScript.h"
24 #include "CClient.h"
25 #include "CMap.h"
26
27
28 ///////////////////
29 // Spawn the bonus
Spawn(CVec ppos,int type,int weapon,CGameScript * gs)30 void CBonus::Spawn(CVec ppos, int type, int weapon, CGameScript *gs)
31 {
32 bUsed = true;
33 fLastSimulationTime = tLX->currentTime;
34 vPos = ppos;
35 vVelocity = CVec(0,0);
36 iType = type;
37 iWeapon = weapon;
38 fLife = 0;
39 fSpawnTime = tLX->currentTime;
40 fFlashTime = 0;
41
42 if(type == BNS_WEAPON)
43 sWeapon = (gs->GetWeapons()+weapon)->Name;
44 }
45
46
47 ///////////////////
48 // Draw the bonus
Draw(SDL_Surface * bmpDest,CViewport * v,int showname)49 void CBonus::Draw(SDL_Surface * bmpDest, CViewport *v, int showname)
50 {
51 CMap* map = cClient->getMap();
52 VectorD2<int> p = v->physicToReal(vPos, cClient->getGameLobby()->features[FT_InfiniteMap], map->GetWidth(), map->GetHeight());
53
54 // If we are in a flashing mode, don't show it on an 'off' flash mode
55 if(fLife > BONUS_LIFETIME-3) {
56 if(fFlashTime > 0.15f)
57 return;
58 }
59
60
61 switch(iType) {
62
63 // Health
64 case BNS_HEALTH:
65 DrawImage(bmpDest, DeprecatedGUI::gfxGame.bmpHealth,p.x-5,p.y-5);
66 break;
67
68 // Weapon
69 case BNS_WEAPON:
70 DrawImage(bmpDest, DeprecatedGUI::gfxGame.bmpBonus, p.x-5,p.y-5);
71
72 if(showname)
73 tLX->cOutlineFont.DrawCentre(bmpDest, p.x, p.y-20, tLX->clPlayerName, sWeapon);
74 break;
75 }
76 }
77
setUsed(bool _u)78 void CBonus::setUsed(bool _u) {
79 bUsed = _u; if(_u) fLastSimulationTime = tLX->currentTime;
80 }
81
82