From 566e12d129cc6aebeebcfb85b987d5f876b86544 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 7 Feb 2010 08:49:36 +0000 Subject: [PATCH] 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 --- data/stk_config.xml | 4 +-- src/Makefile.am | 2 -- src/ide/vc9/supertuxkart.vcproj | 8 ------ src/input/input_manager.cpp | 2 +- src/items/bubblegumitem.cpp | 45 --------------------------------- src/items/bubblegumitem.hpp | 37 --------------------------- src/items/item.cpp | 45 ++++++++++++++++++++++++--------- src/items/item.hpp | 4 +-- src/items/item_manager.cpp | 10 ++------ 9 files changed, 40 insertions(+), 117 deletions(-) delete mode 100644 src/items/bubblegumitem.cpp delete mode 100644 src/items/bubblegumitem.hpp diff --git a/data/stk_config.xml b/data/stk_config.xml index 75b0d138a..87054859d 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -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 --> the item will - // reappear immediately. - Item::collected(-1); -} // isCollected diff --git a/src/items/bubblegumitem.hpp b/src/items/bubblegumitem.hpp deleted file mode 100644 index 00e1e7f65..000000000 --- a/src/items/bubblegumitem.hpp +++ /dev/null @@ -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 -// -// 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 diff --git a/src/items/item.cpp b/src/items/item.cpp index 495349ccb..7a45c316f 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -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 diff --git a/src/items/item.hpp b/src/items/item.hpp index 838dbb360..4dae617b1 100644 --- a/src/items/item.hpp +++ b/src/items/item.hpp @@ -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); diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 2e3d9f489..ff2480063 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -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(*i); + Item *b=*i; AllItemTypes::iterator i_next = m_all_items.erase(i); delete b; i = i_next;