super-tux-commit Mailing List for Super Tux (Page 23)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Matze B. <mat...@us...> - 2004-11-20 22:17:56
|
Update of /cvsroot/super-tux/supertux/src/trigger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7746/src/trigger Added Files: .cvsignore Log Message: added more cvsignores because scons is placing .sconsign files all over the place :-/ --- NEW FILE: .cvsignore --- .sconsign |
From: Matze B. <mat...@us...> - 2004-11-20 22:17:56
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7746/src/object Added Files: .cvsignore Log Message: added more cvsignores because scons is placing .sconsign files all over the place :-/ --- NEW FILE: .cvsignore --- .sconsign |
From: Matze B. <mat...@us...> - 2004-11-20 22:17:56
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7746/lib/app Added Files: .cvsignore Log Message: added more cvsignores because scons is placing .sconsign files all over the place :-/ --- NEW FILE: .cvsignore --- .sconsign |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:19
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/video Modified Files: drawing_context.cpp font.cpp screen.cpp surface.cpp Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- font.cpp 16 Oct 2004 11:20:28 -0000 1.13 +++ font.cpp 20 Nov 2004 22:14:37 -0000 1.14 @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include <config.h> + #include <cstdlib> #include <cstring> Index: screen.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/screen.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- screen.cpp 27 Aug 2004 20:34:56 -0000 1.5 +++ screen.cpp 20 Nov 2004 22:14:37 -0000 1.6 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <iostream> #include <cstdio> #include <cstdlib> @@ -36,7 +38,6 @@ #include "../video/screen.h" #include "../app/globals.h" #include "../video/drawing_context.h" -#include "../special/base.h" #include "../math/vector.h" using namespace SuperTux; Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- drawing_context.cpp 24 Sep 2004 18:13:27 -0000 1.9 +++ drawing_context.cpp 20 Nov 2004 22:14:36 -0000 1.10 @@ -16,6 +16,8 @@ // 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 <config.h> + #include <algorithm> #include <cassert> #include <iostream> @@ -29,9 +31,9 @@ DrawingContext::DrawingContext() { -transform.draw_effect = NONE_EFFECT; -transform.zoom = 1; -transform.alpha = 255; + transform.draw_effect = NONE_EFFECT; + transform.zoom = 1; + transform.alpha = 255; } DrawingContext::~DrawingContext() @@ -50,6 +52,11 @@ request.layer = layer; request.request_data = const_cast<Surface*> (surface); request.pos = transform.apply(position); + + if(request.pos.x >= screen->w || request.pos.y >= screen->h + || request.pos.x + surface->w < 0 || request.pos.y + surface->h < 0) + return; + request.drawing_effect = drawing_effect; request.drawing_effect = transform.draw_effect | drawing_effect; request.zoom = transform.zoom; Index: surface.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/surface.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- surface.cpp 23 Oct 2004 11:30:12 -0000 1.13 +++ surface.cpp 20 Nov 2004 22:14:37 -0000 1.14 @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include <config.h> + #include <cassert> #include <iostream> #include <algorithm> |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:19
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/special Modified Files: frame_rate.cpp game_object.cpp game_object.h moving_object.cpp moving_object.h sprite.cpp sprite.h sprite_manager.cpp sprite_manager.h timer.cpp timer.h Added Files: collision.cpp collision.h collision_hit.h sprite_data.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: moving_object.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/moving_object.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- moving_object.cpp 22 Jul 2004 19:07:50 -0000 1.3 +++ moving_object.cpp 20 Nov 2004 22:14:36 -0000 1.4 @@ -17,14 +17,14 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include "../special/moving_object.h" using namespace SuperTux; MovingObject::MovingObject() { - base.x = base.y = base.width = base.height = 0; - old_base = base; } MovingObject::~MovingObject() Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/timer.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- timer.h 28 Jul 2004 23:06:12 -0000 1.5 +++ timer.h 20 Nov 2004 22:14:36 -0000 1.6 @@ -30,12 +30,12 @@ { public: /// Time a game is running. (Non-pause mode, etc.) - static unsigned int get(void); + static unsigned int get(); - static void pause_init(void); - static void pause_start(void); - static void pause_stop(void); - static bool pause_started(void); + static void pause_init(); + static void pause_start(); + static void pause_stop(); + static bool pause_started(); private: static unsigned int pause_ticks; Index: frame_rate.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/frame_rate.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- frame_rate.cpp 29 Jul 2004 11:05:28 -0000 1.2 +++ frame_rate.cpp 20 Nov 2004 22:14:36 -0000 1.3 @@ -16,6 +16,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include "SDL.h" #include "../special/frame_rate.h" Index: sprite_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- sprite_manager.cpp 17 Aug 2004 21:53:20 -0000 1.4 +++ sprite_manager.cpp 20 Nov 2004 22:14:36 -0000 1.5 @@ -16,13 +16,19 @@ // 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 <config.h> #include <iostream> +#include <sstream> +#include <stdexcept> -#include "../utils/lispreader.h" -#include "../special/sprite_manager.h" +#include "utils/lispreader.h" +#include "sprite_manager.h" +#include "sprite_data.h" +#include "sprite.h" -using namespace SuperTux; +namespace SuperTux +{ SpriteManager::SpriteManager(const std::string& filename) { @@ -31,8 +37,7 @@ SpriteManager::~SpriteManager() { - for(std::map<std::string, Sprite*>::iterator i = sprites.begin(); - i != sprites.end(); ++i) { + for(Sprites::iterator i = sprites.begin(); i != sprites.end(); ++i) { delete i->second; } } @@ -53,47 +58,42 @@ return; cur = lisp_cdr(cur); - while(cur) - { - lisp_object_t* el = lisp_car(cur); - - if (strcmp(lisp_symbol(lisp_car(el)), "sprite") == 0) - { - Sprite* sprite = new Sprite(lisp_cdr(el)); + while(cur) { + lisp_object_t* el = lisp_car(cur); - Sprites::iterator i = sprites.find(sprite->get_name()); - if (i == sprites.end()) - { - sprites[sprite->get_name()] = sprite; - } - else - { - delete i->second; - i->second = sprite; - std::cout << "Warning: dulpicate entry: '" << sprite->get_name() << "'" << std::endl; - } - } - else - { - std::cout << "SpriteManager: Unknown tag" << std::endl; - } + if (strcmp(lisp_symbol(lisp_car(el)), "sprite") == 0) { + SpriteData* spritedata = new SpriteData(lisp_cdr(el)); - cur = lisp_cdr(cur); + Sprites::iterator i = sprites.find(spritedata->get_name()); + if (i == sprites.end()) { + sprites[spritedata->get_name()] = spritedata; + } else { + delete i->second; + i->second = spritedata; + std::cout << "Warning: dulpicate entry: '" << spritedata->get_name() + << "' in spritefile." << std::endl; + } + } else { + std::cout << "SpriteManager: Unknown tag in spritefile.\n"; } + cur = lisp_cdr(cur); + } + lisp_free(root_obj); } Sprite* -SpriteManager::load(const std::string& name) +SpriteManager::create(const std::string& name) { Sprites::iterator i = sprites.find(name); - if (i == sprites.end()) - { - std::cerr << "Warning: Sprite '" << name << "' not found" << std::endl; - return 0; - } - return i->second; + if(i == sprites.end()) { + std::stringstream msg; + msg << "Sprite '" << name << "' not found."; + throw std::runtime_error(msg.str()); + } + return new Sprite(*i->second); +} + } -/* EOF */ --- NEW FILE: collision.h --- #ifndef __COLLISION_H__ #define __COLLISION_H__ namespace SuperTux { class Rectangle; class CollisionHit; class AATriangle; class Collision { public: /** does collision detection between 2 rectangles. Returns true in case of * collision and fills in the hit structure then. */ static bool rectangle_rectangle(CollisionHit& hit, const Rectangle& r1, const Rectangle& r2); /** does collision detection between a rectangle and an axis aligned triangle * Returns true in case of a collision and fills in the hit structure then. */ static bool rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect, const AATriangle& triangle); }; } #endif Index: game_object.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/game_object.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- game_object.cpp 22 Jul 2004 19:07:50 -0000 1.3 +++ game_object.cpp 20 Nov 2004 22:14:36 -0000 1.4 @@ -1,7 +1,7 @@ // $Id$ // // SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun <ma...@br... +// Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -17,12 +17,15 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include "../special/game_object.h" -using namespace SuperTux; +namespace SuperTux +{ GameObject::GameObject() - : wants_to_die(false) + : wants_to_die(false), flags(0) { } @@ -30,3 +33,4 @@ { } +} Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- sprite.cpp 25 Oct 2004 03:32:49 -0000 1.29 +++ sprite.cpp 20 Nov 2004 22:14:36 -0000 1.30 @@ -16,247 +16,141 @@ // 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 <config.h> #include <iostream> #include <cmath> +#include <stdexcept> #include "../app/globals.h" #include "../app/setup.h" #include "../special/sprite.h" #include "../video/drawing_context.h" -using namespace SuperTux; - -Sprite::Sprite(lisp_object_t* cur) +namespace SuperTux { - for(; !lisp_nil_p(cur); cur = lisp_cdr(cur)) - { - std::string token = lisp_symbol(lisp_car(lisp_car(cur))); - lisp_object_t* data = lisp_car(lisp_cdr(lisp_car(cur))); - LispReader reader(lisp_cdr(lisp_car(cur))); - - if(token == "name") - name = lisp_string(data); - else if(token == "action") - parse_action(reader); - else - std::cerr << "Warning: Unknown sprite field: " << token << std::endl; - } - - if(name.empty()) - Termination::abort("Error: Sprite wihtout name.", ""); - if(actions.empty()) - Termination::abort("Error: Sprite wihtout actions.", ""); -} -Sprite::~Sprite() +Sprite::Sprite(SpriteData& newdata) + : data(newdata) { - for(Actions::iterator i_act = actions.begin(); i_act != actions.end(); ++i_act) - { - for(std::vector<Surface*>::iterator i_sur = i_act->second->surfaces.begin(); - i_sur != i_act->second->surfaces.end(); ++i_sur) - { - delete *i_sur; - } - delete i_act->second; - } + action = data.actions.begin()->second; + reset(); } -void -Sprite::parse_action(LispReader& lispreader) +Sprite::Sprite(const Sprite& other) + : data(other.data), frame(other.frame), + animation_loops(other.animation_loops), last_tick(other.last_tick), + action(other.action), next_action(other.next_action) { - action = new Action; - - init_defaults(action); - - if(!lispreader.read_string("name", action->name)) - if(!actions.empty()) - Termination::abort("Error: If there are more than one action, they need names!", ""); - lispreader.read_int("x-offset", action->x_offset); - lispreader.read_int("y-offset", action->y_offset); - lispreader.read_int("z-order", action->z_order); - lispreader.read_float("fps", action->fps); - - /* TODO: add a top filter entry */ - std::vector <int> mask_color; - lispreader.read_int_vector("apply-mask", mask_color); - if(mask_color.size() == 4) - { - for(std::vector<Surface*>::iterator i = action->surfaces.begin(); - i < action->surfaces.end(); i++) - { - (*i)->apply_filter(MASK_FILTER, Color(mask_color)); - } - } - - std::string mirror_action; - lispreader.read_string("mirror-action", mirror_action); - if(!mirror_action.empty()) - { - Action* act_tmp = get_action(mirror_action); - if(act_tmp == NULL) - std::cerr << "Warning: Could not mirror action. Action not found\n" - "Mirror actions must be defined after the real one!\n"; - else - { - for(int i = 0; static_cast<unsigned int>(i) < act_tmp->surfaces.size(); i++) - { - Surface* surface = new Surface(sdl_surface_from_sdl_surface( - act_tmp->surfaces[i]->impl->get_sdl_surface(), true), true); - surface->apply_filter(HORIZONTAL_FLIP_FILTER); - action->surfaces.push_back(surface); - } - } - } - else // Load images - { - std::vector<std::string> images; - if(!lispreader.read_string_vector("images", images)) - Termination::abort("Sprite contains no images: ", action->name); - - for(std::vector<std::string>::size_type i = 0; i < images.size(); i++) - { - action->surfaces.push_back( - new Surface(datadir + "/images/" + images[i], true)); - } - } - actions[action->name] = action; } -/*void Sprite::parse_filter(LispReader& lispreader) -{ - -}*/ - -void -Sprite::init_defaults(Action* act) +Sprite::~Sprite() { - act->x_offset = 0; - act->y_offset = 0; - act->z_order = 0; - act->fps = 10; - - start_animation(-1); } void -Sprite::set_action(std::string act) +Sprite::set_action(std::string name) { -if(!next_action.empty() && animation_loops > 0) - { - next_action = act; - return; - } -Actions::iterator i = actions.find(act); -if(i == actions.end()) - { - std::cerr << "Warning: Action '" << act << "' not found on Sprite '" << name << "'\n"; - return; + if(!next_action.empty() && animation_loops > 0) { + next_action = name; + return; } -action = i->second; -} + SpriteData::Action* newaction = data.get_action(name); + if(!action) + return; -Sprite::Action* -Sprite::get_action(std::string act) -{ -Actions::iterator i = actions.find(act); -if(i == actions.end()) - { - std::cerr << "Warning: Action '" << act << "' not found on Sprite '" << name << "'\n"; - return NULL; - } -return i->second; + action = newaction; } void Sprite::start_animation(int loops) { -reset(); -animation_loops = loops; + reset(); + animation_loops = loops; } void Sprite::reset() { -frame = 0; -last_tick = SDL_GetTicks(); -animation_reversed = false; -next_action.clear(); + frame = 0; + last_tick = SDL_GetTicks(); + animation_reversed = false; + animation_loops = -1; + next_action.clear(); } bool Sprite::check_animation() { -return animation_loops; + return animation_loops; } void Sprite::reverse_animation(bool reverse) { -animation_reversed = reverse; + animation_reversed = reverse; -if(animation_reversed) - frame = get_frames()-1; -else - frame = 0; + if(animation_reversed) + frame = get_frames()-1; + else + frame = 0; } void Sprite::update() { -if(animation_loops == 0) + if(animation_loops == 0) { - if(frame >= get_frames() || frame < 0) - frame = 0; - return; + if(frame >= get_frames() || frame < 0) + frame = 0; + return; } -float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick); -last_tick = SDL_GetTicks(); + float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick); + last_tick = SDL_GetTicks(); -if(animation_reversed) - frame -= frame_inc; -else - frame += frame_inc; + if(animation_reversed) + frame -= frame_inc; + else + frame += frame_inc; -if(animation_reversed) - { - if(frame < 0 || frame >= (float)get_frames()) - { // last case can happen when not used reverse_animation() - float excedent = frame - 0; - frame = get_frames() - 1; - if(animation_loops > 0) + if(animation_reversed) { + if(frame < 0 || frame >= (float)get_frames()) { + // last case can happen when not used reverse_animation() + float excedent = frame - 0; + frame = get_frames() - 1; + if(animation_loops > 0) { - animation_loops--; - if(animation_loops == 0 && !next_action.empty()) + animation_loops--; + if(animation_loops == 0 && !next_action.empty()) { - set_action(next_action); - start_animation(-1); + set_action(next_action); + start_animation(-1); } } - if(fabsf(excedent) < get_frames()) - frame += excedent; + if(fabsf(excedent) < get_frames()) + frame += excedent; } } -else + else { - if(frame >= (float)get_frames()) + if(frame >= (float)get_frames()) { - float excedent = frame - get_frames(); - frame = 0; - if(animation_loops > 0) + float excedent = frame - get_frames(); + frame = 0; + if(animation_loops > 0) { - animation_loops--; - if(animation_loops == 0 && !next_action.empty()) + animation_loops--; + if(animation_loops == 0 && !next_action.empty()) { - set_action(next_action); - start_animation(-1); + set_action(next_action); + start_animation(-1); } } - if(excedent < get_frames()) - frame += excedent; + if(excedent < get_frames()) + frame += excedent; } } } @@ -273,12 +167,13 @@ << "/" << get_action_name() << std::endl; else context.draw_surface(action->surfaces[(int)frame], - pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, drawing_effect); + pos - Vector(action->x_offset, action->y_offset), + layer + action->z_order, drawing_effect); } void -Sprite::draw_part(DrawingContext& context, const Vector& source, const Vector& size, - const Vector& pos, int layer, Uint32 drawing_effect) +Sprite::draw_part(DrawingContext& context, const Vector& source, + const Vector& size, const Vector& pos, int layer, Uint32 drawing_effect) { update(); @@ -288,19 +183,22 @@ << "/" << get_action_name() << std::endl; else context.draw_surface_part(action->surfaces[(int)frame], source, size, - pos - Vector(action->x_offset, action->y_offset), layer + action->z_order, drawing_effect); + pos - Vector(action->x_offset, action->y_offset), + layer + action->z_order, drawing_effect); } int -Sprite::get_width() +Sprite::get_width() const { return action->surfaces[get_frame()]->w; } int -Sprite::get_height() +Sprite::get_height() const { return action->surfaces[get_frame()]->h; } +} + /* EOF */ Index: moving_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/moving_object.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- moving_object.h 22 Jul 2004 19:07:50 -0000 1.3 +++ moving_object.h 20 Nov 2004 22:14:36 -0000 1.4 @@ -20,10 +20,12 @@ #ifndef SUPERTUX_MOVING_OBJECT_H #define SUPERTUX_MOVING_OBJECT_H -#include "../special/base.h" -#include "../special/game_object.h" -#include "../math/vector.h" -//#include "rectangle.h" +#include "game_object.h" +#include "collision_hit.h" +#include "math/vector.h" +#include "math/rectangle.h" + +class Sector; namespace SuperTux { @@ -40,26 +42,35 @@ /** this function is called when the object collided with any other object */ - virtual void collision(const MovingObject& other_object, - int collision_type) = 0; + virtual HitResponse collision(GameObject& other, + const CollisionHit& hit) = 0; - Vector get_pos() const + const Vector& get_pos() const { - return Vector(base.x, base.y); + return bbox.p1; } - base_type base; - base_type old_base; + /** returns the bounding box of the Object */ + const Rectangle& get_bbox() const + { + return bbox; + } + + const Vector& get_movement() const + { + return movement; + } protected: -#if 0 // this will be used in my collision detection rewrite later - /// the current position of the object - Vector pos; - /// the position we want to move until next frame - Vector new_pos; - /// the bounding box relative to the current position - Rectangle bounding_box; -#endif + friend class Sector; + + /** The bounding box of the object (as used for collision detection, this + * isn't necessarily the bounding box for graphics) + */ + Rectangle bbox; + /** The movement that will happen till next frame + */ + Vector movement; }; } //namespace SuperTux --- NEW FILE: sprite_data.h --- // $Id: sprite_data.h,v 1.1 2004/11/20 22:14:36 matzebraun Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...>, // (C) 2004 Matthias Braun <ma...@br...> // // 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 SUPERTUX_SPRITE_DATA_H #define SUPERTUX_SPRITE_DATA_H #include <string> #include <vector> #include <map> #include "../utils/lispreader.h" #include "../video/surface.h" namespace SuperTux { class SpriteData { public: /** cur has to be a pointer to data in the form of ((x-offset 5) (y-offset 10) ...) */ SpriteData(lisp_object_t* cur); ~SpriteData(); const std::string& get_name() const { return name; } private: friend class Sprite; struct Action { Action(); ~Action(); std::string name; /** Position correction */ int x_offset; int y_offset; /** Drawing priority in queue */ int z_order; /** Frames per second */ float fps; /** Mirror is used to avoid duplicating left and right side sprites */ // bool mirror; std::vector<Surface*> surfaces; }; typedef std::map <std::string, Action*> Actions; Actions actions; void parse_action(LispReader& lispreader); /** Get an action */ Action* get_action(std::string act); std::string name; }; } #endif --- NEW FILE: collision.cpp --- #include <config.h> #include "collision.h" #include <algorithm> #include <iostream> #include <stdio.h> #include <float.h> #include <math.h> #include "math/vector.h" #include "math/aatriangle.h" #include "math/rectangle.h" #include "collision_hit.h" namespace SuperTux { bool Collision::rectangle_rectangle(CollisionHit& hit, const Rectangle& r1, const Rectangle& r2) { if(r1.p2.x < r2.p1.x || r1.p1.x > r2.p2.x) return false; if(r1.p2.y < r2.p1.y || r1.p1.y > r2.p2.y) return false; hit.depth = r1.p2.x - r2.p1.x; hit.normal.x = -1; hit.normal.y = 0; float px2 = r2.p2.x - r1.p1.x; if(px2 < hit.depth) { hit.depth = px2; hit.normal.x = 1; hit.normal.y = 0; } float py1 = r1.p2.y - r2.p1.y; if(py1 < hit.depth) { hit.depth = py1; hit.normal.x = 0; hit.normal.y = -1; } float py2 = r2.p2.y - r1.p1.y; if(py2 < hit.depth) { hit.depth = py2; hit.normal.x = 0; hit.normal.y = 1; } return true; } //--------------------------------------------------------------------------- static void makePlane(const Vector& p1, const Vector& p2, Vector& n, float& c) { n = Vector(p2.y-p1.y, p1.x-p2.x); c = -(p2 * n); float nval = n.norm(); n /= nval; c /= nval; } bool Collision::rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect, const AATriangle& triangle) { if(!rectangle_rectangle(hit, rect, (const Rectangle&) triangle)) return false; Vector normal; float c; Vector p1; switch(triangle.dir) { case AATriangle::SOUTHWEST: p1 = Vector(rect.p1.x, rect.p2.y); makePlane(triangle.p1, triangle.p2, normal, c); break; case AATriangle::NORTHEAST: p1 = Vector(rect.p2.x, rect.p1.y); makePlane(triangle.p2, triangle.p1, normal, c); break; case AATriangle::SOUTHEAST: p1 = rect.p2; makePlane(Vector(triangle.p1.x, triangle.p2.y), Vector(triangle.p2.x, triangle.p1.y), normal, c); break; case AATriangle::NORTHWEST: p1 = rect.p1; makePlane(Vector(triangle.p2.x, triangle.p1.y), Vector(triangle.p1.x, triangle.p2.y), normal, c); break; } float depth = -(normal * p1) - c; if(depth < 0) return false; if(depth < hit.depth) { hit.depth = depth; hit.normal = normal; } return true; } } Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- sprite.h 19 Oct 2004 17:48:22 -0000 1.16 +++ sprite.h 20 Nov 2004 22:14:36 -0000 1.17 @@ -27,115 +27,83 @@ #include "../utils/lispreader.h" #include "../video/surface.h" #include "../math/vector.h" +#include "sprite_data.h" namespace SuperTux - { - +{ class Sprite - { - private: - - struct Action - { - std::string name; - - /** Position correction */ - int x_offset; - int y_offset; - /** Drawing priority in queue */ - int z_order; - - /** Frames per second */ - float fps; - - /** Mirror is used to avoid duplicating left and right side - sprites */ -// bool mirror; - - std::vector<Surface*> surfaces; - }; - - public: - /** cur has to be a pointer to data in the form of ((x-offset 5) - (y-offset 10) ...) */ - Sprite(lisp_object_t* cur); - ~Sprite(); - - /** Draw sprite, automatically calculates next frame */ - void draw(DrawingContext& context, const Vector& pos, int layer, - Uint32 drawing_effect = NONE_EFFECT); - - void draw_part(DrawingContext& context, const Vector& source, - const Vector& size, const Vector& pos, int layer, - Uint32 drawing_effect = NONE_EFFECT); - - /** Set action (or state) */ - void set_action(std::string act); - - /* Start an animation - -1 - for infinite - 0 - stopped - 1,2,3 - one, two, three times... */ - void start_animation(int loops); - /* Stop animation */ - void stop_animation() - { start_animation(0); } - /** Check if animation is stopped or not */ - bool check_animation(); - /** Reverse the animation */ - void reverse_animation(bool reverse); + { + public: + Sprite(SpriteData& data); + Sprite(const Sprite& other); + ~Sprite(); + + /** Draw sprite, automatically calculates next frame */ + void draw(DrawingContext& context, const Vector& pos, int layer, + Uint32 drawing_effect = NONE_EFFECT); - float get_fps() - { return action->fps; } - /** Get current action total frames */ - int get_frames() - { return action->surfaces.size(); } - /** Get sprite's name */ - std::string get_name() const - { return name; } - /** Get current action name */ - std::string get_action_name() const - { return action->name; } - int get_width(); - int get_height(); + void draw_part(DrawingContext& context, const Vector& source, + const Vector& size, const Vector& pos, int layer, + Uint32 drawing_effect = NONE_EFFECT); - /** Get current frame */ - int get_frame() - { return (int)frame; } - /** Set current frame */ - void set_frame(int frame_) - { if(frame_ > get_frames()) frame = 0; else frame = frame_; } - Surface* get_frame(unsigned int frame) - { - if(frame < action->surfaces.size()) - return action->surfaces[frame]; - else - return action->surfaces[0]; - } - private: - void init_defaults(Action* act); - void parse_action(LispReader& lispreader); + /** Set action (or state) */ + void set_action(std::string act); - /** Get an action */ - Action* get_action(std::string act); + /* Start an animation + -1 - for infinite + 0 - stopped + 1,2,3 - one, two, three times... */ + void start_animation(int loops); + /* Stop animation */ + void stop_animation() + { start_animation(0); } + /** Check if animation is stopped or not */ + bool check_animation(); + /** Reverse the animation */ + void reverse_animation(bool reverse); - void update(); - void reset(); + float get_fps() const + { return action->fps; } + /** Get current action total frames */ + int get_frames() const + { return action->surfaces.size(); } + /** Get sprite's name */ + const std::string& get_name() const + { return data.name; } + /** Get current action name */ + const std::string& get_action_name() const + { return action->name; } - std::string name; + int get_width() const; + int get_height() const; - float frame; - int animation_loops; - bool animation_reversed; - float last_tick; + /** Get current frame */ + int get_frame() const + { return (int)frame; } + /** Set current frame */ + void set_frame(int frame_) + { if(frame_ > get_frames()) frame = 0; else frame = frame_; } + Surface* get_frame(unsigned int frame) + { + if(frame < action->surfaces.size()) + return action->surfaces[frame]; + else + return action->surfaces[0]; + } + private: + void update(); + void reset(); - typedef std::map <std::string, Action*> Actions; - Actions actions; + SpriteData& data; - Action* action; - std::string next_action; - }; + float frame; + int animation_loops; + bool animation_reversed; + float last_tick; + SpriteData::Action* action; + std::string next_action; + }; } //namespace SuperTux #endif /*SUPERTUX_SPRITE_H*/ --- NEW FILE: collision_hit.h --- // $Id: collision_hit.h,v 1.1 2004/11/20 22:14:36 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 SUPERTUX_COLLISION_HIT_H #define SUPERTUX_COLLISION_HIT_H #include "math/vector.h" namespace SuperTux { /** * Used as return value for the collision functions, to indicate how the * collision should be handled */ enum HitResponse { ABORT_MOVE, // don't move the object FORCE_MOVE, // do the move ignoring the collision CONTINUE // move object out of collision and check for collisions again // if this happens to often then the move will just be aborted }; /** * This class collects data about a collision */ class CollisionHit { public: /// penetration depth float depth; // The normal of the side we collided with Vector normal; }; } #endif Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/timer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- timer.cpp 27 Jul 2004 13:25:05 -0000 1.4 +++ timer.cpp 20 Nov 2004 22:14:36 -0000 1.5 @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include <config.h> + #include "SDL.h" #include "../special/timer.h" Index: game_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/game_object.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- game_object.h 24 Sep 2004 21:33:59 -0000 1.3 +++ game_object.h 20 Nov 2004 22:14:36 -0000 1.4 @@ -1,7 +1,7 @@ // $Id$ // // SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun <ma...@br... +// Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -46,8 +46,9 @@ virtual ~GameObject(); /** This function is called once per frame and allows the object to update - * it's state. The elapsed_time is the time since the last frame and should be - * the base for all timed things. + * it's state. The elapsed_time is the time since the last frame in + * seconds and should be the base for all timed calculations (don't use + * SDL_GetTicks directly as this will fail in pause mode) */ virtual void action(float elapsed_time) = 0; @@ -67,11 +68,27 @@ wants_to_die = true; } + // flags + enum { + /// the tile so you can stand on it + FLAG_SOLID = 0x0001, + /// can be used to temporatily disable collision detection + FLAG_NO_COLLDET = 0x0002 + }; + + int get_flags() const + { + return flags; + } + private: /** this flag indicates if the object should be removed at the end of the * frame */ bool wants_to_die; + + protected: + int flags; }; } Index: sprite_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- sprite_manager.h 22 Jul 2004 19:07:50 -0000 1.3 +++ sprite_manager.h 20 Nov 2004 22:14:36 -0000 1.4 @@ -25,24 +25,23 @@ #include "../special/sprite.h" namespace SuperTux - { +{ class SpriteManager - { - private: - typedef std::map<std::string, Sprite*> Sprites; - Sprites sprites; - public: - SpriteManager(const std::string& filename); - ~SpriteManager(); - - void load_resfile(const std::string& filename); - /** loads a sprite. - * WARNING: You must not delete the returned object. - */ - Sprite* load(const std::string& name); - }; + { + private: + typedef std::map<std::string, SpriteData*> Sprites; + Sprites sprites; + public: + SpriteManager(const std::string& filename); + ~SpriteManager(); + void load_resfile(const std::string& filename); + /** loads a sprite. + * (contrary to the old api you have to delete the sprite!) + */ + Sprite* create(const std::string& name); + }; } //namespace SuperTux #endif /*SUPERTUX_SPRITE_MANAGER_H*/ |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:16
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/utils Modified Files: configfile.cpp lispreader.cpp lispreader.h lispwriter.cpp Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: lispwriter.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lispwriter.cpp 22 Jul 2004 19:07:51 -0000 1.3 +++ lispwriter.cpp 20 Nov 2004 22:14:36 -0000 1.4 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <iostream> #include "../utils/lispwriter.h" Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- configfile.cpp 6 Aug 2004 11:43:08 -0000 1.7 +++ configfile.cpp 20 Nov 2004 22:14:36 -0000 1.8 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <cstdlib> #include <string> Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- lispreader.cpp 25 Jul 2004 19:03:35 -0000 1.4 +++ lispreader.cpp 20 Nov 2004 22:14:36 -0000 1.5 @@ -20,8 +20,11 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include <config.h> + #include <iostream> #include <vector> +#include <stdexcept> #include <string> #include <cctype> #include <cstdlib> @@ -68,7 +71,7 @@ _token_append (char c) { if (token_length >= MAX_TOKEN_LENGTH) - throw LispReaderException("_token_append()", __FILE__, __LINE__); + throw std::runtime_error("token too long."); token_string[token_length++] = c; token_string[token_length] = '\0'; @@ -98,7 +101,7 @@ return stream->v.any.next_char(stream->v.any.data); } - throw LispReaderException("_next_char()", __FILE__, __LINE__); + assert(false); return EOF; } @@ -120,7 +123,7 @@ break; default : - throw LispReaderException("_unget_char()", __FILE__, __LINE__); + assert(false); } } @@ -272,7 +275,7 @@ } } - throw LispReaderException("_scan()", __FILE__, __LINE__); + throw std::runtime_error("invalid token in lisp file"); return TOKEN_ERROR; } @@ -311,7 +314,7 @@ void (*unget_char) (char c, void *data)) { if (next_char == 0 || unget_char == 0) - throw LispReaderException("lisp_stream_init_any()", __FILE__, __LINE__); + throw std::runtime_error("no data"); stream->type = LISP_STREAM_ANY; stream->v.any.data = data; @@ -499,7 +502,7 @@ return lisp_make_boolean(0); } - throw LispReaderException("lisp_read()", __FILE__, __LINE__); + throw std::runtime_error("syntax error in lisp file"); return &error_object; } @@ -663,7 +666,7 @@ _match_pattern_var (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars) { if (lisp_type(pattern) != LISP_TYPE_PATTERN_VAR) - throw LispReaderException("_match_pattern_var", __FILE__, __LINE__); + throw std::runtime_error("type is not a var"); switch (pattern->v.pattern.type) { @@ -708,7 +711,7 @@ for (sub = pattern->v.pattern.sub; sub != 0; sub = lisp_cdr(sub)) { if (lisp_type(sub) != LISP_TYPE_CONS) - throw LispReaderException("_match_pattern_var()", __FILE__, __LINE__); + throw std::runtime_error("type isn't a car/cons"); if (_match_pattern(lisp_car(sub), obj, vars)) matched = 1; @@ -720,7 +723,7 @@ break; default : - throw LispReaderException("_match_pattern_var()", __FILE__, __LINE__); + assert(false); } if (vars != 0) @@ -770,7 +773,7 @@ break; default : - throw LispReaderException("_match_pattern()", __FILE__, __LINE__); + assert(false); } return 0; @@ -826,7 +829,7 @@ SuperTux::lisp_integer (lisp_object_t *obj) { if (obj->type != LISP_TYPE_INTEGER) - throw LispReaderException("lisp_integer()", __FILE__, __LINE__); + throw std::runtime_error("expected integer"); return obj->v.integer; } @@ -835,7 +838,7 @@ SuperTux::lisp_symbol (lisp_object_t *obj) { if (obj->type != LISP_TYPE_SYMBOL) - throw LispReaderException("lisp_symbol()", __FILE__, __LINE__); + throw std::runtime_error("expected symbol"); return obj->v.string; } @@ -844,7 +847,7 @@ SuperTux::lisp_string (lisp_object_t *obj) { if (obj->type != LISP_TYPE_STRING) - throw LispReaderException("lisp_string()", __FILE__, __LINE__); + throw std::runtime_error("expected string"); return obj->v.string; } @@ -853,7 +856,7 @@ SuperTux::lisp_boolean (lisp_object_t *obj) { if (obj->type != LISP_TYPE_BOOLEAN) - throw LispReaderException("lisp_boolean()", __FILE__, __LINE__); + throw std::runtime_error("expected boolean"); return obj->v.integer; } @@ -862,7 +865,7 @@ SuperTux::lisp_real (lisp_object_t *obj) { if (obj->type != LISP_TYPE_REAL && obj->type != LISP_TYPE_INTEGER) - throw LispReaderException("lisp_real()", __FILE__, __LINE__); + throw std::runtime_error("expected real"); if (obj->type == LISP_TYPE_INTEGER) return obj->v.integer; @@ -873,7 +876,7 @@ SuperTux::lisp_car (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_car()", __FILE__, __LINE__); + throw std::runtime_error("expected car"); return obj->v.cons.car; } @@ -882,7 +885,7 @@ SuperTux::lisp_cdr (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_cdr()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); return obj->v.cons.cdr; } @@ -898,7 +901,7 @@ else if (x[i] == 'd') obj = lisp_cdr(obj); else - throw LispReaderException("lisp_cxr()", __FILE__, __LINE__); + throw std::runtime_error("couldn't parse cxr"); return obj; } @@ -911,7 +914,7 @@ while (obj != 0) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_list_length()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); ++length; obj = obj->v.cons.cdr; @@ -926,9 +929,9 @@ while (index > 0) { if (obj == 0) - throw LispReaderException("lisp_list_nth_cdr()", __FILE__, __LINE__); + throw std::runtime_error("list too short"); if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) - throw LispReaderException("lisp_list_nth_cdr()", __FILE__, __LINE__); + throw std::runtime_error("expected cons"); --index; obj = obj->v.cons.cdr; @@ -943,7 +946,7 @@ obj = lisp_list_nth_cdr(obj, index); if (obj == 0) - throw LispReaderException("lisp_list_nth()", __FILE__, __LINE__); + throw std::runtime_error("list too short"); return obj->v.cons.car; } @@ -1025,7 +1028,7 @@ break; default : - throw LispReaderException("lisp_dump()", __FILE__, __LINE__); + throw std::runtime_error("unknown list type"); } } @@ -1049,13 +1052,12 @@ if(obj->type == LISP_TYPE_EOF || obj->type == LISP_TYPE_PARSE_ERROR) { lisp_free(obj); - throw LispReaderException("LispReader::load", __FILE__, __LINE__); + throw std::runtime_error("Error while parsing lispfile"); } if(toplevellist != lisp_symbol(lisp_car(obj))) { lisp_car(obj); - throw LispReaderException("LispReader::load wrong toplevel symbol", - __FILE__, __LINE__); + throw std::runtime_error("Worng toplevel symbol in lisp file"); } LispReader* reader = new LispReader(lisp_cdr(obj)); @@ -1077,7 +1079,6 @@ if (!lisp_cons_p(cur) || !lisp_symbol_p (lisp_car(cur))) { lisp_dump(cur, stdout); - //throw ConstruoError (std::string("LispReader: Read error in search_for ") + name); printf("LispReader: Read error in search\n"); } else @@ -1108,6 +1109,20 @@ } bool +LispReader::read_uint (const char* name, unsigned int& i) +{ + lisp_object_t* obj = search_for (name); + if(!obj) + return false; + + if (!lisp_integer_p(lisp_car(obj))) + return false; + + i = (unsigned int) lisp_integer(lisp_car(obj)); + return true; +} + +bool LispReader::read_lisp(const char* name, lisp_object_t*& b) { lisp_object_t* obj = search_for (name); @@ -1291,5 +1306,3 @@ return obj; } - -// EOF // Index: lispreader.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lispreader.h 22 Jul 2004 19:07:51 -0000 1.3 +++ lispreader.h 20 Nov 2004 22:14:36 -0000 1.4 @@ -61,14 +61,6 @@ #define LISP_PATTERN_LIST 7 #define LISP_PATTERN_OR 8 -// Exception -class LispReaderException : public SuperTuxException -{ - public: - LispReaderException(const char* _message = "lispreader error", const char* _file = "", const unsigned int _line = 0) - : SuperTuxException(_message, _file, _line) { }; -}; - typedef struct { int type; @@ -191,6 +183,7 @@ bool read_string_vector(const char* name, std::vector<std::string>& vec); bool read_string(const char* name, std::string& str, bool translatable = false); bool read_int(const char* name, int& i); + bool read_uint(const char* name, unsigned int& i); bool read_float(const char* name, float& f); bool read_bool(const char* name, bool& b); bool read_lisp(const char* name, lisp_object_t*& b); |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:15
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/math Modified Files: physic.cpp physic.h vector.cpp vector.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: vector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/vector.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- vector.cpp 22 Jul 2004 19:07:50 -0000 1.3 +++ vector.cpp 20 Nov 2004 22:14:35 -0000 1.4 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <cmath> #include "../math/vector.h" Index: vector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/vector.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- vector.h 6 Oct 2004 21:36:51 -0000 1.6 +++ vector.h 20 Nov 2004 22:14:35 -0000 1.7 @@ -1,7 +1,7 @@ // $Id$ // // SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun <ma...@br... +// Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -20,8 +20,6 @@ #ifndef SUPERTUX_VECTOR_H #define SUPERTUX_VECTOR_H -#include "../special/base.h" - namespace SuperTux { @@ -36,9 +34,6 @@ Vector(const Vector& other) : x(other.x), y(other.y) { } - Vector(const base_type& base) - : x(base.x), y(base.y) - { } Vector() : x(0), y(0) { } @@ -92,6 +87,20 @@ return *this; } + const Vector& operator *=(float val) + { + x *= val; + y *= val; + return *this; + } + + const Vector& operator /=(float val) + { + x /= val; + y /= val; + return *this; + } + /// Scalar product of 2 vectors float operator*(const Vector& other) const { Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- physic.cpp 22 Jul 2004 19:07:50 -0000 1.4 +++ physic.cpp 20 Nov 2004 22:14:35 -0000 1.5 @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include <config.h> + #include <cstdio> #include "../math/physic.h" @@ -119,24 +121,18 @@ gravity_enabled = enable_gravity; } -void -Physic::apply(float elapsed_time, float &x, float &y, float gravity) +Vector +Physic::get_movement(float elapsed_time) { - float grav; - if(gravity_enabled) - grav = gravity / 100.0; - else - grav = 0; - - x += vx * elapsed_time + ax * elapsed_time * elapsed_time; - y += vy * elapsed_time + (ay + grav) * elapsed_time * elapsed_time; + float grav = gravity_enabled ? 1000 : 0; + + Vector result( + vx * elapsed_time + ax * elapsed_time * elapsed_time, + vy * elapsed_time + (ay + grav) * elapsed_time * elapsed_time + ); vx += ax * elapsed_time; - vy += (ay + grav) * elapsed_time; -} + vy += (ay + grav) * elapsed_time; -void -Physic::apply(Vector& vector, float elapsed_time, float gravity) -{ - apply(elapsed_time, vector.x, vector.y, gravity); + return result; } Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- physic.h 22 Jul 2004 19:07:50 -0000 1.5 +++ physic.h 20 Nov 2004 22:14:35 -0000 1.6 @@ -21,7 +21,7 @@ #ifndef SUPERTUX_PHYSIC_H #define SUPERTUX_PHYSIC_H -#include "../math/vector.h" +#include "math/vector.h" namespace SuperTux { @@ -67,11 +67,7 @@ /// Enables or disables handling of gravity. void enable_gravity(bool gravity_enabled); - /// Applies the physical simulation to given x and y coordinates. - void apply(float frame_ratio, float &x, float &y, float gravity = 10.0f); - - /// applies the physical simulation to given x and y coordinates. - void apply(Vector& vector, float frame_ratio, float gravity = 10.0f); + Vector get_movement(float elapsed_time); private: /// horizontal and vertical acceleration |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:15
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/gui Modified Files: button.cpp mousecursor.cpp Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: mousecursor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/mousecursor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mousecursor.cpp 22 Jul 2004 19:07:50 -0000 1.3 +++ mousecursor.cpp 20 Nov 2004 22:14:35 -0000 1.4 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include "../video/drawing_context.h" #include "../gui/mousecursor.h" Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- button.cpp 24 Sep 2004 15:08:04 -0000 1.7 +++ button.cpp 20 Nov 2004 22:14:35 -0000 1.8 @@ -15,6 +15,8 @@ * * ***************************************************************************/ +#include <config.h> + #include "SDL.h" #include <iostream> |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:14
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/app Modified Files: globals.cpp globals.h setup.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- globals.cpp 16 Nov 2004 20:37:30 -0000 1.9 +++ globals.cpp 20 Nov 2004 22:14:20 -0000 1.10 @@ -20,7 +20,8 @@ #include <config.h> -#include "../app/globals.h" +#include "app/globals.h" +#include "special/timer.h" namespace SuperTux { Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/setup.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- setup.h 16 Nov 2004 20:37:30 -0000 1.9 +++ setup.h 20 Nov 2004 22:14:20 -0000 1.10 @@ -23,7 +23,6 @@ #include <vector> #include <set> #include <string> -#include "../gui/menu.h" namespace SuperTux { Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/globals.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- globals.h 6 Aug 2004 11:43:08 -0000 1.8 +++ globals.h 20 Nov 2004 22:14:20 -0000 1.9 @@ -27,12 +27,12 @@ #include "SDL.h" #include "../video/font.h" -#include "../gui/menu.h" -#include "../gui/mousecursor.h" namespace SuperTux { + class MouseCursor; + extern std::string datadir; extern std::string package_symbol_name; extern std::string package_name; |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:14
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib/audio Modified Files: musicref.cpp sound_manager.cpp sound_manager.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: sound_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- sound_manager.cpp 25 Jul 2004 19:03:34 -0000 1.4 +++ sound_manager.cpp 20 Nov 2004 22:14:35 -0000 1.5 @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include <cmath> #include <cassert> Index: sound_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sound_manager.h 25 Jul 2004 19:03:34 -0000 1.6 +++ sound_manager.h 20 Nov 2004 22:14:35 -0000 1.7 @@ -47,7 +47,6 @@ class SoundManager { public: - /// Play sound. void play_sound(Mix_Chunk* sound); /// Play sound relative to two Vectors. @@ -161,7 +160,6 @@ bool m_music_enabled; bool m_sound_enabled; bool audio_device; /* != 0: available and initialized */ - }; Mix_Chunk* IDToSound(int id); Index: musicref.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/musicref.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- musicref.cpp 22 Jul 2004 19:07:49 -0000 1.3 +++ musicref.cpp 20 Nov 2004 22:14:35 -0000 1.4 @@ -18,6 +18,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include <config.h> + #include "../audio/musicref.h" using namespace SuperTux; |
From: Matze B. <mat...@us...> - 2004-11-20 22:15:00
|
Update of /cvsroot/super-tux/supertux/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/lib Modified Files: .cvsignore Makefile.am Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: .cvsignore =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- .cvsignore 7 Nov 2004 23:04:27 -0000 1.1 +++ .cvsignore 20 Nov 2004 22:14:20 -0000 1.2 @@ -4,4 +4,4 @@ Makefile.in *.lo *.la - +.sconsign Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 28 Jul 2004 23:06:11 -0000 1.6 +++ Makefile.am 20 Nov 2004 22:14:20 -0000 1.7 @@ -13,9 +13,16 @@ special/game_object.cpp \ special/moving_object.cpp \ special/sprite.cpp \ + special/sprite.h \ + special/sprite_data.cpp \ + special/sprite_data.h \ special/sprite_manager.cpp \ + special/sprite_manager.h \ special/timer.cpp \ special/frame_rate.cpp \ + special/collision.h \ + special/collision_hit.h \ + special/collision.cpp \ utils/configfile.cpp \ utils/lispreader.cpp \ utils/lispwriter.cpp \ @@ -41,8 +48,7 @@ gui/mousecursor.h libsupertuxmath_HEADERS =math/physic.h \ math/vector.h -libsupertuxspecial_HEADERS =special/base.h \ - special/game_object.h \ +libsupertuxspecial_HEADERS = special/game_object.h \ special/moving_object.h \ special/sprite.h \ special/sprite_manager.h \ |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:59
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/data/levels/test Modified Files: level7.stl Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: level7.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level7.stl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- level7.stl 22 Jun 2004 12:35:23 -0000 1.6 +++ level7.stl 20 Nov 2004 22:14:19 -0000 1.7 @@ -1,7 +1,7 @@ ;SuperTux level made using the built-in leveleditor (supertux-level (version 1) - (name "Fire Test") + (name "Slope/Platform Test") (author "Ingo Ruhnke") (music "Mortimers_chipdisko.mod") (background "") @@ -77,5 +77,6 @@ (fish (x 1726) (y 243) (stay-on-platform #f)) (spiky (x 1398) (y 315) (stay-on-platform #f)) (flyingsnowball (x 1490) (y 267) (stay-on-platform #f)) + (platform (x 50) (y 100)) ) ) |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:59
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/data/images/tilesets Modified Files: supertux.stgt Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- supertux.stgt 25 Oct 2004 19:45:14 -0000 1.51 +++ supertux.stgt 20 Nov 2004 22:14:19 -0000 1.52 @@ -23,7 +23,7 @@ (tilegroup (name "Waterfall") (tiles 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294)) (tilegroup (name "Waterfall-edgecloud") (tile 195 196 197 198 199)) (tile (id 0) - (images "notile.png")) + (editor-images "bonus-fireflower.png")) (tile (id 1) (solid #t) @@ -991,15 +991,18 @@ (tile (id 360) (images "mushrooms.png")) + (tile (id 359) + (unisolid #t) + (images "snow11.png")) ; Slopes - (tile (id 400) - (slope-angle 45) - (images "slope-right.png")) (tile (id 401) - (slope-angle 135) + (slope-type 0) (images "slope-left.png")) + (tile (id 400) + (slope-type 2) + (images "slope-right.png")) ) |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:59
|
Update of /cvsroot/super-tux/supertux/data/levels/world1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/data/levels/world1 Modified Files: level4.stl Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: level4.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/world1/level4.stl,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- level4.stl 16 Sep 2004 18:59:05 -0000 1.22 +++ level4.stl 20 Nov 2004 22:14:19 -0000 1.23 @@ -93,10 +93,10 @@ (point (x 4718) (y 336)) ) (objects - (money (x 6752) (y 32)) - (money (x 6528) (y 192)) - (money (x 288) (y 224)) - (money (x 608) (y 224)) + (jumpy (x 6752) (y 32)) + (jumpy (x 6528) (y 192)) + (jumpy (x 288) (y 224)) + (jumpy (x 608) (y 224)) (snowball (x 1376) (y 256)) (snowball (x 1504) (y 256)) (snowball (x 3040) (y 288)) |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:58
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941 Modified Files: .cvsignore TODO configure.ac Removed Files: config.h.in ltmain.sh Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: .cvsignore =================================================================== RCS file: /cvsroot/super-tux/supertux/.cvsignore,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- .cvsignore 16 Nov 2004 11:55:15 -0000 1.6 +++ .cvsignore 20 Nov 2004 22:14:18 -0000 1.7 @@ -18,3 +18,6 @@ .project .cdtproject .sconsign +build_config.py +build + Index: TODO =================================================================== RCS file: /cvsroot/super-tux/supertux/TODO,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- TODO 20 Nov 2004 02:08:33 -0000 1.78 +++ TODO 20 Nov 2004 22:14:18 -0000 1.79 @@ -37,7 +37,76 @@ g++ -Wall .... -o build/linux/src/error.o src/error.cpp +--Collision Detection Rewrite (all [H])-- + * make blocks bounce again - ok + * bonusblocks don't always bounce back to their original position (but stay a + few pixels higher) + * it's impossible to go into passages that have exactly the size of tux, + either reduce collision rectangle by DELTA or round collision coordinates to + integers... + ** implement 1up - ok + ** implement star - ok + * bring back the enemies + - add activation again + - make api simpler + - implement jumpy - ok + -* implement spiky - ok + - implement snowball - ok + - implement fish + - implement bouncingsnowball - ok + -* implement mriceblock - ~ok + - implement flame - ok + -* implement mrbomb - ok + - implement flyingsnowball + - implement wingling + - implement tree (really?) + - bring back stay on platform flag + - make enemies bounce of upon each other again + - make enemies fall again + -* activate/deactive enemies when on screen/away again - ok + ** implement ability to cary mriceblock (and other objects) around - delayed + for after big commit... + * smoke clouds are too fast + * some shots disappear in the ground with a "max collision depth reached" + message + * rework collision detection to take movement into account - this should fix + the egg suddenly turning directions and the somtimes strange behaviour + when hitting a block from the side when falling. + * rethink slopes collision feedback... tux becomes too slow when walking up + and starts jumping when walking down + * think about an attachement mechanism for moving platforms + * implement paths for the moving platform, implement simple moving platforms + ** activate level end sequence again - ok + ** make bullets kill enemies - ok + * fix bullet speed/behaviour + ** fix ducking - ok + * check if unducking is actually possible or if something is in the way + * fix flapping + ** having a star doesn't kill enemies - ok + +--Code Refactoring/Cleanup/Optimisation-- +[H] make the title using GameSession instead of reimplementing all the stuff +[L] rename gameloop.* files to gamesession.* +[L] rename GameObject::action to GameObject::update() +[L] use physfs for loading files +[L] eventually move over new lispreader code from tuxkart +[L] change physics class y-velocity-coordinate to be like all other + y-coordinates again (positive y to go down) +[M] harmonize to 1 single gameloop that switches between title, worldmap, + ingame mode and eventually leveleditor mode +[H] introduce a special mode in DrawingContext for objects that want to draw + themselfes. This could speed up rendering of tilemaps. +[H] implement quadtree to speed up collision detection +[?] remove badguyspecs and bitmask files + --Miscelaneous-- +[?] think about how to implement scripting, and how to make a simple and easy to + use api for the scripting interface + (language will probably be lua - just have to figure out how well we can do + without OO support in the scripting language. + Other candidates are python, ruby and less likely java, mono/.net, + surely no own invention, perl or 1 of these c-like scripting languages) + [?] Default keyboard setup should change. Up will be needed for other features like going through doors and looking up, etc. Up arrow - Look up / activate Index: configure.ac =================================================================== RCS file: /cvsroot/super-tux/supertux/configure.ac,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- configure.ac 21 Sep 2004 11:13:09 -0000 1.35 +++ configure.ac 20 Nov 2004 22:14:18 -0000 1.36 @@ -18,7 +18,10 @@ AM_INIT_AUTOMAKE dnl This is obsolete see automake1.7 // AM_CONFIG_HEADER -SDL_VERSION=1.2.4 +# we don't want the stupid autoconf default -g -O2 +test ".$CXXFLAGS" = "." && CXXFLAGS=" " + +CXXFLAGS="$CXXFLAGS -ffast-math" AC_PROG_CC AC_PROG_CXX @@ -40,7 +43,7 @@ AC_ARG_ENABLE(gprof, AC_HELP_STRING([--enable-gprof], [enable GNU profiling support]), [enable_gprof=$enableval], [enable_gprof=no]) -if test "$enable_gprof" = "no"; then +if test "$enable_gprof" = "yes"; then CXXFLAGS="$CXXFLAGS -pg" AC_MSG_RESULT([enabled]) else @@ -52,9 +55,11 @@ AC_HELP_STRING([--enable-debug], [enable debugging mode]), [enable_debug=$enableval], [enable_debug=no]) if test "$enable_debug" = "yes"; then - CXXFLAGS="$CXXFLAGS -Wall -Werror -DDEBUG -O0 -g3" + AC_DEFINE([DEBUG], 1, [define to compile in debug checks]) + CXXFLAGS="$CXXFLAGS -Wall -Werror -O0 -g3" AC_MSG_RESULT([enabled]) else + CXXFLAGS="$CXXFLAGS -O2 -g" AC_MSG_RESULT([disabled]) fi @@ -72,6 +77,7 @@ dnl =========================================================================== dnl Check for SDL +SDL_VERSION=1.2.4 AM_PATH_SDL($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])) --- config.h.in DELETED --- --- ltmain.sh DELETED --- |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:58
|
Update of /cvsroot/super-tux/supertux/data/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/data/images Modified Files: supertux.strf Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects Index: supertux.strf =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/supertux.strf,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- supertux.strf 27 Oct 2004 08:23:16 -0000 1.21 +++ supertux.strf 20 Nov 2004 22:14:18 -0000 1.22 @@ -783,9 +783,9 @@ ;; Bad Guys follow - ;; Laptop + ;; MrIceBlock (sprite (name "mriceblock") - (action + (action (name "left") (x-offset 2) (y-offset 3) @@ -794,27 +794,27 @@ "shared/mriceblock-left-2.png" "shared/mriceblock-left-1.png")) - (action (name "right") + (action (name "right") (x-offset 2) (y-offset 3) (mirror-action "left")) - (action (name "falling-left") + (action (name "falling-left") (x-offset 2) (y-offset 3) (images "shared/mriceblock-flat-left.png")) - (action (name "falling-right") + (action (name "falling-right") (x-offset 2) (y-offset 3) (mirror-action "falling-left")) - (action (name "flat-left") + (action (name "flat-left") (x-offset 2) (y-offset 3) (images "shared/mriceblock-flat-left.png")) - (action (name "flat-right") + (action (name "flat-right") (x-offset 2) (y-offset 3) (mirror-action "falling-left"))) @@ -1162,10 +1162,79 @@ ; Door (sprite (name "door") (action + (name "default") (x-offset 0) (y-offset 64) - (images "shared/door-1.png") - )) + (images "shared/door-1.png")) + (action + (name "open") + (x-offset 0) + (y-offset 64) + (images "shared/door-1.png" + "shared/door-2.png" + "shared/door-3.png" + "shared/door-4.png" + "shared/door-5.png" + "shared/door-6.png" + "shared/door-7.png" + "shared/door-8.png" + "shared/door-7.png" + "shared/door-6.png" + "shared/door-5.png" + "shared/door-4.png" + "shared/door-3.png" + "shared/door-2.png" + "shared/door-1.png")) + ) + + ; coin + (sprite (name "coin") + (action + (name "default") + (images "tilesets/coin-1.png" + "tilesets/coin-2.png" + "tilesets/coin-3.png" + "tilesets/coin-4.png" + "tilesets/coin-5.png" + "tilesets/coin-6.png" + "tilesets/coin-7.png" + "tilesets/coin-8.png")) + (action + (name "still") + (images "tilesets/coin-1.png")) + ) + + (sprite (name "bonusblock") + (action + (name "default") + (images "tilesets/bonus2-1.png" + "tilesets/bonus2-2.png" + "tilesets/bonus2-3.png" + "tilesets/bonus2-4.png" + "tilesets/bonus2-5.png")) + (action + (name "empty") + (images "tilesets/bonus2-d.png")) + ) + + (sprite (name "brick") + (action + (name "empty") + (images "tilesets/bonus2-d.png")) + (action + (name "default") + (images "tilesets/brick0.png")) + ) + + (sprite (name "icedbrick") + (action + (name "empty") + (images "tilesets/bonus2-d.png")) + (action + (name "default") + (images "tilesets/brick1.png")) + ) + ; (sprite (name "openingdoor") ; (action ; (x-offset 0) |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:51
|
Update of /cvsroot/super-tux/supertux/src/trigger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/src/trigger Added Files: door.cpp door.h sequence_trigger.cpp sequence_trigger.h trigger_base.cpp trigger_base.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects --- NEW FILE: door.h --- // $Id: door.h,v 1.1 2004/11/20 22:14:40 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 SUPERTUX_DOOR_H #define SUPERTUX_DOOR_H #include <string> #include "video/surface.h" #include "special/sprite.h" #include "trigger_base.h" #include "serializable.h" #include "timer.h" class Door : public TriggerBase, public Serializable { public: Door(LispReader& reader); Door(int x, int y); virtual ~Door(); virtual void write(LispWriter& writer); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); virtual void event(Player& player, EventType type); private: std::string target_sector; std::string target_spawnpoint; Sprite* sprite; }; #endif --- NEW FILE: trigger_base.cpp --- // $Id: trigger_base.cpp,v 1.1 2004/11/20 22:14:40 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 <config.h> #include "trigger_base.h" #include "player.h" #include "video/drawing_context.h" TriggerBase::TriggerBase() : sprite(0) { } TriggerBase::~TriggerBase() { } void TriggerBase::action(float ) { lasthit = hit; hit = false; } void TriggerBase::draw(DrawingContext& context) { if(!sprite) return; sprite->draw(context, get_pos(), LAYER_TILES+1); } HitResponse TriggerBase::collision(GameObject& other, const CollisionHit& collhit) { Player* player = dynamic_cast<Player*> (&other); if(player) { hit = true; if(!lasthit) event(*player, EVENT_TOUCH); } return ABORT_MOVE; } --- NEW FILE: trigger_base.h --- // $Id: trigger_base.h,v 1.1 2004/11/20 22:14:40 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 SUPERTUX_TRIGGER_BASE_H #define SUPERTUX_TRIGGER_BASE_H #include "special/moving_object.h" #include "math/rectangle.h" #include "special/sprite.h" class Player; using namespace SuperTux; /** This class is the base class for all objects you can interact with in some * way. There are several interaction types defined like touch and activate */ class TriggerBase : public MovingObject { public: enum EventType { EVENT_TOUCH, EVENT_ACTIVATE }; TriggerBase(); ~TriggerBase(); void action(float elapsed_time); void draw(DrawingContext& context); HitResponse collision(GameObject& other, const CollisionHit& hit); /** * Receive trigger events */ virtual void event(Player& player, EventType type) = 0; private: Sprite* sprite; bool lasthit; bool hit; }; #endif /*SUPERTUX_INTERACTIVE_OBJECT_H*/ --- NEW FILE: door.cpp --- // $Id: door.cpp,v 1.1 2004/11/20 22:14:40 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 <config.h> #include "door.h" #include "utils/lispreader.h" #include "utils/lispwriter.h" #include "gameloop.h" #include "resources.h" #include "special/sprite.h" #include "special/sprite_manager.h" #include "video/drawing_context.h" #include "app/globals.h" using namespace SuperTux; Door::Door(LispReader& reader) { reader.read_float("x", bbox.p1.x); reader.read_float("y", bbox.p1.y); bbox.set_size(32, 64); reader.read_string("sector", target_sector); reader.read_string("spawnpoint", target_spawnpoint); sprite = sprite_manager->create("door"); } Door::Door(int x, int y) { bbox.set_pos(Vector(x, y)); bbox.set_size(32, 64); sprite = sprite_manager->create("door"); } Door::~Door() { delete sprite; } void Door::write(LispWriter& writer) { writer.start_list("door"); writer.write_float("x", bbox.p1.x); writer.write_float("y", bbox.p1.y); writer.write_float("width", bbox.get_width()); writer.write_float("height", bbox.get_height()); writer.write_string("sector", target_sector); writer.write_string("spawnpoint", target_spawnpoint); writer.end_list("door"); } void Door::action(float ) { //Check if door animation is complete if (!sprite->check_animation()) { GameSession::current()->respawn(target_sector, target_spawnpoint); } } void Door::draw(DrawingContext& context) { sprite->draw(context, bbox.p1, LAYER_TILES); } void Door::event(Player& player, EventType type) { if(type == EVENT_ACTIVATE) { sprite->set_action("open"); sprite->start_animation(1); } } --- NEW FILE: sequence_trigger.h --- #ifndef __SEQUENCE_TRIGGER_H__ #define __SEQUENCE_TRIGGER_H__ #include "trigger_base.h" #include "serializable.h" class SequenceTrigger : public TriggerBase, public Serializable { public: SequenceTrigger(LispReader& reader, const std::string& sequence); SequenceTrigger(const Vector& pos, const std::string& sequence); ~SequenceTrigger(); void write(LispWriter& writer); void event(Player& player, EventType type); private: EventType triggerevent; std::string sequence_name; }; #endif --- NEW FILE: sequence_trigger.cpp --- #include <config.h> #include "sequence_trigger.h" #include "utils/lispwriter.h" #include "gameloop.h" SequenceTrigger::SequenceTrigger(LispReader& reader, const std::string& sequence) { // TODO } SequenceTrigger::SequenceTrigger(const Vector& pos, const std::string& sequence) { bbox.set_pos(pos); bbox.set_size(32, 32); sequence_name = sequence; triggerevent = EVENT_TOUCH; } SequenceTrigger::~SequenceTrigger() { } void SequenceTrigger::write(LispWriter& writer) { writer.start_list("sequencetrigger"); writer.write_float("x", bbox.p1.x); writer.write_float("y", bbox.p1.y); writer.write_float("width", bbox.get_width()); writer.write_float("height", bbox.get_height()); writer.write_string("sequence", sequence_name); writer.end_list("sequencetrigger"); } void SequenceTrigger::event(Player& player, EventType type) { if(type == triggerevent) { GameSession::current()->start_sequence(sequence_name); } } |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:50
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/src/object Added Files: block.cpp block.h bullet.cpp bullet.h coin.cpp coin.h fireworks.cpp fireworks.h flower.cpp flower.h growup.cpp growup.h oneup.cpp oneup.h platform.cpp platform.h specialriser.cpp specialriser.h star.cpp star.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects --- NEW FILE: platform.cpp --- #include <config.h> #include "platform.h" #include "video/drawing_context.h" #include "resources.h" #include "player.h" #include "special/sprite_manager.h" #include "utils/lispreader.h" Platform::Platform(LispReader& reader) { sprite = sprite_manager->create("flying_platform"); movement = Vector(0, 1); reader.read_float("x", bbox.p1.x); reader.read_float("y", bbox.p1.y); bbox.set_size(sprite->get_width(), sprite->get_height()); flags |= FLAG_SOLID; state = 0; } Platform::~Platform() { delete sprite; } HitResponse Platform::collision(GameObject& object, const CollisionHit& hit) { #if 0 if(typeid(object) == typeid(Player)) { Player* player = (Player*) &object; //player->movement += movement; } #endif return FORCE_MOVE; } void Platform::action(float elapsed_time) { // just some test code... if(state == 0) { movement = Vector(0, 1); if(bbox.p1.y > 250) state = 1; } if(state == 1) { movement = Vector(0, -1); if(bbox.p1.y < 50) state = 2; } if(state == 2) { movement = Vector(1, 0); if(bbox.p1.x > 800) state = 3; } if(state == 3) { movement = Vector(-1, 0); if(bbox.p1.x < 400) state = 4; } if(state == 4) { movement = Vector(-1, 1); if(bbox.p1.x < 0) state = 0; } } void Platform::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } --- NEW FILE: growup.cpp --- #include <config.h> #include <math.h> #include "growup.h" #include "defines.h" #include "resources.h" #include "camera.h" #include "sector.h" #include "player.h" #include "app/globals.h" #include "special/sprite_manager.h" GrowUp::GrowUp(const Vector& pos) { bbox.set_pos(pos); bbox.set_size(32, 32); sprite = sprite_manager->create("egg"); physic.enable_gravity(true); physic.set_velocity_x(100); } GrowUp::~GrowUp() { delete sprite; } void GrowUp::action(float elapsed_time) { movement = physic.get_movement(elapsed_time); } HitResponse GrowUp::collision(GameObject& other, const CollisionHit& hit) { if(other.get_flags() & FLAG_SOLID) { if(fabsf(hit.normal.y) > .5) { // roof physic.set_velocity_y(0); } else { // bumped left or right physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } Player* player = dynamic_cast<Player*>(&other); if(player != 0) { player->grow(); SoundManager::get()->play_sound(IDToSound(SND_EXCELLENT)); remove_me(); return ABORT_MOVE; } return FORCE_MOVE; } void GrowUp::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } --- NEW FILE: coin.cpp --- #include <config.h> #include "coin.h" #include "resources.h" #include "video/drawing_context.h" #include "special/sprite_manager.h" #include "player.h" #include "scene.h" Coin::Coin(const Vector& pos) { bbox.set_pos(pos); bbox.set_size(32, 32); sprite = sprite_manager->create("coin"); } Coin::~Coin() { delete sprite; } void Coin::action(float ) { } void Coin::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_TILES); } HitResponse Coin::collision(GameObject& other, const CollisionHit& hit) { Player* player = dynamic_cast<Player*>(&other); if(player == 0) return ABORT_MOVE; player->get_status().incCoins(); remove_me(); return ABORT_MOVE; } --- NEW FILE: flower.h --- #ifndef __FLOWER_H__ #define __FLOWER_H__ #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" using namespace SuperTux; class Flower : public MovingObject { public: enum Type { FIREFLOWER, ICEFLOWER }; Flower(const Vector& pos, Type type); ~Flower(); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); private: Type type; Sprite* sprite; }; #endif --- NEW FILE: star.h --- #ifndef __STAR_H__ #define __STAR_H__ #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" using namespace SuperTux; class Star : public MovingObject { public: Star(const Vector& pos); ~Star(); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); private: Sprite* sprite; Physic physic; }; #endif --- NEW FILE: specialriser.cpp --- #include <config.h> #include <math.h> #include "specialriser.h" #include "defines.h" #include "resources.h" #include "camera.h" #include "sector.h" #include "app/globals.h" #include "special/sprite_manager.h" SpecialRiser::SpecialRiser(MovingObject* _child) : child(_child) { offset = 0; } SpecialRiser::~SpecialRiser() { } void SpecialRiser::action(float elapsed_time) { offset += 50 * elapsed_time; if(offset > 32) { Sector::current()->add_object(child); remove_me(); } } void SpecialRiser::draw(DrawingContext& context) { context.push_transform(); context.set_translation( context.get_translation() + Vector(0, -32 + offset)); child->draw(context); context.pop_transform(); } --- NEW FILE: block.cpp --- #include <config.h> #include "block.h" #include "resources.h" #include "player.h" #include "sector.h" #include "special/sprite.h" #include "special/sprite_manager.h" #include "video/drawing_context.h" #include "gameobjs.h" #include "specialriser.h" #include "growup.h" #include "flower.h" #include "oneup.h" #include "star.h" static const float BOUNCY_BRICK_MAX_OFFSET=8; static const float BOUNCY_BRICK_SPEED=90; static const float EPSILON = .0001; Block::Block(const Vector& pos, Sprite* newsprite) : sprite(newsprite), bouncing(false), bounce_dir(0), bounce_offset(0) { bbox.set_pos(pos); bbox.set_size(32, 32); flags |= FLAG_SOLID; original_y = pos.y; } Block::~Block() { delete sprite; } HitResponse Block::collision(GameObject& other, const CollisionHit& hitdata) { if(bouncing) return FORCE_MOVE; // TODO kill badguys when bumping them... Player* player = dynamic_cast<Player*> (&other); if(!player) return ABORT_MOVE; // collided from below? if(hitdata.normal.x == 0 && hitdata.normal.y < 0 && player->get_movement().y < 0) { hit(player); } return ABORT_MOVE; } void Block::action(float elapsed_time) { if(!bouncing) return; float offset = original_y - get_pos().y; if(offset > BOUNCY_BRICK_MAX_OFFSET) { bounce_dir *= -1; movement = Vector(0, bounce_dir * elapsed_time); } else if(offset < -EPSILON) { movement = Vector(0, offset); bounce_dir = 0; bouncing = false; } else { movement = Vector(0, bounce_dir * elapsed_time); } } void Block::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS+1); } void Block::start_bounce() { bouncing = true; bounce_dir = -BOUNCY_BRICK_SPEED; bounce_offset = 0; } //--------------------------------------------------------------------------- BonusBlock::BonusBlock(const Vector& pos, int newdata) : Block(pos, sprite_manager->create("bonusblock")), data(newdata) { sprite->set_action("default"); } void BonusBlock::hit(Player* player) { if(sprite->get_action_name() == "empty") { SoundManager::get()->play_sound(IDToSound(SND_BRICK)); return; } Sector* sector = Sector::current(); switch(data) { case 1: // coin Sector::current()->add_object(new BouncyCoin(get_pos())); player->get_status().incCoins(); break; case 2: // grow/fireflower if(player->size == SMALL) { SpecialRiser* riser = new SpecialRiser( new GrowUp(get_pos() + Vector(0, -32))); sector->add_object(riser); } else { SpecialRiser* riser = new SpecialRiser( new Flower(get_pos() + Vector(0, -32), Flower::FIREFLOWER)); sector->add_object(riser); } SoundManager::get()->play_sound(IDToSound(SND_UPGRADE)); break; case 5: // grow/iceflower if(player->size == SMALL) { SpecialRiser* riser = new SpecialRiser( new GrowUp(get_pos() + Vector(0, -32))); sector->add_object(riser); } else { SpecialRiser* riser = new SpecialRiser( new Flower(get_pos() + Vector(0, -32), Flower::ICEFLOWER)); sector->add_object(riser); } SoundManager::get()->play_sound(IDToSound(SND_UPGRADE)); break; case 3: // star sector->add_object(new Star(get_pos())); break; case 4: // 1up sector->add_object(new OneUp(get_pos())); break; default: assert(false); } start_bounce(); sprite->set_action("empty"); } //--------------------------------------------------------------------------- Brick::Brick(const Vector& pos, int data) : Block(pos, sprite_manager->create("brick")), breakable(false), coin_counter(0) { if(data == 1) coin_counter = 5; else breakable = true; } void Brick::hit(Player* player) { if(sprite->get_action_name() == "empty") return; SoundManager::get()->play_sound(IDToSound(SND_BRICK)); Sector* sector = Sector::current(); if(coin_counter > 0) { sector->add_object(new BouncyCoin(get_pos())); coin_counter--; player->get_status().incCoins(); if(coin_counter == 0) sprite->set_action("empty"); start_bounce(); } else if(breakable) { if(player->size == SMALL) { start_bounce(); return; } sector->add_object( new BrokenBrick(new Sprite(*sprite), get_pos(), Vector(-100, -400))); sector->add_object( new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(0, 16), Vector(-150, -300))); sector->add_object( new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 0), Vector(100, -400))); sector->add_object( new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 16), Vector(150, -300))); remove_me(); } } --- NEW FILE: specialriser.h --- #ifndef __SPECIALRISE_H__ #define __SPECIALRISE_H__ #include "special/moving_object.h" using namespace SuperTux; /** * special object that contains another object and slowly rises it out of a * bonus block. */ class SpecialRiser : public GameObject { public: SpecialRiser(MovingObject* child); ~SpecialRiser(); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); private: float offset; MovingObject* child; }; #endif --- NEW FILE: flower.cpp --- #include <config.h> #include <math.h> #include "flower.h" #include "defines.h" #include "resources.h" #include "camera.h" #include "sector.h" #include "player.h" #include "app/globals.h" #include "special/sprite_manager.h" Flower::Flower(const Vector& pos, Type _type) : type(_type) { bbox.set_pos(pos); bbox.set_size(32, 32); if(_type == FIREFLOWER) sprite = sprite_manager->create("fireflower"); else sprite = sprite_manager->create("iceflower"); } Flower::~Flower() { delete sprite; } void Flower::action(float ) { } void Flower::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } HitResponse Flower::collision(GameObject& other, const CollisionHit& hit) { Player* player = dynamic_cast<Player*>(&other); if(!player) return ABORT_MOVE; if(type == FIREFLOWER) player->got_power = Player::FIRE_POWER; else player->got_power = Player::ICE_POWER; SoundManager::get()->play_sound(IDToSound(SND_COFFEE)); remove_me(); return ABORT_MOVE; } --- NEW FILE: bullet.cpp --- #include <config.h> #include <math.h> #include "bullet.h" #include "defines.h" #include "resources.h" #include "camera.h" #include "sector.h" #include "app/globals.h" #include "special/sprite_manager.h" #include "badguy/badguy.h" static const float BULLET_XM = 300; static const float BULLET_STARTING_YM = 0; Bullet::Bullet(const Vector& pos, float xm, int dir, int kind_) : kind(kind_), life_count(3), sprite(0) { bbox.set_pos(pos); bbox.set_size(4, 4); float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM; physic.set_velocity_x(speed + xm); physic.set_velocity_y(-BULLET_STARTING_YM); if (kind == ICE_BULLET) { life_count = 6; //ice-bullets get "extra lives" for bumping off walls sprite = sprite_manager->create("icebullet"); } else if(kind == FIRE_BULLET) { sprite = sprite_manager->create("firebullet"); } } Bullet::~Bullet() { delete sprite; } void Bullet::action(float elapsed_time) { if(kind == FIRE_BULLET) { // @not completely framerate independant :-/ physic.set_velocity_y(physic.get_velocity_y() - 50 * elapsed_time); } if(physic.get_velocity_y() > 900) physic.set_velocity_y(900); else if(physic.get_velocity_y() < -900) physic.set_velocity_y(-900); float scroll_x = Sector::current()->camera->get_translation().x; float scroll_y = Sector::current()->camera->get_translation().y; if (get_pos().x < scroll_x || get_pos().x > scroll_x + screen->w || // get_pos().y < scroll_y || get_pos().y > scroll_y + screen->h || life_count <= 0) { remove_me(); return; } movement = physic.get_movement(elapsed_time); } void Bullet::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } HitResponse Bullet::collision(GameObject& other, const CollisionHit& hit) { if(other.get_flags() & FLAG_SOLID) { if(fabsf(hit.normal.y) > .5) { // roof or floor bump physic.set_velocity_y(-physic.get_velocity_y()); life_count -= 1; } else { // bumped left or right if(kind == FIRE_BULLET) remove_me(); else physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { badguy->kill_fall(); remove_me(); return FORCE_MOVE; } // TODO kill badguys return FORCE_MOVE; } --- NEW FILE: platform.h --- #ifndef __PLATFORM_H__ #define __PLATFORM_H__ #include "special/moving_object.h" #include "special/sprite.h" using namespace SuperTux; /** * This class is the base class for platforms that tux can stand on */ class Platform : public SuperTux::MovingObject { public: Platform(LispReader& reader); ~Platform(); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); private: int state; Sprite* sprite; }; #endif --- NEW FILE: oneup.cpp --- #include <config.h> #include "oneup.h" #include "resources.h" #include "player.h" #include "scene.h" #include "special/sprite_manager.h" #include "video/drawing_context.h" OneUp::OneUp(const Vector& pos) { bbox.set_pos(pos); bbox.set_size(32, 32); sprite = sprite_manager->create("1up"); physic.set_velocity(100, 400); } OneUp::~OneUp() { delete sprite; } void OneUp::action(float elapsed_time) { movement = physic.get_movement(elapsed_time); } void OneUp::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } HitResponse OneUp::collision(GameObject& other, const CollisionHit& hit) { Player* player = dynamic_cast<Player*> (&other); if(player) { player->get_status().incLives(); remove_me(); return ABORT_MOVE; } return FORCE_MOVE; } --- NEW FILE: growup.h --- #ifndef __GROWUP_H__ #define __GROWUP_H__ #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" using namespace SuperTux; class GrowUp : public MovingObject { public: GrowUp(const Vector& pos); ~GrowUp(); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); private: Sprite* sprite; Physic physic; }; #endif --- NEW FILE: block.h --- #ifndef __BOX_H__ #define __BOX_H__ #include "special/moving_object.h" namespace SuperTux { class Sprite; } class Player; using namespace SuperTux; class Block : public MovingObject { public: Block(const Vector& pos, Sprite* sprite); ~Block(); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); protected: virtual void hit(Player* player) = 0; void start_bounce(); Sprite* sprite; bool bouncing; float bounce_dir; float bounce_offset; float original_y; }; class BonusBlock : public Block { public: BonusBlock(const Vector& pos, int data); protected: virtual void hit(Player* player); private: int data; }; class Brick : public Block { public: Brick(const Vector& pos, int data); protected: virtual void hit(Player* player); private: bool breakable; int coin_counter; }; #endif --- NEW FILE: coin.h --- #ifndef __COIN_H__ #define __COIN_H__ #include "special/moving_object.h" namespace SuperTux { class Sprite; } using namespace SuperTux; class Coin : public MovingObject { public: Coin(const Vector& pos); ~Coin(); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); private: Sprite* sprite; }; #endif --- NEW FILE: star.cpp --- #include <config.h> #include "star.h" #include "resources.h" #include "player.h" #include "scene.h" #include "special/sprite_manager.h" #include "video/drawing_context.h" static const float INITIALJUMP = 400; static const float SPEED = 150; static const float JUMPSPEED = 300; Star::Star(const Vector& pos) { bbox.set_pos(pos); bbox.set_size(32, 32); sprite = sprite_manager->create("star"); physic.set_velocity(SPEED, INITIALJUMP); } Star::~Star() { delete sprite; } void Star::action(float elapsed_time) { movement = physic.get_movement(elapsed_time); } void Star::draw(DrawingContext& context) { sprite->draw(context, get_pos(), LAYER_OBJECTS); } HitResponse Star::collision(GameObject& other, const CollisionHit& hit) { if(other.get_flags() & FLAG_SOLID) { if(hit.normal.y < -.5) { // ground physic.set_velocity_y(JUMPSPEED); } else if(hit.normal.y > .5) { // roof physic.set_velocity_y(0); } else { // bumped left or right physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } Player* player = dynamic_cast<Player*> (&other); if(player) { player->make_invincible(); remove_me(); return ABORT_MOVE; } return FORCE_MOVE; } --- NEW FILE: oneup.h --- #ifndef __ONEUP_H__ #define __ONEUP_H__ #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" using namespace SuperTux; class OneUp : public MovingObject { public: OneUp(const Vector& pos); ~OneUp(); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); private: Sprite* sprite; Physic physic; }; #endif --- NEW FILE: fireworks.h --- #ifndef __FIREWORKS_H__ #define __FIREWORKS_H__ #include "video/drawing_context.h" #include "special/game_object.h" #include "timer.h" class Fireworks : public SuperTux::GameObject { public: Fireworks(); ~Fireworks(); virtual void action(float elapsed_time); virtual void draw(SuperTux::DrawingContext& context); private: Timer2 timer; }; #endif --- NEW FILE: bullet.h --- #ifndef __BULLET_H__ #define __BULLET_H__ #include "special/moving_object.h" #include "math/physic.h" #include "special/sprite.h" using namespace SuperTux; enum BulletsKind { FIRE_BULLET, ICE_BULLET }; class Bullet : public MovingObject { public: Bullet(const Vector& pos, float xm, int dir, int kind); ~Bullet(); void action(float elapsed_time); void draw(DrawingContext& context); HitResponse collision(GameObject& other, const CollisionHit& hit); int kind; private: int life_count; Physic physic; Sprite* sprite; }; #endif --- NEW FILE: fireworks.cpp --- #include <config.h> #include "fireworks.h" #include "resources.h" #include "sector.h" #include "camera.h" #include "app/globals.h" #include "video/drawing_context.h" #include "audio/sound_manager.h" using namespace SuperTux; Fireworks::Fireworks() { timer.start(.2); } Fireworks::~Fireworks() { } void Fireworks::action(float ) { if(timer.check()) { Sector* sector = Sector::current(); Vector pos = sector->camera->get_translation(); pos += Vector(screen->w * ((float) rand() / RAND_MAX), screen->h/2 * ((float) rand() / RAND_MAX)); int red = rand() % 255; int green = rand() % red; sector->add_particles(pos, 0, 360, Vector(140, 140), Vector(0, 0), 45, Color(red, green, 0), 3, 1300, LAYER_FOREGROUND1+1); SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS)); timer.start(((float) rand() / RAND_MAX) + .5); } } void Fireworks::draw(DrawingContext& ) { } |
From: Matze B. <mat...@us...> - 2004-11-20 22:14:50
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5941/src/badguy Added Files: badguy.cpp badguy.h bomb.cpp bomb.h bouncing_snowball.cpp bouncing_snowball.h flame.cpp flame.h jumpy.cpp jumpy.h mrbomb.cpp mrbomb.h mriceblock.cpp mriceblock.h snowball.cpp snowball.h spiky.cpp spiky.h Log Message: The BIG COMMIT(tm) This is it, expect a broken supertux I only fixed the most annoying issues so far, lots more are still waiting in the TODO list, but I had to bring this stuff to cvs sometime. Changes: - Completely new collision detection scheme, which collides all objects with each other once per frame, instead of single objects manually testing for collisions - New collision detection routines which support slopes and provide additional info on collisions: penetration depth, hit normal vector - Lots of general cleanup/refactoring - Splitted the monolithic badguy class and reimplemented most of them as single classes with a badguy base class. - Splitted the monolithic Special class into several classes - Rewrote the timer and all timing related stuff to work on float and seconds (not like the mixup before where you had frame_ratio, msecs and secs in different parts of the app) - Support for unisolid tiles - Created a flying platform prototype (doesn't work completely yet) - rename InteractiveObjects to triggers and implemented a new sequence trigger, (only supported sequence is endsequence at the moment) - transformed the bonusblocks and bricks into objects --- NEW FILE: badguy.cpp --- #include <config.h> #include "badguy.h" #include "camera.h" static const float SQUISH_TIME = 2; static const float X_OFFSCREEN_DISTANCE = 1600; static const float Y_OFFSCREEN_DISTANCE = 1200; BadGuy::BadGuy() : sprite(0), dir(LEFT), state(STATE_INIT) { } BadGuy::~BadGuy() { delete sprite; } void BadGuy::draw(DrawingContext& context) { if(!sprite) return; if(state == STATE_INIT || state == STATE_INACTIVE) return; sprite->draw(context, get_pos(), LAYER_OBJECTS); } void BadGuy::action(float elapsed_time) { if(!Sector::current()->inside(bbox)) { remove_me(); return; } if(is_offscreen()) { set_state(STATE_INACTIVE); } switch(state) { case STATE_ACTIVE: active_action(elapsed_time); break; case STATE_INIT: case STATE_INACTIVE: inactive_action(elapsed_time); try_activate(); break; case STATE_SQUISHED: if(state_timer.check()) { remove_me(); break; } movement = physic.get_movement(elapsed_time); break; case STATE_FALLING: movement = physic.get_movement(elapsed_time); break; } } void BadGuy::activate() { } void BadGuy::deactivate() { } void BadGuy::active_action(float elapsed_time) { movement = physic.get_movement(elapsed_time); } void BadGuy::inactive_action(float elapsed_time) { } HitResponse BadGuy::collision(GameObject& other, const CollisionHit& hit) { switch(state) { case STATE_INIT: case STATE_INACTIVE: return ABORT_MOVE; case STATE_ACTIVE: { if(other.get_flags() & FLAG_SOLID) return collision_solid(other, hit); BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) return collision_badguy(*badguy, hit); Player* player = dynamic_cast<Player*> (&other); if(player) return collision_player(*player, hit); return FORCE_MOVE; } case STATE_SQUISHED: if(other.get_flags() & FLAG_SOLID) return CONTINUE; return FORCE_MOVE; case STATE_FALLING: return FORCE_MOVE; } return ABORT_MOVE; } HitResponse BadGuy::collision_solid(GameObject& other, const CollisionHit& hit) { return FORCE_MOVE; } HitResponse BadGuy::collision_player(Player& player, const CollisionHit& hit) { if(player.is_invincible()) { kill_fall(); return ABORT_MOVE; } if(hit.normal.y > .9) { if(collision_squished(player)) return ABORT_MOVE; } player.kill(Player::SHRINK); return FORCE_MOVE; } HitResponse BadGuy::collision_badguy(BadGuy& other, const CollisionHit& hit) { return FORCE_MOVE; } bool BadGuy::collision_squished(Player& player) { return false; } void BadGuy::kill_squished(Player& player) { SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), player.get_pos()); physic.set_velocity_x(0); physic.set_velocity_y(0); set_state(STATE_SQUISHED); player.bounce(*this); } void BadGuy::kill_fall() { physic.set_velocity_y(0); physic.enable_gravity(true); set_state(STATE_FALLING); remove_me(); } void BadGuy::set_state(State state) { if(this->state == state) return; State laststate = this->state; this->state = state; switch(state) { case STATE_SQUISHED: state_timer.start(SQUISH_TIME); break; case STATE_ACTIVE: flags &= ~FLAG_NO_COLLDET; bbox.set_pos(start_position); break; case STATE_INACTIVE: // was the badguy dead anyway? if(laststate == STATE_SQUISHED || laststate == STATE_SQUISHED) { remove_me(); } flags |= FLAG_NO_COLLDET; break; default: break; } } bool BadGuy::is_offscreen() { float scroll_x = Sector::current()->camera->get_translation().x; float scroll_y = Sector::current()->camera->get_translation().y; if(bbox.p2.x < scroll_x - X_OFFSCREEN_DISTANCE || bbox.p1.x > scroll_x + X_OFFSCREEN_DISTANCE || bbox.p2.y < scroll_y - Y_OFFSCREEN_DISTANCE || bbox.p1.y > scroll_y + Y_OFFSCREEN_DISTANCE) return true; return false; } void BadGuy::try_activate() { float scroll_x = Sector::current()->camera->get_translation().x; float scroll_y = Sector::current()->camera->get_translation().y; /* Activate badguys if they're just around the screen to avoid * the effect of having badguys suddenly popping up from nowhere. */ if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x - bbox.get_width() && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { dir = RIGHT; set_state(STATE_ACTIVE); activate(); } else if (start_position.x > scroll_x && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { dir = LEFT; set_state(STATE_ACTIVE); activate(); } else if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE && ((start_position.y > scroll_y && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) || (start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y))) { dir = start_position.x < scroll_x ? RIGHT : LEFT; set_state(STATE_ACTIVE); activate(); } else if(state == STATE_INIT && start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { dir = LEFT; set_state(STATE_ACTIVE); activate(); } } --- NEW FILE: snowball.h --- #ifndef __SNOWBALL_H__ #define __SNOWBALL_H__ #include "badguy.h" class SnowBall : public BadGuy { public: SnowBall(LispReader& reader); void activate(); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); protected: bool collision_squished(Player& player); }; #endif --- NEW FILE: spiky.h --- #ifndef __SPIKY_H__ #define __SPIKY_H__ #include "badguy.h" class Spiky : public BadGuy { public: Spiky(LispReader& reader); void activate(); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); }; #endif --- NEW FILE: bomb.h --- #ifndef __BOMB_H__ #define __BOMB_H__ #include "badguy.h" class Bomb : public BadGuy { public: Bomb(const Vector& pos, Direction dir); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_player(Player& player, const CollisionHit& hit); void active_action(float elapsed_time); void kill_fall(); private: int state; Timer2 timer; }; #endif --- NEW FILE: mriceblock.cpp --- #include <config.h> #include "mriceblock.h" static const float WALKSPEED = 80; static const float KICKSPEED = 500; static const int MAXSQUISHES = 10; MrIceBlock::MrIceBlock(LispReader& reader) : ice_state(ICESTATE_NORMAL), squishcount(0) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("mriceblock"); } void MrIceBlock::write(LispWriter& writer) { writer.start_list("mriceblock"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("mriceblock"); } void MrIceBlock::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } void MrIceBlock::active_action(float elapsed_time) { if(ice_state == ICESTATE_FLAT && flat_timer.check()) { printf("unflat.\n"); ice_state = ICESTATE_NORMAL; physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } BadGuy::active_action(elapsed_time); } HitResponse MrIceBlock::collision_solid(GameObject& other, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // floor or roof physic.set_velocity_y(0); return CONTINUE; } // hit left or right switch(ice_state) { case ICESTATE_NORMAL: dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); break; case ICESTATE_KICKED: dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); physic.set_velocity_x(-physic.get_velocity_x()); SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(), Sector::current()->player->get_pos()); break; case ICESTATE_FLAT: physic.set_velocity_x(0); break; } return CONTINUE; } bool MrIceBlock::collision_squished(Player& player) { switch(ice_state) { case ICESTATE_KICKED: case ICESTATE_NORMAL: squishcount++; if(squishcount >= MAXSQUISHES) { kill_fall(); return true; } // flatten SoundManager::get()->play_sound(IDToSound(SND_STOMP), get_pos(), player.get_pos()); physic.set_velocity_x(0); physic.set_velocity_y(0); sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); flat_timer.start(4); ice_state = ICESTATE_FLAT; printf("flat.\n"); break; case ICESTATE_FLAT: // kick SoundManager::get()->play_sound(IDToSound(SND_KICK), this, player.get_pos()); if(player.get_pos().x < get_pos().x) { dir = RIGHT; } else { dir = LEFT; } physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED); sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); ice_state = ICESTATE_KICKED; printf("kicked.\n"); break; } player.bounce(*this); return true; } --- NEW FILE: bouncing_snowball.h --- #ifndef __BOUNCING_SNOWBALL_H__ #define __BOUNCING_SNOWBALL_H__ #include "badguy.h" class BouncingSnowball : public BadGuy { public: BouncingSnowball(LispReader& reader); void activate(); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); protected: bool collision_squished(Player& player); }; #endif --- NEW FILE: jumpy.cpp --- #include <config.h> #include "jumpy.h" static const float JUMPSPEED=600; Jumpy::Jumpy(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("jumpy"); } void Jumpy::write(LispWriter& writer) { writer.start_list("jumpy"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("jumpy"); } HitResponse Jumpy::collision_solid(GameObject& other, const CollisionHit& hit) { // hit floor? if(hit.normal.y < -.5) { physic.set_velocity_y(JUMPSPEED); } else if(hit.normal.y < .5) { // bumped on roof physic.set_velocity_y(0); } return CONTINUE; } --- NEW FILE: jumpy.h --- #ifndef __JUMPY_H__ #define __JUMPY_H__ #include "badguy.h" #include "utils/lispreader.h" #include "utils/lispwriter.h" #include "serializable.h" class Jumpy : public BadGuy { public: Jumpy(LispReader& reader); virtual HitResponse collision_solid(GameObject& other, const CollisionHit& hit); virtual void write(LispWriter& writer); }; #endif --- NEW FILE: bouncing_snowball.cpp --- #include <config.h> #include "bouncing_snowball.h" static const float JUMPSPEED = 450; static const float WALKSPEED = 80; BouncingSnowball::BouncingSnowball(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("bouncingsnowball"); } void BouncingSnowball::write(LispWriter& writer) { writer.start_list("bouncingsnowball"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("bouncingsnowball"); } void BouncingSnowball::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } bool BouncingSnowball::collision_squished(Player& player) { sprite->set_action("squished"); kill_squished(player); return true; } HitResponse BouncingSnowball::collision_solid(GameObject& other, const CollisionHit& hit) { if(hit.normal.y < -.5) { // hit floor physic.set_velocity_y(JUMPSPEED); } else if(hit.normal.y > .5) { // bumped on roof physic.set_velocity_y(0); } else { // left or right collision dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } --- NEW FILE: spiky.cpp --- #include <config.h> #include "spiky.h" static const float WALKSPEED = 80; Spiky::Spiky(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("spiky"); } void Spiky::write(LispWriter& writer) { writer.start_list("spiky"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("spiky"); } void Spiky::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } HitResponse Spiky::collision_solid(GameObject& other, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // hit floor or roof? physic.set_velocity_y(0); } else { // hit right or left dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } --- NEW FILE: mriceblock.h --- #ifndef __MRICEBLOCK_H__ #define __MRICEBLOCK_H__ #include "badguy.h" class MrIceBlock : public BadGuy { public: MrIceBlock(LispReader& reader); void activate(); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); void active_action(float elapsed_time); protected: bool collision_squished(Player& player); private: enum IceState { ICESTATE_NORMAL, ICESTATE_FLAT, ICESTATE_KICKED }; IceState ice_state; Timer2 flat_timer; int squishcount; }; #endif --- NEW FILE: badguy.h --- #ifndef __BADGUY_H__ #define __BADGUY_H__ // moved them here to make it less typing when implementing new badguys #include <math.h> #include "timer.h" #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" #include "player.h" #include "serializable.h" #include "resources.h" #include "sector.h" #include "utils/lispwriter.h" #include "utils/lispreader.h" #include "video/drawing_context.h" #include "special/sprite_manager.h" using namespace SuperTux; class BadGuy : public MovingObject, public Serializable { public: BadGuy(); ~BadGuy(); //virtual void action_activated(float elapsed_time); virtual void draw(DrawingContext& context); virtual void action(float elapsed_time); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); virtual void kill_fall(); protected: enum State { STATE_INIT, STATE_INACTIVE, STATE_ACTIVE, STATE_SQUISHED, STATE_FALLING }; virtual HitResponse collision_player(Player& player, const CollisionHit& hit); virtual HitResponse collision_solid(GameObject& other, const CollisionHit& hit); virtual HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); virtual bool collision_squished(Player& player); virtual void active_action(float elapsed_time); virtual void inactive_action(float elapsed_time); /** * called when the badguy has been activated. (As a side effect the dir * variable might have been changed so that it faces towards the player. */ virtual void activate(); /** caleed when the badguy has been deactivated */ virtual void deactivate(); void kill_squished(Player& player); void set_state(State state); State get_state() const { return state; } /** * returns a pointer to the player, try to avoid this function to avoid * problems later when we have multiple players or no player in scripted * sequence. */ Player* get_player(); Sprite* sprite; Physic physic; /// is the enemy activated bool activated; /** * initial position of the enemy. Also the position where enemy respawns when * after being deactivated. */ Vector start_position; Direction dir; private: bool is_offscreen(); void try_activate(); State state; Timer2 state_timer; }; #endif --- NEW FILE: mrbomb.cpp --- #include <config.h> #include "mrbomb.h" #include "bomb.h" static const float WALKSPEED = 80; MrBomb::MrBomb(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("mrbomb"); } void MrBomb::write(LispWriter& writer) { writer.start_list("snowball"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("snowball"); } void MrBomb::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } bool MrBomb::collision_squished(Player& player) { remove_me(); Sector::current()->add_object(new Bomb(get_pos(), dir)); player.bounce(*this); return true; } HitResponse MrBomb::collision_solid(GameObject& other, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // hit floor or roof? physic.set_velocity_y(0); } else { // hit right or left dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } --- NEW FILE: snowball.cpp --- #include <config.h> #include "snowball.h" static const float WALKSPEED = 80; SnowBall::SnowBall(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); bbox.set_size(32, 32); sprite = sprite_manager->create("snowball"); } void SnowBall::write(LispWriter& writer) { writer.start_list("snowball"); writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); writer.end_list("snowball"); } void SnowBall::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } bool SnowBall::collision_squished(Player& player) { sprite->set_action(dir == LEFT ? "squished-left" : "squished-right"); kill_squished(player); return true; } HitResponse SnowBall::collision_solid(GameObject& other, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // hit floor or roof? physic.set_velocity_y(0); } else { // hit right or left dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); } return CONTINUE; } --- NEW FILE: flame.h --- #ifndef __FLAME_H__ #define __FLAME_H__ #include "badguy.h" class Flame : public BadGuy { public: Flame(LispReader& reader); void write(LispWriter& write); void active_action(float elapsed_time); void kill_fall(); private: float angle; float radius; float speed; }; #endif --- NEW FILE: bomb.cpp --- #include <config.h> #include "bomb.h" static const float TICKINGTIME = 1; static const float EXPLOSIONTIME = 1; Bomb::Bomb(const Vector& pos, Direction dir) { start_position = pos; bbox.set_pos(pos); bbox.set_size(32, 32); sprite = sprite_manager->create("bomb"); state = 0; timer.start(TICKINGTIME); this->dir = dir; sprite->set_action(dir == LEFT ? "ticking-left" : "ticking-right"); } void Bomb::write(LispWriter& writer) { // bombs are only temporarily so don't write them out... } HitResponse Bomb::collision_solid(GameObject& other, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) physic.set_velocity_y(0); return CONTINUE; } HitResponse Bomb::collision_player(Player& player, const CollisionHit& hit) { if(state == 1) { player.kill(Player::SHRINK); } return ABORT_MOVE; } void Bomb::active_action(float elapsed_time) { switch(state) { case 0: if(timer.check()) { state = 1; sprite->set_action("explosion"); timer.start(EXPLOSIONTIME); } break; case 1: if(timer.check()) { remove_me(); } break; } } void Bomb::kill_fall() { } --- NEW FILE: mrbomb.h --- #ifndef __MRBOMB_H__ #define __MRBOMB_H__ #include "badguy.h" class MrBomb : public BadGuy { public: MrBomb(LispReader& reader); void activate(); void write(LispWriter& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); protected: bool collision_squished(Player& player); }; #endif --- NEW FILE: flame.cpp --- #include <config.h> #include "flame.h" Flame::Flame(LispReader& reader) : angle(0), radius(100), speed(2) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); reader.read_float("radius", radius); reader.read_float("speed", speed); bbox.set_pos(Vector(start_position.x + cos(angle) * radius, start_position.y + sin(angle) * radius)); bbox.set_size(32, 32); sprite = sprite_manager->create("flame"); } void Flame::write(LispWriter& writer) { writer.start_list("flame"); writer.write_float("x", start_position.x); writer.write_float("y", start_position.y); writer.write_float("radius", radius); writer.write_float("speed", speed); writer.end_list("flame"); } void Flame::active_action(float elapsed_time) { angle = fmodf(angle + elapsed_time * speed, 2*M_PI); Vector newpos(start_position.x + cos(angle) * radius, start_position.y + sin(angle) * radius); movement = newpos - get_pos(); } void Flame::kill_fall() { } |
From: Matze B. <mat...@us...> - 2004-11-20 22:05:02
|
Update of /cvsroot/super-tux/supertux/src/trigger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5253/trigger Log Message: Directory /cvsroot/super-tux/supertux/src/trigger added to the repository |
From: Matze B. <mat...@us...> - 2004-11-20 22:05:02
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5253/badguy Log Message: Directory /cvsroot/super-tux/supertux/src/badguy added to the repository |
From: Matze B. <mat...@us...> - 2004-11-20 22:05:02
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5253/object Log Message: Directory /cvsroot/super-tux/supertux/src/object added to the repository |
From: Ryan F. <sik...@us...> - 2004-11-20 20:42:46
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21825/levels/test Modified Files: level14.stl Log Message: - fixed background Index: level14.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level14.stl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- level14.stl 3 Oct 2004 10:58:03 -0000 1.4 +++ level14.stl 20 Nov 2004 20:42:37 -0000 1.5 @@ -7,7 +7,7 @@ (height 19) (start_pos_x 100) (start_pos_y 100) - (background "arctis2.jpg") + (background "arctis.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red_top 150) (bkgd_green_top 200) |
From: Matze B. <mat...@us...> - 2004-11-20 17:28:12
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13237 Modified Files: SConstruct Log Message: output some help on scons -h Index: SConstruct =================================================================== RCS file: /cvsroot/super-tux/supertux/SConstruct,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- SConstruct 20 Nov 2004 15:18:23 -0000 1.18 +++ SConstruct 20 Nov 2004 17:28:03 -0000 1.19 @@ -87,6 +87,7 @@ ['optimize', 'debug', 'profile'])) env = Environment(options = opts) +Help(opts.GenerateHelpText(env)) # Create build_config.py and config.h if not os.path.exists("build_config.py") or not os.path.exists("config.h"): |
From: Matze B. <mat...@us...> - 2004-11-20 15:18:33
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20357 Modified Files: SConstruct Added Files: SConscript Log Message: hack to make scons -U work in toplevel dir too Index: SConstruct =================================================================== RCS file: /cvsroot/super-tux/supertux/SConstruct,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- SConstruct 20 Nov 2004 14:49:10 -0000 1.17 +++ SConstruct 20 Nov 2004 15:18:23 -0000 1.18 @@ -143,4 +143,4 @@ env.Export(["env", "Glob"]) env.SConscript("lib/SConscript", build_dir=build_dir + "/lib", duplicate=0) env.SConscript("src/SConscript", build_dir=build_dir + "/src", duplicate=0) -Default("supertux") +env.SConscript("SConscript", build_dir=build_dir, duplicate=0) --- NEW FILE: SConscript --- # needed so that scons -U works correctly Default(".") |