1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 *
24 */
25
26 #include "pegasus/pegasus.h"
27 #include "pegasus/neighborhood/mars/energybeam.h"
28
29 namespace Pegasus {
30
31 static const TimeValue kEnergyBeamTime = kOneSecond * kShuttleWeaponScale / 2;
32
33 static const CoordType kEnergyBeamOriginH = kShuttleWindowMidH;
34 static const CoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
35
36 static const float kBeamXOrigin = convertScreenHToSpaceX(kEnergyBeamOriginH, kEnergyBeamMinDistance);
37 static const float kBeamYOrigin = convertScreenVToSpaceY(kEnergyBeamOriginV, kEnergyBeamMinDistance);
38 static const float kBeamZOrigin = kEnergyBeamMinDistance;
39
EnergyBeam()40 EnergyBeam::EnergyBeam() {
41 _weaponDuration = kEnergyBeamTime;
42 setSegment(0, kEnergyBeamTime);
43 _weaponOrigin = Point3D(kBeamXOrigin, kBeamYOrigin, kBeamZOrigin);
44 }
45
draw(const Common::Rect &)46 void EnergyBeam::draw(const Common::Rect &) {
47 static const int kBeamColorRed1 = 224;
48 static const int kBeamColorRed2 = 64;
49
50 Graphics::Surface *surface = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
51
52 byte red = linearInterp(0, kEnergyBeamTime, _lastTime, kBeamColorRed1, kBeamColorRed2);
53 uint32 color = surface->format.RGBToColor(red, 0, 0);
54
55 Point3D startPoint;
56 if (_weaponTime < 0.1)
57 startPoint = _weaponOrigin;
58 else
59 linearInterp(_weaponOrigin, _weaponTarget, _weaponTime - 0.1, startPoint);
60
61 Common::Point lineStart;
62 project3DTo2D(startPoint, lineStart);
63
64 Common::Point lineEnd;
65 project3DTo2D(_weaponLocation, lineEnd);
66
67 surface->drawThickLine(lineStart.x, lineStart.y, lineEnd.x, lineEnd.y, 2, 1, color);
68 }
69
70 } // End of namespace Pegasus
71