Debian Codegraph @

engine/particle/smokeparticle.cpp

raw
1 // ____ _ __
2 // / __ )____ _____ | | / /___ ___________
3 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
4 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
5 // /_____/\____/____/ |__/|__/\__,_/_/ /____/
6 //
7 // A futuristic real-time strategy game.
8 // This file is part of Bos Wars.
9 //
10 /**@name smokeparticle.cpp - The smoke particle. */
11 //
12 // (c) Copyright 2007-2008 by Jimmy Salmon and Francois Beerten
13 //
14 // This program is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; only version 2 of the License.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 // 02111-1307, USA.
27 //
28
29 //@{
30 #include "stratagus.h"
31 #include "particle.h"
32 #include "video.h"
33
34
35
36
37 CSmokeParticle::CSmokeParticle(CPosition position, Animation *smoke) :
38 CParticle(position), puff(smoke)
39 {
40 Assert(smoke);
41 }
42
43 CSmokeParticle::~CSmokeParticle()
44 {
45 delete puff;
46 }
47
48 void CSmokeParticle::draw()
49 {
50 CPosition screenPos = ParticleManager.getScreenPos(pos);
51 puff->draw(static_cast<int>(screenPos.x), static_cast<int>(screenPos.y));
52 }
53
54 void CSmokeParticle::update(int ticks)
55 {
56 puff->update(ticks);
57 if (puff->isFinished()) {
58 destroy();
59 return;
60 }
61
62 // smoke rises
63 const int smokeRisePerSecond = 22;
64 pos.y -= ticks / 1000.f * smokeRisePerSecond;
65 }
66
67 CParticle* CSmokeParticle::clone()
68 {
69 return new CSmokeParticle(pos, puff);
70 }
71
72 //@}