first introduction of bubble gum, many improvements still necessary before it is complete

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2414 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2008-11-07 01:18:04 +00:00
parent c553ec77ee
commit 7c1d3560bf
21 changed files with 178 additions and 5971 deletions

View File

@ -2,7 +2,7 @@
(tuxkart-collectable
(name "missile")
(model "missile.ac")
(model "../items/bubblegum.ac")
(icon "missile.rgb")
(speed 50.0)
(min-height 0.3)

File diff suppressed because it is too large Load Diff

View File

@ -58,12 +58,12 @@ supertuxkart_SOURCES = main.cpp \
grand_prix_manager.cpp grand_prix_manager.hpp \
items/attachment.cpp items/attachment.hpp \
items/attachment_manager.cpp items/attachment_manager.hpp \
items/powerup.cpp items/powerup.hpp \
items/powerup_manager.cpp items/powerup_manager.hpp \
items/powerup.cpp items/powerup.hpp \
items/powerup_manager.cpp items/powerup_manager.hpp \
items/item.cpp items/item.hpp \
items/item_manager.cpp items/item_manager.hpp \
items/projectile_manager.cpp items/projectile_manager.hpp \
items/missile.cpp items/missile.hpp \
items/bubblegumitem.cpp items/bubblegumitem.hpp \
items/cake.cpp items/cake.hpp \
items/bowling.cpp items/bowling.hpp \
karts/kart_model.cpp karts/kart_model.hpp \

View File

@ -22,6 +22,7 @@
#include "network/flyable_info.hpp"
#include "flyable.hpp"
#include "kart.hpp"
#include "track.hpp"
#include "items/projectile_manager.hpp"
#include "callback_manager.hpp"
#include "scene.hpp"
@ -96,7 +97,6 @@ void Flyable::createPhysics(float y_offset, const btVector3 velocity,
m_body->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
} // createPhysics
// -----------------------------------------------------------------------------
void Flyable::init(const lisp::Lisp* lisp, ssgEntity *model,
PowerupType type)

View File

@ -70,6 +70,7 @@ protected:
*/
void getClosestKart(const Kart **minKart, float *minDistSquared,
btVector3 *minDelta, const Kart* inFrontOf=NULL) const;
/** init bullet for moving objects like projectiles */
void createPhysics(float y_offset,
const btVector3 velocity,
btCollisionShape *shape, const bool gravity=false,

View File

@ -58,10 +58,10 @@ HelpPageTwo::HelpPageTwo()
widget_manager->breakLine();
widget_manager->addImgWgt( WTOK_IMG1, 10, 12,
powerup_manager->getIcon(POWERUP_MISSILE)->getState()->getTextureHandle());
powerup_manager->getIcon(POWERUP_BUBBLEGUM)->getState()->getTextureHandle());
widget_manager->addTextWgt( WTOK_TXT1, 90, 12,
_("Missile - fast stopper in a straight line"));
_("BubbleGum - leave a sticky pink puddle behind you"));
widget_manager->setWgtRoundCorners( WTOK_TXT1, WGT_AREA_RGT );
widget_manager->breakLine();

View File

@ -178,7 +178,7 @@ RaceGUI::handle(GameAction ga, int value)
if (race_manager->getNumPlayers() ==1 )
{
Kart* kart = RaceManager::getPlayerKart(0);
kart->setPowerup(POWERUP_MISSILE, 10000);
kart->setPowerup(POWERUP_BUBBLEGUM, 10000);
}
break;
case GA_DEBUG_ADD_HOMING:

View File

@ -13,6 +13,8 @@
95090A4C0EB7EA960048841A /* item_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95090A480EB7EA960048841A /* item_manager.cpp */; };
9518C11D0EB7AF7A00952372 /* cake.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9518C11B0EB7AF7A00952372 /* cake.cpp */; };
9518C11E0EB7AF7A00952372 /* cake.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9518C11C0EB7AF7A00952372 /* cake.hpp */; };
951DF9B50EC2899200F18CE6 /* bubblegumitem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951DF9B30EC2899200F18CE6 /* bubblegumitem.cpp */; };
951DF9B60EC2899200F18CE6 /* bubblegumitem.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 951DF9B40EC2899200F18CE6 /* bubblegumitem.hpp */; };
958EEFB60EB93C03005F6F70 /* item_info.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 958EEFB50EB93C03005F6F70 /* item_info.hpp */; };
958EF0130EB94819005F6F70 /* powerup_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958EF00F0EB94818005F6F70 /* powerup_manager.cpp */; };
958EF0140EB94819005F6F70 /* powerup_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 958EF0100EB94819005F6F70 /* powerup_manager.hpp */; };
@ -394,7 +396,6 @@
95B0D35B0EB69DDF001A0D06 /* attachment_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE2A0EB69DD9001A0D06 /* attachment_manager.hpp */; };
95B0D35C0EB69DDF001A0D06 /* bowling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE2B0EB69DD9001A0D06 /* bowling.cpp */; };
95B0D35D0EB69DDF001A0D06 /* bowling.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE2C0EB69DD9001A0D06 /* bowling.hpp */; };
95B0D3680EB69DDF001A0D06 /* missile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE370EB69DD9001A0D06 /* missile.cpp */; };
95B0D3690EB69DDF001A0D06 /* missile.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE380EB69DD9001A0D06 /* missile.hpp */; };
95B0D36A0EB69DDF001A0D06 /* projectile_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE390EB69DD9001A0D06 /* projectile_manager.cpp */; };
95B0D36B0EB69DDF001A0D06 /* projectile_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE3A0EB69DD9001A0D06 /* projectile_manager.hpp */; };
@ -832,6 +833,7 @@
958EEFB60EB93C03005F6F70 /* item_info.hpp in CopyFiles */,
958EF0140EB94819005F6F70 /* powerup_manager.hpp in CopyFiles */,
958EF0150EB94819005F6F70 /* powerup.hpp in CopyFiles */,
951DF9B60EC2899200F18CE6 /* bubblegumitem.hpp in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
@ -844,6 +846,8 @@
95090A480EB7EA960048841A /* item_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = item_manager.cpp; sourceTree = "<group>"; };
9518C11B0EB7AF7A00952372 /* cake.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cake.cpp; sourceTree = "<group>"; };
9518C11C0EB7AF7A00952372 /* cake.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = cake.hpp; sourceTree = "<group>"; };
951DF9B30EC2899200F18CE6 /* bubblegumitem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = bubblegumitem.cpp; sourceTree = "<group>"; };
951DF9B40EC2899200F18CE6 /* bubblegumitem.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = bubblegumitem.hpp; sourceTree = "<group>"; };
958EEFB50EB93C03005F6F70 /* item_info.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = item_info.hpp; sourceTree = "<group>"; };
958EF00F0EB94818005F6F70 /* powerup_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = powerup_manager.cpp; sourceTree = "<group>"; };
958EF0100EB94819005F6F70 /* powerup_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = powerup_manager.hpp; sourceTree = "<group>"; };
@ -2290,6 +2294,8 @@
95B0CE260EB69DD9001A0D06 /* items */ = {
isa = PBXGroup;
children = (
951DF9B30EC2899200F18CE6 /* bubblegumitem.cpp */,
951DF9B40EC2899200F18CE6 /* bubblegumitem.hpp */,
958EF00F0EB94818005F6F70 /* powerup_manager.cpp */,
958EF0100EB94819005F6F70 /* powerup_manager.hpp */,
958EF0110EB94819005F6F70 /* powerup.hpp */,
@ -2953,7 +2959,6 @@
95B0D3580EB69DDF001A0D06 /* attachment.cpp in Sources */,
95B0D35A0EB69DDF001A0D06 /* attachment_manager.cpp in Sources */,
95B0D35C0EB69DDF001A0D06 /* bowling.cpp in Sources */,
95B0D3680EB69DDF001A0D06 /* missile.cpp in Sources */,
95B0D36A0EB69DDF001A0D06 /* projectile_manager.cpp in Sources */,
95B0D36C0EB69DDF001A0D06 /* kart.cpp in Sources */,
95B0D3700EB69DDF001A0D06 /* kart_properties.cpp in Sources */,
@ -3017,6 +3022,7 @@
95090A4C0EB7EA960048841A /* item_manager.cpp in Sources */,
958EF0130EB94819005F6F70 /* powerup_manager.cpp in Sources */,
958EF0160EB94819005F6F70 /* powerup.cpp in Sources */,
951DF9B50EC2899200F18CE6 /* bubblegumitem.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -0,0 +1,34 @@
// $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, ssgEntity* model,
unsigned int item_id) : Item(type, xyz, model, item_id)
{
m_rotate = false;
} // BubbleGumItem
//-----------------------------------------------------------------------------
BubbleGumItem::~BubbleGumItem()
{
} // ~BubbleGumItem
//-----------------------------------------------------------------------------

View File

@ -0,0 +1,35 @@
// $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_H
#define HEADER_BUBBLEGUMITEM_H
#include "items/item.hpp"
// -----------------------------------------------------------------------------
class BubbleGumItem : public Item
{
public:
BubbleGumItem (ItemType type, const Vec3& xyz, ssgEntity* model,
unsigned int item_id);
~BubbleGumItem ();
}
; // class Item
#endif

View File

@ -36,6 +36,10 @@ Item::Item(ItemType type, const Vec3& xyz, ssgEntity* model,
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
m_root->addKid(model);
scene->add(m_root);
m_rotate = true;
m_parent = NULL;
m_immunity_timer = 0;
} // Item
@ -52,16 +56,25 @@ void Item::reset()
m_time_till_return = 0.0f;
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
} // reset
//-----------------------------------------------------------------------------
int Item::hitKart(Kart* kart)
void Item::setParent(Kart* parent)
{
m_parent = parent;
m_immunity_timer = 1.5f;
}
//-----------------------------------------------------------------------------
bool Item::hitKart(Kart* kart)
{
if(m_immunity_timer > 0) return false;
return (kart->getXYZ()-m_coord.getXYZ()).length2()<0.8f;
} // hitKart
//-----------------------------------------------------------------------------
void Item::update(float delta)
{
if(m_parent != NULL && m_immunity_timer > 0) m_immunity_timer -= delta;
if(m_collected)
{
m_time_till_return -= delta;
@ -83,6 +96,9 @@ void Item::update(float delta)
}
else
{ // not m_collected
if(!m_rotate) return;
// have it rotate
Vec3 rotation(delta*M_PI, 0, 0);
m_coord.setHPR(m_coord.getHPR()+rotation);
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));

View File

@ -29,13 +29,23 @@ class Kart;
class ssgTransform;
class ssgEntity;
// ITEM_BONUS_BOX must be the first, ITEM_SILVER_COIN the last entry. See ItemManager
enum ItemType { ITEM_BONUS_BOX, ITEM_BANANA, ITEM_GOLD_COIN, ITEM_SILVER_COIN, ITEM_NONE };
enum ItemType
{
ITEM_FIRST = -1,
ITEM_BONUS_BOX = 0,
ITEM_BANANA,
ITEM_GOLD_COIN,
ITEM_SILVER_COIN,
ITEM_BUBBLEGUM,
ITEM_LAST
};
// -----------------------------------------------------------------------------
class Item
{
private:
protected:
ItemType m_type; // Item type
bool m_collected; // true if item was collected & is not displayed
float m_time_till_return; // time till a collected item reappears
@ -43,6 +53,12 @@ private:
// collected items reappear.
ssgTransform* m_root; // The actual root of the item
unsigned int m_item_id; // index in item_manager field
bool m_rotate; // set to false if item should not rotate
Kart* m_parent; // optional, if item was placed by a kart, a timer
float m_immunity_timer; // can be used so it's not hit by its own item
public:
Item (ItemType type, const Vec3& xyz, ssgEntity* model,
unsigned int item_id);
@ -50,11 +66,13 @@ public:
unsigned int getItemId() const {return m_item_id; }
void update (float delta);
void isCollected ();
int hitKart (Kart* kart );
bool hitKart (Kart* kart );
void reset ();
ssgTransform* getRoot () const {return m_root;}
ItemType getType () const {return m_type;}
ItemType getType () const {return m_type;}
bool wasCollected() const {return m_collected;}
void setParent(Kart* parent);
}
; // class Item

View File

@ -24,6 +24,7 @@
#include "network/network_manager.hpp"
#include "user_config.hpp"
#include "items/item_manager.hpp"
#include "items/bubblegumitem.hpp"
#include "file_manager.hpp"
#include "loader.hpp"
#include "material_manager.hpp"
@ -155,12 +156,16 @@ void ItemManager::loadDefaultItems()
void ItemManager::setDefaultItemStyle()
{
// This should go in an internal, system wide configuration file
const std::string DEFAULT_NAMES[4] = {"bonusblock", "banana",
"goldcoin", "silvercoin"};
std::string DEFAULT_NAMES[ITEM_LAST - ITEM_FIRST - 1];
DEFAULT_NAMES[ITEM_BONUS_BOX] = "bonusblock";
DEFAULT_NAMES[ITEM_BANANA] = "banana";
DEFAULT_NAMES[ITEM_GOLD_COIN] = "goldcoin";
DEFAULT_NAMES[ITEM_SILVER_COIN] = "silvercoin";
DEFAULT_NAMES[ITEM_BUBBLEGUM] = "bubblegum";
bool bError=0;
char msg[MAX_ERROR_MESSAGE_LENGTH];
for(int i=ITEM_BONUS_BOX; i<=ITEM_SILVER_COIN; i++)
for(int i=ITEM_FIRST+1; i<ITEM_LAST; i++)
{
m_item_model[i] = m_all_models[DEFAULT_NAMES[i]];
if(!m_item_model[i])
@ -198,9 +203,16 @@ void ItemManager::setDefaultItemStyle()
} // setDefaultItemStyle
//-----------------------------------------------------------------------------
Item* ItemManager::newItem(ItemType type, const Vec3& xyz)
Item* ItemManager::newItem(ItemType type, const Vec3& xyz, Kart* parent)
{
Item* h = new Item(type, xyz, m_item_model[type], m_all_items.size());
Item* h;
if(type == ITEM_BUBBLEGUM)
h = new BubbleGumItem(type, xyz, m_item_model[type], m_all_items.size());
else
h = new Item(type, xyz, m_item_model[type], m_all_items.size());
if(parent != NULL) h->setParent(parent);
m_all_items.push_back(h);
return h;
} // newItem

View File

@ -56,7 +56,7 @@ public:
~ItemManager();
void loadDefaultItems();
void loadItemStyle (const std::string filename);
Item* newItem (ItemType type, const Vec3& xyz);
Item* newItem (ItemType type, const Vec3& xyz, Kart* parent=NULL);
void update (float delta);
void hitItem (Kart* kart);
void cleanup ();

View File

@ -89,13 +89,32 @@ void Powerup::use()
break ;
case POWERUP_CAKE:
case POWERUP_BOWLING:
case POWERUP_MISSILE:
m_sound_shot->position(m_owner->getXYZ());
m_sound_shot->play();
projectile_manager->newProjectile(m_owner, m_type);
break ;
case POWERUP_BUBBLEGUM:
{
m_sound_shot->position(m_owner->getXYZ());
m_sound_shot->play();
btVector3 pos = m_owner->getXYZ();
float z_coord = Track::NOHIT;
Vec3 unused; const Material* unused2;
RaceManager::getTrack()->getTerrainInfo(pos, &z_coord, &unused, &unused2);
assert(z_coord != Track::NOHIT);
pos.setZ(z_coord-0.05f);
item_manager->newItem(ITEM_BUBBLEGUM, pos, m_owner);
}
break;
case POWERUP_ANVIL:
//Attach an anvil(twice as good as the one given
//by the bananas) to the kart in the 1st position.
for(unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i)

View File

@ -24,8 +24,7 @@
#include "material_manager.hpp"
#include "material.hpp"
#include "translation.hpp"
#include "items/bowling.hpp"
#include "missile.hpp"
#include "items/bowling.hpp"
#include "items/cake.hpp"
#include "loader.hpp"
@ -44,7 +43,7 @@ initPowerupType ict[]=
{
{POWERUP_ZIPPER, "zipper.collectable" },
{POWERUP_BOWLING, "bowling.projectile" },
{POWERUP_MISSILE, "missile.projectile" },
{POWERUP_BUBBLEGUM, "missile.projectile" },
{POWERUP_CAKE, "cake.projectile" },
{POWERUP_ANVIL, "anvil.collectable" },
{POWERUP_PARACHUTE, "parachute.collectable" },
@ -137,8 +136,8 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType )
switch (collectType) {
case POWERUP_BOWLING:
Bowling::init (lisp, m_all_models[collectType]); break;
case POWERUP_MISSILE:
Missile::init(lisp, m_all_models[collectType]); break;
//case POWERUP_BUBBLEGUM:
// BubbleGum::init(lisp, m_all_models[collectType]); break;
case POWERUP_CAKE:
Cake::init (lisp, m_all_models[collectType]); break;
default:;

View File

@ -30,7 +30,7 @@ class ssgEntity;
// The anvil and parachute must be at the end of the enum, and the
// zipper just before them (see Powerup::hitBonusBox).
enum PowerupType {POWERUP_NOTHING,
POWERUP_MISSILE, POWERUP_CAKE,
POWERUP_BUBBLEGUM, POWERUP_CAKE,
POWERUP_BOWLING, POWERUP_ZIPPER,
POWERUP_PARACHUTE, POWERUP_ANVIL,
POWERUP_MAX};

View File

@ -22,7 +22,6 @@
#include "loader.hpp"
#include "items/projectile_manager.hpp"
#include "items/bowling.hpp"
#include "missile.hpp"
#include "items/cake.hpp"
#include "explosion.hpp"
#include "items/powerup_manager.hpp"
@ -187,7 +186,7 @@ Flyable *ProjectileManager::newProjectile(Kart *kart, PowerupType type)
{
case POWERUP_BOWLING: f = new Bowling(kart); break;
case POWERUP_CAKE: f = new Cake(kart); break;
case POWERUP_MISSILE: f = new Missile(kart); break;
// case POWERUP_BUBBLEGUM: f = new BubbleGum(kart); break;
default: return NULL;
}
m_active_projectiles.push_back(f);

View File

@ -370,6 +370,10 @@ void Kart::collectedItem(const Item &item, int add_info)
int n=1 + 4*getNumItems() / MAX_ITEMS_COLLECTED;
m_powerup.hitBonusBox(n, item,add_info);break;
}
case ITEM_BUBBLEGUM:
// skid
m_body->setAngularVelocity( btVector3(0,0,4) );
break;
default : break;
} // switch TYPE

View File

@ -300,7 +300,7 @@ void PlayerKart::collectedItem(const Item &item, int add_info)
}
else
{
if(item.getType() == ITEM_BANANA)
if(item.getType() == ITEM_BANANA || item.getType() == ITEM_BUBBLEGUM)
m_ugh_sound->play();
else
m_grab_sound->play();

View File

@ -376,7 +376,7 @@ void DefaultRobot::handle_items( const float DELTA, const int STEPS )
}
break;
case POWERUP_MISSILE:
case POWERUP_BUBBLEGUM:
case POWERUP_CAKE:
if( m_time_since_last_shot > 5.0f && m_crashes.m_kart != -1 )
{