1) Removed bubblegum as a separate object, instead bubblegums are now

created as normal items. 
2) Now bubblebum can be used in swapping as well, so all nitro become
   bubblegums, and all bubblegums become items.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4657 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-02-07 08:49:36 +00:00
parent 3116f475cd
commit 566e12d129
9 changed files with 40 additions and 117 deletions

View File

@ -72,7 +72,7 @@ zipper-force is the additional zipper force
zipper-speed-gain is the one time additional speed
item-switch-time How long a switch is being effective.
switch-items for each item list the index of the item it is switched with.
Order: item, banana, big-nitro, small-nitro
Order: item, banana, big-nitro, small-nitro, bubble-bum
-->
<attachment-parameters
@ -91,7 +91,7 @@ switch-items for each item list the index of the item it is switched with.
zipper-speed-gain="4.5"
zipper-max-speed-fraction="2.0"
item-switch-time="5"
switch-items="1 0 1 1 4"
switch-items="1 0 4 4 0"
/>
<!-- GENERAL KART DEFAULTS

View File

@ -132,8 +132,6 @@ supertuxkart_SOURCES = \
items/attachment_manager.hpp \
items/bowling.cpp \
items/bowling.hpp \
items/bubblegumitem.cpp \
items/bubblegumitem.hpp \
items/cake.cpp \
items/cake.hpp \
items/flyable.cpp \

View File

@ -604,10 +604,6 @@
RelativePath="..\..\items\bowling.cpp"
>
</File>
<File
RelativePath="..\..\items\bubblegumitem.cpp"
>
</File>
<File
RelativePath="..\..\items\cake.cpp"
>
@ -1426,10 +1422,6 @@
RelativePath="..\..\items\bowling.hpp"
>
</File>
<File
RelativePath="..\..\items\bubblegumitem.hpp"
>
</File>
<File
RelativePath="..\..\items\cake.hpp"
>

View File

@ -103,7 +103,7 @@ void InputManager::handleStaticAction(int key, int value)
if (race_manager->getNumPlayers() ==1 )
{
Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0);
kart->setPowerup(POWERUP_BOWLING, 10000);
kart->setPowerup(POWERUP_BUBBLEGUM, 10000);
projectile_manager->newExplosion(Vec3(0, 8, 0.5));
}
break;

View File

@ -1,45 +0,0 @@
// $Id: item.cpp 2405 2008-10-31 20:48:19Z auria $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 Steve Baker <sjbaker1@airmail.net>
//
// 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 3
// 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 "items/bubblegumitem.hpp"
BubbleGumItem::BubbleGumItem(ItemType type, const Vec3& xyz, const Vec3 &normal,
scene::IMesh* mesh, unsigned int item_id)
: Item(type, xyz, normal, mesh, item_id,
/* rotate */ false)
{
} // BubbleGumItem
//-----------------------------------------------------------------------------
BubbleGumItem::~BubbleGumItem()
{
} // ~BubbleGumItem
//-----------------------------------------------------------------------------
/** Is called when the item is hit by a kart. The bubble gum item then
* inactivates itself for 0.5 seconds, but disables the reappearing of
* the bubble gum.
*/
void BubbleGumItem::collected(float t)
{
deactivate(0.5);
// Set the time till reappear to -1 seconds --> the item will
// reappear immediately.
Item::collected(-1);
} // isCollected

View File

@ -1,37 +0,0 @@
// $Id: item.hpp 2405 2008-10-31 20:48:19Z auria $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 Steve Baker <sjbaker1@airmail.net>
//
// 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 3
// 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_BUBBLEGUMITEM_HPP
#define HEADER_BUBBLEGUMITEM_HPP
#include "items/item.hpp"
// -----------------------------------------------------------------------------
class BubbleGumItem : public Item
{
public:
BubbleGumItem(ItemType type, const Vec3& xyz,
const Vec3 &normal, scene::IMesh* mesh,
unsigned int item_id);
~BubbleGumItem ();
virtual void collected(float t);
}
; // class Item
#endif

View File

@ -26,9 +26,9 @@
#include "utils/vec3.hpp"
Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
scene::IMesh* mesh, unsigned int item_id, bool rotate)
scene::IMesh* mesh, unsigned int item_id)
{
m_rotate = rotate;
setType(type);
m_event_handler = NULL;
m_deactive_time = 0;
m_normal = normal;
@ -36,7 +36,6 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
Vec3 hpr = Vec3(0, normal);
m_coord = Coord(xyz, hpr);
m_item_id = item_id;
m_type = type;
m_original_type = ITEM_NONE;
m_collected = false;
m_time_till_return = 0.0f; // not strictly necessary, see isCollected()
@ -46,6 +45,17 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
m_node->grab();
} // Item
//-----------------------------------------------------------------------------
/** Sets the type of this item, but also derived values, e.g. m_rotate.
* (bubblegums do not return).
* \param type New type of the item.
*/
void Item::setType(ItemType type)
{
m_type = type;
m_rotate = type!=ITEM_BUBBLEGUM;
} // setType
//-----------------------------------------------------------------------------
/** Changes this item to be a new type for a certain amount of time.
* \param type New type of this item.
@ -54,7 +64,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
void Item::switchTo(ItemType type, scene::IMesh *mesh)
{
m_original_type = m_type;
m_type = type;
setType(type);
m_node->setMesh(mesh);
} // switchTo
@ -64,7 +74,7 @@ void Item::switchTo(ItemType type, scene::IMesh *mesh)
void Item::switchBack()
{
assert(m_original_type!=ITEM_NONE);
m_type = m_original_type;
setType(m_original_type);
m_original_type = ITEM_NONE;
m_node->setMesh(m_original_mesh);
} // switchBack
@ -88,7 +98,7 @@ void Item::reset()
m_deactive_time = 0.0f;
if(m_original_type!=ITEM_NONE)
{
m_type = m_original_type;
setType(m_original_type);
m_original_type = ITEM_NONE;
}
} // reset
@ -102,7 +112,7 @@ void Item::setParent(Kart* parent)
{
m_event_handler = parent;
m_deactive_time = 1.5f;
}
} // setParent
//-----------------------------------------------------------------------------
/** Updated the item - rotates it, takes care of items coming back into
@ -111,7 +121,7 @@ void Item::setParent(Kart* parent)
*/
void Item::update(float dt)
{
if(m_event_handler != NULL && m_deactive_time > 0) m_deactive_time -= dt;
if(m_deactive_time > 0) m_deactive_time -= dt;
if(m_collected)
{
@ -161,9 +171,20 @@ void Item::update(float dt)
*/
void Item::collected(float t)
{
m_collected = true;
// Note if the time is negative, in update the m_collected flag will
// be automatically set to false again.
m_time_till_return = t;
m_collected = true;
if(m_type==ITEM_BUBBLEGUM)
{
deactivate(0.5);
// Set the time till reappear to -1 seconds --> the item will
// reappear immediately.
m_time_till_return = -1;
}
else
{
// Note if the time is negative, in update the m_collected flag will
// be automatically set to false again.
m_time_till_return = t;
}
} // isCollected

View File

@ -84,10 +84,10 @@ private:
deactivate collision so a kart is not hit by its own item */
float m_deactive_time;
void setType(ItemType type);
public:
Item (ItemType type, const Vec3& xyz, const Vec3& normal,
scene::IMesh* mesh, unsigned int item_id,
bool rotate=true);
scene::IMesh* mesh, unsigned int item_id);
virtual ~Item ();
void update (float delta);
virtual void collected(float t=2.0f);

View File

@ -29,7 +29,6 @@
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "io/file_manager.hpp"
#include "items/bubblegumitem.hpp"
#include "karts/kart.hpp"
#include "network/network_manager.hpp"
#include "tracks/track.hpp"
@ -143,12 +142,7 @@ Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz,
const Vec3 &normal, Kart *parent)
{
Item* h;
if(type == Item::ITEM_BUBBLEGUM)
h = new BubbleGumItem(type, xyz, normal, m_item_mesh[type],
m_all_items.size());
else
h = new Item(type, xyz, normal, m_item_mesh[type],
m_all_items.size());
h = new Item(type, xyz, normal, m_item_mesh[type], m_all_items.size());
if(parent != NULL) h->setParent(parent);
m_all_items.push_back(h);
@ -209,7 +203,7 @@ void ItemManager::reset()
{
if((*i)->getType()==Item::ITEM_BUBBLEGUM)
{
BubbleGumItem *b=static_cast<BubbleGumItem*>(*i);
Item *b=*i;
AllItemTypes::iterator i_next = m_all_items.erase(i);
delete b;
i = i_next;