[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 296 - in trunk: data data/images/vehicles src/vehic
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 296 - in trunk: data data/images/vehicles src/vehicles |
Date: |
Sat, 22 Nov 2003 22:01:36 +0100 |
Author: grumbel
Date: 2003-11-22 22:01:34 +0100 (Sat, 22 Nov 2003)
New Revision: 296
Added:
trunk/data/images/vehicles/chinook_rotor.png
trunk/data/images/vehicles/chinook_rotor2.png
trunk/data/images/vehicles/chinook_shadow.png
trunk/src/vehicles/rotor.cxx
trunk/src/vehicles/rotor.hxx
Modified:
trunk/data/feuerkraft.xml
trunk/data/images/vehicles/chinook.png
trunk/data/images/vehicles/huey_rotor.png
trunk/data/images/vehicles/huey_rotor2.png
trunk/src/vehicles/Makefile.am
trunk/src/vehicles/helicopter.cxx
trunk/src/vehicles/helicopter.hxx
Log:
- added chinook
Modified: trunk/data/feuerkraft.xml
===================================================================
--- trunk/data/feuerkraft.xml 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/data/feuerkraft.xml 2003-11-22 21:01:34 UTC (rev 296)
@@ -283,6 +283,22 @@
<image file="images/vehicles/huey_rotor2.png" />
</sprite>
+ <sprite name="chinook">
+ <image file="images/vehicles/chinook.png" />
+ </sprite>
+
+ <sprite name="chinook_shadow">
+ <image file="images/vehicles/chinook_shadow.png" />
+ </sprite>
+
+ <sprite name="chinook_rotor">
+ <image file="images/vehicles/chinook_rotor.png" />
+ </sprite>
+
+ <sprite name="chinook_rotor2">
+ <image file="images/vehicles/chinook_rotor2.png" />
+ </sprite>
+
<sprite name="hole">
<image file="images/hole.png" />
</sprite>
Modified: trunk/data/images/vehicles/chinook.png
===================================================================
(Binary files differ)
Added: trunk/data/images/vehicles/chinook_rotor.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/images/vehicles/chinook_rotor.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/images/vehicles/chinook_rotor2.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/images/vehicles/chinook_rotor2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/images/vehicles/chinook_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/data/images/vehicles/chinook_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/images/vehicles/huey_rotor.png
===================================================================
(Binary files differ)
Modified: trunk/data/images/vehicles/huey_rotor2.png
===================================================================
(Binary files differ)
Modified: trunk/src/vehicles/Makefile.am
===================================================================
--- trunk/src/vehicles/Makefile.am 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/src/vehicles/Makefile.am 2003-11-22 21:01:34 UTC (rev 296)
@@ -3,7 +3,8 @@
libfeuerkraft_vehicles_a_SOURCES = \
tank.cxx tank.hxx \
helicopter.cxx helicopter.hxx \
- jeep.cxx jeep.hxx \
- turret.cxx turret.hxx
+ jeep.cxx jeep.hxx \
+ turret.cxx turret.hxx \
+ rotor.cxx rotor.hxx
# EOF #
Modified: trunk/src/vehicles/helicopter.cxx
===================================================================
--- trunk/src/vehicles/helicopter.cxx 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/src/vehicles/helicopter.cxx 2003-11-22 21:01:34 UTC (rev 296)
@@ -27,19 +27,22 @@
#include "helicopter.hxx"
Helicopter::Helicopter(const AList& lst)
- : rotor (resources->get_sprite ("feuerkraft/huey_rotor2")),
- rotor_halt (resources->get_sprite ("feuerkraft/huey_rotor")),
- heli (resources->get_sprite ("feuerkraft/huey")),
- heli_shadow (resources->get_sprite ("feuerkraft/huey_shadow")),
- helidestroyed (resources->get_sprite ("feuerkraft/helidestroyed")),
- rotor_speed(0),
- rotor_pos(0),
- strafe (0.0),
- fireing (false),
- reloading (0),
- energie (100),
- destroyed (false),
- ai(0)
+ :
+ //rotor("feuerkraft/huey_rotor",
+ // "feuerkraft/huey_rotor2"),
+ //heli (resources->get_sprite ("feuerkraft/chuey")),
+ //heli_shadow (resources->get_sprite ("feuerkraft/huey_shadow")),
+ rotor("feuerkraft/chinook_rotor",
+ "feuerkraft/chinook_rotor2"),
+ heli (resources->get_sprite ("feuerkraft/chinook")),
+ heli_shadow (resources->get_sprite ("feuerkraft/chinook_shadow")),
+ helidestroyed (resources->get_sprite ("feuerkraft/helidestroyed")),
+ strafe (0.0),
+ fireing (false),
+ reloading (0),
+ energie (100),
+ destroyed (false),
+ ai(0)
{
pos.x = lst.get_float("x-pos");
pos.y = lst.get_float("y-pos");
@@ -47,9 +50,8 @@
velocity = 0;
orientation = 0;
- height = 50.0f;
-
- state = FLYING;
+ height = 0;
+ state = LANDED;
}
Helicopter::~Helicopter ()
@@ -64,17 +66,10 @@
view.draw (heli_shadow, FloatVector2d(pos.x + height/2.0f, pos.y +
height),
orientation);
- view.draw (heli, pos, orientation);
- /*
- view->draw (heli,
- pos.x - heli.get_width ()/2,
- pos.y - heli.get_height ()/2,
- frame);*/
+ view.draw(heli, pos, orientation);
- if (state == LANDED)
- view.draw (rotor_halt, pos, rotor_pos);
- else
- view.draw (rotor, pos, rotor_pos);
+ rotor.draw(view, pos + FloatVector2d(-40.0f, 0).rotate(orientation),
orientation);
+ rotor.draw(view, pos + FloatVector2d(+40.0f, 0).rotate(orientation),
orientation);
energie.draw (view, int(pos.x), int(pos.y - 40));
}
@@ -82,19 +77,13 @@
{
view.draw (helidestroyed, pos, orientation);
}
-
- /*
- view->draw_rect (int(pos.x) - 40, int(pos.y) - 10,
- int(pos.x) + 30, int(pos.y) + 10,
- 1.0f, 1.0f, 1.0f);
- view->draw_rect (int(pos.x) - 15, int(pos.y) - 20,
- int(pos.x) + 5, int(pos.y) + 20,
- 1.0f, 1.0f, 1.0f);*/
}
void
Helicopter::update (float delta)
{
+ rotor.update(delta);
+
if (state == LANDING)
{
height -= 20.0f * delta;
@@ -102,20 +91,24 @@
{
height = 0;
state = LANDED;
+ rotor.stop();
}
}
else if (state == STARTING)
{
- height += 20.0f * delta;
- if (height > 50.0f)
+ if (rotor.is_running())
{
- height = 50;
- state = FLYING;
+ height += 20.0f * delta;
+ if (height > 50.0f)
+ {
+ height = 50;
+ state = FLYING;
+ }
}
}
// Apply controlls
- if (state != LANDED)
+ if (state != LANDED && height > 0)
{
orientation += 3.0f * steering * delta;
velocity -= 15.0f * acceleration * delta;
@@ -123,22 +116,8 @@
}
strafe_steering = steering = acceleration = 0;
-
- if (state == LANDED)
- {
- rotor_pos -= rotor_speed * delta;
- rotor_speed -= 1.5f * delta;
- if (rotor_speed < 0)
- rotor_speed = 0;
- }
- else
- {
- rotor_speed = 10.0f;
- rotor_pos -= rotor_speed * delta;
- }
-
+
delta *= 50;
- rotor.update (delta);
if (energie <= 0 && !destroyed)
{
@@ -176,9 +155,14 @@
Helicopter::land_or_start()
{
if (state == FLYING || state == STARTING)
- state = LANDING;
+ {
+ state = LANDING;
+ }
else if (state == LANDED || state == LANDING)
- state = STARTING;
+ {
+ state = STARTING;
+ rotor.start();
+ }
}
bool
Modified: trunk/src/vehicles/helicopter.hxx
===================================================================
--- trunk/src/vehicles/helicopter.hxx 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/src/vehicles/helicopter.hxx 2003-11-22 21:01:34 UTC (rev 296)
@@ -23,6 +23,7 @@
#include <ClanLib/Display/sprite.h>
#include "../energie.hxx"
#include "../vehicle.hxx"
+#include "rotor.hxx"
class VehicleAI;
class AList;
@@ -34,19 +35,15 @@
enum { FLYING, STARTING, LANDING, LANDED } state;
float height;
- CL_Sprite rotor_halt;
- CL_Sprite rotor;
+ Rotor rotor;
CL_Sprite heli;
CL_Sprite heli_shadow;
CL_Sprite helidestroyed;
- float rotor_speed;
- float rotor_pos;
-
float strafe;
- bool fireing;
- int reloading;
+ bool fireing;
+ int reloading;
Energie energie;
bool destroyed;
VehicleAI* ai;
Added: trunk/src/vehicles/rotor.cxx
===================================================================
--- trunk/src/vehicles/rotor.cxx 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/src/vehicles/rotor.cxx 2003-11-22 21:01:34 UTC (rev 296)
@@ -0,0 +1,89 @@
+// $Id$
+//
+// Feuerkraft - A Tank Battle Game
+// Copyright (C) 2003 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "../view.hxx"
+#include "../resource_manager.hxx"
+#include "rotor.hxx"
+
+Rotor::Rotor(const std::string& slow_name,
+ const std::string& fast_name)
+{
+ slow = CL_Sprite(resources->get_sprite(slow_name));
+ fast = CL_Sprite(resources->get_sprite(fast_name));
+
+ running = false;
+ orientation = 0;
+ velocity = 0;
+ max_velocity = 10.0f;
+ acceleration = 1.5f;
+}
+
+void
+Rotor::draw(View& view, const FloatVector2d& pos, float ori)
+{
+ if (velocity > 8.0f)
+ {
+ view.draw(fast, pos, orientation);
+ }
+ else
+ {
+ view.draw(slow, pos, orientation + ori);
+ }
+}
+
+void
+Rotor::update(float delta)
+{
+ fast.update(delta);
+ fast.set_angle(orientation);
+
+ slow.update(delta);
+ slow.set_angle(orientation);
+
+ orientation += velocity * delta;
+
+ if (running)
+ {
+ velocity += acceleration * delta;
+
+ if (velocity > max_velocity)
+ velocity = max_velocity;
+ }
+ else
+ {
+ velocity -= acceleration * delta;
+
+ if (velocity < 0)
+ velocity = 0;
+ }
+}
+
+void
+Rotor::start()
+{
+ running = true;
+}
+
+void
+Rotor::stop()
+{
+ running = false;
+}
+
+/* EOF */
Added: trunk/src/vehicles/rotor.hxx
===================================================================
--- trunk/src/vehicles/rotor.hxx 2003-11-22 17:27:48 UTC (rev 295)
+++ trunk/src/vehicles/rotor.hxx 2003-11-22 21:01:34 UTC (rev 296)
@@ -0,0 +1,57 @@
+// $Id$
+//
+// Feuerkraft - A Tank Battle Game
+// Copyright (C) 2003 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_FEUERKRAFT_VEHICLES_ROTOR_HXX
+#define HEADER_FEUERKRAFT_VEHICLES_ROTOR_HXX
+
+#include <ClanLib/Display/sprite.h>
+
+class View;
+
+/** */
+class Rotor
+{
+private:
+ bool running;
+
+ float orientation;
+ float velocity;
+
+ float acceleration;
+ float max_velocity;
+
+ CL_Sprite slow;
+ CL_Sprite fast;
+public:
+ Rotor(const std::string& slow_name,
+ const std::string& fast_name);
+
+ void draw(View& view, const FloatVector2d& pos, float orientation);
+ void update(float delta);
+
+ void start();
+ void stop();
+
+ float get_velocity() { return velocity; }
+ bool is_running() { return velocity >= max_velocity; }
+};
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 296 - in trunk: data data/images/vehicles src/vehicles,
Ingo Ruhnke <=