super-tux-commit Mailing List for Super Tux (Page 95)
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: Ricardo C. <rm...@us...> - 2004-04-18 12:11:22
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26742/data Modified Files: CREDITS Log Message: Changes in credits: Added Ryan and Ingo to the developers list. Ranked me to an higher position ;D Index: CREDITS =================================================================== RCS file: /cvsroot/super-tux/supertux/data/CREDITS,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CREDITS 15 Mar 2004 17:45:29 -0000 1.3 +++ CREDITS 18 Apr 2004 12:11:11 -0000 1.4 @@ -13,8 +13,18 @@ Bill Kendrick Original author -Duong-Khang NGUYEN Ricardo Cruz + Main developer + Made the very first leveleditor and + now works a bit everywhere. + +Ingo Ruhnke + Main developer + Made a lot of C++ ports, introduced + the worldmap and the lispreader. + +Ryan +Duong-Khang NGUYEN Contributors |
From: Ricardo C. <rm...@us...> - 2004-04-18 12:03:18
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25291/src Modified Files: gameloop.cpp leveleditor.cpp menu.cpp menu.h timer.cpp title.cpp worldmap.cpp Log Message: Finally!! This makes the Back button to be used in case there is one (when Esc is pressed). Because of that, the menu is now much more independent. Currently, everything seems to be working just fine and smooth. Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- menu.cpp 13 Apr 2004 12:25:22 -0000 1.35 +++ menu.cpp 18 Apr 2004 12:03:06 -0000 1.36 @@ -144,6 +144,7 @@ { pos_x = screen->w/2; pos_y = screen->h/2; + has_backitem = false; last_menu = 0; arrange_left = 0; active_item = 0; @@ -160,6 +161,9 @@ void Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_) { + if(kind_ == MN_BACK) + has_backitem = true; + additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_)); } @@ -167,6 +171,9 @@ void Menu::additem(MenuItem* pmenu_item) { + if(pmenu_item->kind == MN_BACK) + has_backitem = true; + item.push_back(*pmenu_item); delete pmenu_item; } @@ -540,6 +547,9 @@ /* Draw the current menu and execute the (menu)events */ void menu_process_current(void) { + if(!show_menu) + return; + menu_change = false; if(current_menu != NULL) @@ -555,6 +565,9 @@ void Menu::event(SDL_Event& event) { + if(show_menu == false && event.key.keysym.sym != SDLK_ESCAPE) + return; + SDLKey key; switch(event.type) { @@ -613,6 +626,13 @@ menu_change = true; delete_character++; break; + case SDLK_ESCAPE: + if(show_menu && has_backitem == true && last_menu != NULL) + Menu::set_current(last_menu); + else if(show_menu) + show_menu = false; + else + show_menu = true; default: if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH)) { Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- menu.h 13 Apr 2004 12:25:22 -0000 1.34 +++ menu.h 18 Apr 2004 12:03:07 -0000 1.35 @@ -59,6 +59,7 @@ // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; + bool has_backitem; Menu* last_menu; int width(); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- leveleditor.cpp 17 Apr 2004 13:29:38 -0000 1.49 +++ leveleditor.cpp 18 Apr 2004 12:03:06 -0000 1.50 @@ -40,7 +40,6 @@ /* definitions to aid development */ #define DONE_LEVELEDITOR 1 #define DONE_QUIT 2 -#define DONE_CHANGELEVEL 3 /* definitions that affect gameplay */ #define KEY_CURSOR_SPEED 32 @@ -340,12 +339,6 @@ return 0; } - if(done == DONE_QUIT) - { - le_quit(); - return 1; - } - ++global_frame_counter; SDL_Delay(25); @@ -791,9 +784,8 @@ while(SDL_PollEvent(&event)) { - if(show_menu) - current_menu->event(event); - else + current_menu->event(event); + if(!show_menu) mouse_cursor->set_state(MC_NORMAL); /* testing SDL_KEYDOWN, SDL_KEYUP and SDL_QUIT events*/ @@ -804,23 +796,8 @@ { case SDL_KEYDOWN: // key pressed key = event.key.keysym.sym; - if(show_menu) - { - if(key == SDLK_ESCAPE) - { - show_menu = false; - Menu::set_current(leveleditor_menu); - } - break; - } switch(key) { - case SDLK_ESCAPE: - if(!show_menu) - show_menu = true; - else - show_menu = false; - break; case SDLK_LEFT: if(fire == DOWN) cursor_x -= KEY_CURSOR_SPEED; Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- timer.cpp 11 Apr 2004 16:38:58 -0000 1.9 +++ timer.cpp 18 Apr 2004 12:03:07 -0000 1.10 @@ -32,7 +32,8 @@ void st_pause_ticks_start(void) { - st_pause_count = SDL_GetTicks(); + if(st_pause_count == 0) + st_pause_count = SDL_GetTicks(); } void st_pause_ticks_stop(void) Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- title.cpp 17 Apr 2004 13:56:48 -0000 1.44 +++ title.cpp 18 Apr 2004 12:03:07 -0000 1.45 @@ -285,7 +285,7 @@ /* Check for menu events */ //menu_event(event); - if (key == SDLK_ESCAPE) + if (!show_menu) { /* Escape: Quit: */ done = true; Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- worldmap.cpp 17 Apr 2004 21:24:02 -0000 1.31 +++ worldmap.cpp 18 Apr 2004 12:03:07 -0000 1.32 @@ -370,11 +370,11 @@ SDL_Event event; while (SDL_PollEvent(&event)) { - if(show_menu) - { - current_menu->event(event); - } - else + if(!show_menu && event.key.keysym.sym == SDLK_ESCAPE) + Menu::set_current(worldmap_menu); + + current_menu->event(event); + if(!show_menu) { switch(event.type) { @@ -385,10 +385,6 @@ case SDL_KEYDOWN: switch(event.key.keysym.sym) { - case SDLK_ESCAPE: - Menu::set_current(worldmap_menu); - show_menu = !show_menu; - break; case SDLK_LCTRL: case SDLK_RETURN: enter_level = true; @@ -643,8 +639,7 @@ void WorldMap::display() { - show_menu = 0; - menu_reset(); + show_menu = false; quit = false; @@ -669,7 +664,11 @@ get_input(); update(); - menu_process_current(); + if(show_menu) + { + menu_process_current(); + mouse_cursor->draw(); + } flipscreen(); SDL_Delay(20); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- gameloop.cpp 17 Apr 2004 13:56:47 -0000 1.74 +++ gameloop.cpp 18 Apr 2004 12:03:06 -0000 1.75 @@ -134,8 +134,7 @@ while (SDL_PollEvent(&event)) { /* Check for menu-events, if the menu is shown */ - if(show_menu) - current_menu->event(event); + current_menu->event(event); switch(event.type) { @@ -159,7 +158,7 @@ { exit_status = LEVEL_ABORT; } - else if(show_menu) + else if(!show_menu) { Menu::set_current(game_menu); show_menu = 0; |
From: Ricardo C. <rm...@us...> - 2004-04-18 11:10:04
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9573/src Modified Files: badguy.cpp player.cpp world.cpp Log Message: Patch by Ryan: « Here's a patch that makes a few changes that makes ST more like SMB. Changes include: * Kicked mriceblocks (laptops) don't die after hitting a single enemy, they keep going to kill more badguys (or Tux if you're not careful) * You can now kick mriceblocks (laptops) by running into their sides. Before you had to jump on them to "kick" them and if you walked into their sides you would die (or shrink). * When badguys walk into one another they turn around instead of walking through eachother. » Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- player.cpp 17 Apr 2004 13:56:47 -0000 1.39 +++ player.cpp 18 Apr 2004 11:09:55 -0000 1.40 @@ -726,8 +726,8 @@ { case CO_BADGUY: pbad_c = (BadGuy*) p_c_object; - /* Hurt the player if he just touched it: */ + /* Hurt player if he touches a badguy */ if (!pbad_c->dying && !dying && !safe_timer.started() && pbad_c->mode != HELD) @@ -737,30 +737,24 @@ pbad_c->mode = HELD; pbad_c->base.y-=8; } + else if (pbad_c->mode == FLAT) + { + // Don't get hurt if we're kicking a flat badguy! + } else if (pbad_c->mode == KICK) { - if (base.y < pbad_c->base.y - 16) + /* Hurt if you get hit by kicked laptop: */ + if (!invincible_timer.started()) { - /* Step on (stop being kicked) */ - - pbad_c->mode = FLAT; - play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER); + kill(SHRINK); } else { - /* Hurt if you get hit by kicked laptop: */ - if (!invincible_timer.started()) - { - kill(SHRINK); - } - else - { - pbad_c->dying = DYING_FALLING; - play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); - World::current()->add_score(pbad_c->base.x - scroll_x, - pbad_c->base.y, - 25 * player_status.score_multiplier); - } + pbad_c->dying = DYING_FALLING; + play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); + World::current()->add_score(pbad_c->base.x - scroll_x, + pbad_c->base.y, + 25 * player_status.score_multiplier); } } else Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- badguy.cpp 17 Apr 2004 12:00:31 -0000 1.36 +++ badguy.cpp 18 Apr 2004 11:09:55 -0000 1.37 @@ -957,6 +957,7 @@ return; } + /* COLLISION_NORMAL */ switch (c_object) { case CO_BULLET: @@ -965,13 +966,12 @@ case CO_BADGUY: pbad_c = (BadGuy*) p_c_object; + + /* If we're a kicked mriceblock, kill any badguys we hit */ if(kind == BAD_LAPTOP && mode == KICK && pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB) { - /* We're in kick mode, kill the other guy - and yourself(wuahaha) : */ pbad_c->kill_me(); - kill_me(); } /* Kill badguys that run into exploding bomb */ @@ -993,8 +993,46 @@ { pbad_c->kill_me(); } + + /* When enemies run into eachother, make them change directions */ + else + { + // Jumpy is an exception + if (pbad_c->kind == BAD_MONEY) + break; + if (dir == LEFT) + dir = RIGHT; + else if (dir == RIGHT) + dir = LEFT; + + physic.inverse_velocity_x(); + } break; + + case CO_PLAYER: + Player* player = static_cast<Player*>(p_c_object); + /* Get kicked if were flat */ + if (mode == FLAT && !dying) + { + play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER); + + // Hit from left side + if (player->base.x < base.x) { + physic.set_velocity(5, physic.get_velocity_y()); + dir = RIGHT; + } + // Hit from right side + else { + physic.set_velocity(-5, physic.get_velocity_y()); + dir = LEFT; + } + + mode = KICK; + set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); + } + break; + } } Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- world.cpp 17 Apr 2004 13:56:48 -0000 1.27 +++ world.cpp 18 Apr 2004 11:09:55 -0000 1.28 @@ -315,6 +315,7 @@ else { tux.collision(&bad_guys[i], CO_BADGUY); + bad_guys[i].collision(&tux, CO_PLAYER, COLLISION_NORMAL); } } } |
From: Ingo R. <gr...@us...> - 2004-04-17 22:22:45
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29505 Modified Files: sprite.cpp sprite.h Log Message: - added draw_part() Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- sprite.cpp 17 Apr 2004 10:48:04 -0000 1.3 +++ sprite.cpp 17 Apr 2004 22:22:35 -0000 1.4 @@ -71,6 +71,16 @@ } void +Sprite::draw_part(float sx, float sy, float x, float y, float w, float h) +{ + time = SDL_GetTicks(); + unsigned int frame = get_current_frame(); + + if (frame < surfaces.size()) + surfaces[frame]->draw_part(sx, sy, x - x_hotspot, y - y_hotspot, w, h); +} + +void Sprite::reset() { time = 0; Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- sprite.h 17 Apr 2004 10:48:04 -0000 1.4 +++ sprite.h 17 Apr 2004 22:22:35 -0000 1.5 @@ -55,7 +55,7 @@ /** Update the sprite and process to the next frame */ void update(float delta); void draw(float x, float y); - + void draw_part(float sx, float sy, float x, float y, float w, float h); int get_current_frame() const; std::string get_name() const { return name; } |
From: Ingo R. <gr...@us...> - 2004-04-17 21:24:11
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19465 Modified Files: worldmap.cpp worldmap.h Log Message: - implemented locked levels on worldmap Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- worldmap.cpp 17 Apr 2004 20:41:18 -0000 1.30 +++ worldmap.cpp 17 Apr 2004 21:24:02 -0000 1.31 @@ -31,6 +31,57 @@ namespace WorldMapNS { +Direction reverse_dir(Direction direction) +{ + switch(direction) + { + case WEST: + return EAST; + case EAST: + return WEST; + case NORTH: + return SOUTH; + case SOUTH: + return NORTH; + case NONE: + return NONE; + } + return NONE; +} + +std::string +direction_to_string(Direction direction) +{ + switch(direction) + { + case WEST: + return "west"; + case EAST: + return "east"; + case NORTH: + return "north"; + case SOUTH: + return "south"; + default: + return "none"; + } +} + +Direction +string_to_direction(const std::string& directory) +{ + if (directory == "west") + return WEST; + else if (directory == "east") + return EAST; + else if (directory == "north") + return NORTH; + else if (directory == "south") + return SOUTH; + else + return NONE; +} + TileManager* TileManager::instance_ = 0; TileManager::TileManager() @@ -162,13 +213,26 @@ if (!moving) { if (input_direction != NONE) - { // We got a new direction, so lets start walking when possible + { + WorldMap::Level* level = worldmap->at_level(); + + // We got a new direction, so lets start walking when possible Point next_tile; - if (worldmap->path_ok(input_direction, tile_pos, &next_tile)) + if ((!level || level->solved) + && worldmap->path_ok(input_direction, tile_pos, &next_tile)) { tile_pos = next_tile; moving = true; direction = input_direction; + back_direction = reverse_dir(direction); + } + else if (input_direction == back_direction) + { + std::cout << "Back triggered" << std::endl; + moving = true; + direction = input_direction; + tile_pos = worldmap->get_next_tile(tile_pos, direction); + back_direction = reverse_dir(direction); } } } @@ -187,6 +251,7 @@ } else { + // Walk automatically to the next tile Point next_tile; if (worldmap->path_ok(direction, tile_pos, &next_tile)) { @@ -271,6 +336,12 @@ Level level; LispReader reader(lisp_cdr(element)); level.solved = false; + + level.north = true; + level.east = true; + level.south = true; + level.west = true; + reader.read_string("name", &level.name); reader.read_int("x", &level.x); reader.read_int("y", &level.y); @@ -487,20 +558,21 @@ && p.x < width && p.y >= 0 && p.y < height); + return TileManager::instance()->get(tilemap[width * p.y + p.x]); } -bool +WorldMap::Level* WorldMap::at_level() { for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { if (i->x == tux->get_tile_pos().x && i->y == tux->get_tile_pos().y) - return true; + return &*i; } - return false; + return 0; } @@ -625,7 +697,8 @@ << " (lives " << player_status.lives << ")\n" << " (score " << player_status.score << ")\n" << " (distros " << player_status.distros << ")\n" - << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << "))\n" + << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")" + << " (back \"" << direction_to_string(tux->back_direction) << "\"))\n" << " (levels\n"; for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) @@ -684,10 +757,14 @@ { std::string name; bool solved = false; - + std::string back_str =""; + Direction back = NONE; + LispReader level_reader(data); level_reader.read_string("name", &name); level_reader.read_bool("solved", &solved); + if (level_reader.read_string("back", &back_str)) + back = string_to_direction(back_str); std::cout << "Name: " << name << " " << solved << std::endl; Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- worldmap.h 17 Apr 2004 14:13:53 -0000 1.18 +++ worldmap.h 17 Apr 2004 21:24:02 -0000 1.19 @@ -77,10 +77,16 @@ enum Direction { NONE, WEST, EAST, NORTH, SOUTH }; +std::string direction_to_string(Direction d); +Direction string_to_direction(const std::string& d); +Direction reverse_dir(Direction d); + class WorldMap; class Tux { +public: + Direction back_direction; private: WorldMap* worldmap; Surface* sprite; @@ -127,14 +133,22 @@ int width; int height; +public: struct Level { int x; int y; std::string name; bool solved; + + // Directions which are walkable from this level + bool north; + bool east; + bool south; + bool west; }; +private: typedef std::vector<Level> Levels; Levels levels; @@ -166,7 +180,7 @@ Point get_next_tile(Point pos, Direction direction); Tile* at(Point pos); - bool at_level(); + WorldMap::Level* at_level(); /** Check if it is possible to walk from \a pos into \a direction, if possible, write the new position to \a new_pos */ |
From: Ingo R. <gr...@us...> - 2004-04-17 20:41:27
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11590 Modified Files: worldmap.cpp Log Message: - fixed loadgame Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- worldmap.cpp 17 Apr 2004 14:13:53 -0000 1.29 +++ worldmap.cpp 17 Apr 2004 20:41:18 -0000 1.30 @@ -517,8 +517,12 @@ for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { - leveldot_green->draw(i->x*32 + offset.x, - i->y*32 + offset.y); + if (i->solved) + leveldot_green->draw(i->x*32 + offset.x, + i->y*32 + offset.y); + else + leveldot_red->draw(i->x*32 + offset.x, + i->y*32 + offset.y); } tux->draw(offset); @@ -673,16 +677,25 @@ { while(level_cur) { - std::string name; - bool solved = false; - LispReader level_reader(level_cur); - level_reader.read_string("name", &name); - level_reader.read_bool("solved", &solved); + lisp_object_t* sym = lisp_car(lisp_car(level_cur)); + lisp_object_t* data = lisp_cdr(lisp_car(level_cur)); - for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + if (strcmp(lisp_symbol(sym), "level") == 0) { - if (name == i->name) - i->solved = solved; + std::string name; + bool solved = false; + + LispReader level_reader(data); + level_reader.read_string("name", &name); + level_reader.read_bool("solved", &solved); + + std::cout << "Name: " << name << " " << solved << std::endl; + + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (name == i->name) + i->solved = solved; + } } level_cur = lisp_cdr(level_cur); |
From: Ricardo C. <rm...@us...> - 2004-04-17 15:40:10
|
Update of /cvsroot/super-tux/supertux/data/levels/default In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21554/data/levels/default Modified Files: worldmap.stwm Log Message: Marek has sent this hand of 'world1' levels that he thinks are suitable for a release. He has polish them. I have made worldmap to use them. We need testing, boys! Index: worldmap.stwm =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/default/worldmap.stwm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- worldmap.stwm 17 Apr 2004 14:18:00 -0000 1.8 +++ worldmap.stwm 17 Apr 2004 15:40:01 -0000 1.9 @@ -37,76 +37,76 @@ )) (levels - (level (name "default/level1.stl") + (level (name "world1/level1.stl") (x 5) (y 4)) - (level (name "default/level2.stl") + (level (name "world1/level2.stl") (x 4) (y 7)) - (level (name "default/level3.stl") + (level (name "world1/level3.stl") (x 5) (y 11)) - (level (name "Level 4") + (level (name "world1/level4.stl") (x 7) (y 11)) - (level (name "Level 5") + (level (name "world1/level5.stl") (x 7) (y 8)) - (level (name "Level 6") + (level (name "world1/level6.stl") (x 11) (y 9)) - (level (name "Level 7") + (level (name "world1/level7.stl") (x 14) (y 9)) - (level (name "Level 8") + (level (name "world1/level8.stl") (x 16) (y 8)) - (level (name "Level 9") + (level (name "world1/level9.stl") (x 16) (y 6)) - (level (name "Level 10") + (level (name "world1/level10.stl") (x 21) (y 8)) - (level (name "Level 11") + (level (name "world1/level11.stl") (x 26) (y 7)) - (level (name "Level 12") + (level (name "world1/level12.stl") (x 28) (y 9)) - (level (name "Level 13") + (level (name "world1/level13.stl") (x 31) (y 9)) - (level (name "Level 14") + (level (name "world1/level14.stl") (x 34) (y 11)) - (level (name "Level 15") + (level (name "world1/level15.stl") (x 29) (y 11)) - (level (name "Level 16") + (level (name "world1/level16.stl") (x 28) (y 13)) - (level (name "Level 17") + (level (name "world1/level17.stl") (x 29) (y 16)) - (level (name "Level 18") + (level (name "world1/level18.stl") (x 27) (y 19)) - (level (name "Level 19") + (level (name "world1/level19.stl") (x 23) (y 22)) - (level (name "Level 20") + (level (name "world1/level20.stl") (x 20) (y 25)) - (level (name "Level 21") + (level (name "world1/level21.stl") (x 18) (y 23)) - (level (name "Level 22") + (level (name "world1/level22.stl") (x 19) (y 20)) - (level (name "Level 23") + (level (name "world1/level23.stl") (x 14) (y 24)) - (level (name "Level 24") + (level (name "world1/level24.stl") (x 14) (y 20)) (level (name "Level 25") |
From: Ricardo C. <rm...@us...> - 2004-04-17 15:36:21
|
Update of /cvsroot/super-tux/supertux/data/levels/world1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21301/data/levels/world1 Log Message: Directory /cvsroot/super-tux/supertux/data/levels/world1 added to the repository |
From: Ricardo C. <rm...@us...> - 2004-04-17 15:22:02
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18703/src Modified Files: physic.cpp physic.h Log Message: Added inverse functions for speed. Might be usefull for someone that wants to make enemies to change directions when colliding with each other. Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- physic.h 11 Apr 2004 15:28:26 -0000 1.9 +++ physic.h 17 Apr 2004 15:21:50 -0000 1.10 @@ -28,6 +28,10 @@ /** sets velocity to a fixed value */ void set_velocity(float vx, float vy); + /** velocities invertion */ + void inverse_velocity_x(); + void inverse_velocity_y(); + float get_velocity_x(); float get_velocity_y(); Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- physic.cpp 11 Apr 2004 15:28:26 -0000 1.7 +++ physic.cpp 17 Apr 2004 15:21:50 -0000 1.8 @@ -41,6 +41,16 @@ vy = -nvy; } +void Physic::inverse_velocity_x() +{ +vx = -vx; +} + +void Physic::inverse_velocity_y() +{ +vy = -vy; +} + float Physic::get_velocity_x() { |
From: Ingo R. <gr...@us...> - 2004-04-17 14:18:10
|
Update of /cvsroot/super-tux/supertux/data/levels/default In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6168 Modified Files: worldmap.stwm Log Message: sik0fewl's worldmap patch Index: worldmap.stwm =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/default/worldmap.stwm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- worldmap.stwm 15 Apr 2004 19:08:01 -0000 1.7 +++ worldmap.stwm 17 Apr 2004 14:18:00 -0000 1.8 @@ -8,32 +8,113 @@ 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 12 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 16 12 11 16 16 16 16 12 9 9 9 9 11 16 16 12 9 9 14 13 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 16 16 16 22 19 17 15 24 25 25 26 23 16 12 9 9 14 18 18 13 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 - 9 9 11 22 19 4 19 20 18 13 15 31 32 32 34 26 19 23 16 12 9 9 9 9 9 9 11 16 16 16 16 12 9 9 9 9 9 9 9 9 + 9 9 11 22 19 47 19 20 18 13 15 31 32 32 34 26 19 23 16 12 9 9 9 9 9 9 11 16 16 16 16 12 9 9 9 9 9 9 9 9 9 9 15 19 48 42 20 13 9 9 15 31 35 29 29 28 19 19 19 23 16 12 9 9 9 11 22 19 24 25 26 23 12 11 16 16 12 9 9 9 - 9 9 15 19 47 19 17 11 16 16 22 30 28 19 48 40 4 40 39 20 18 13 9 9 11 22 19 19 30 36 34 26 23 22 19 19 23 12 9 9 - 9 9 15 19 4 19 23 22 19 19 19 19 24 26 47 19 19 19 47 23 16 16 16 16 22 48 4 40 39 31 32 34 25 25 25 25 26 17 9 9 - 9 9 15 19 37 39 19 4 40 40 40 39 30 28 41 40 4 40 44 40 40 4 40 40 40 42 19 19 47 30 29 29 29 29 29 36 27 17 9 9 - 9 9 15 19 19 47 19 47 24 25 26 4 40 40 4 24 25 25 26 20 18 18 18 21 24 25 25 26 4 40 40 4 40 40 39 31 27 23 12 9 + 9 9 15 19 47 19 17 11 16 16 22 30 28 19 48 40 40 40 39 20 18 13 9 9 11 22 19 19 30 36 34 26 23 22 19 19 23 12 9 9 + 9 9 15 19 47 19 23 22 19 19 19 19 24 26 47 19 19 19 47 23 16 16 16 16 22 48 40 40 39 31 32 34 25 25 25 25 26 17 9 9 + 9 9 15 19 37 39 19 48 40 40 40 39 30 28 41 40 40 40 44 40 40 40 40 40 40 42 19 19 47 30 29 29 29 29 29 36 27 17 9 9 + 9 9 15 19 19 47 19 47 24 25 26 37 40 40 42 24 25 25 26 20 18 18 18 21 24 25 25 26 37 40 40 40 40 40 39 31 27 23 12 9 9 9 14 18 21 47 19 47 30 29 28 19 24 25 25 33 35 29 28 17 9 9 9 15 30 29 36 27 19 19 19 19 19 19 47 31 34 26 17 9 - 9 9 9 9 15 4 40 4 19 19 24 25 33 35 29 29 28 20 18 13 9 9 9 14 18 21 31 27 48 4 40 40 40 40 4 30 36 27 17 9 + 9 9 9 9 15 37 40 42 19 19 24 25 33 35 29 29 28 20 18 13 9 9 9 14 18 21 31 27 48 40 40 40 40 40 42 30 36 27 17 9 9 9 9 9 15 19 19 24 25 25 33 32 35 28 20 18 18 13 9 9 9 9 9 9 9 15 31 27 47 24 25 25 25 26 19 19 30 28 17 9 - 9 9 9 9 14 21 19 31 32 32 32 35 28 20 13 9 9 11 16 12 9 9 9 9 9 15 30 28 4 30 36 32 35 28 20 21 19 20 13 9 + 9 9 9 9 14 21 19 31 32 32 32 35 28 20 13 9 9 11 16 12 9 9 9 9 9 15 30 28 47 30 36 32 35 28 20 21 19 20 13 9 9 9 11 12 9 14 21 30 29 29 29 28 20 13 9 11 16 22 20 13 9 9 9 9 9 14 21 19 37 39 31 32 27 20 13 14 21 17 9 9 9 9 14 13 11 12 14 18 18 18 18 18 13 9 9 14 18 18 13 9 9 9 9 9 9 9 14 21 19 47 30 36 27 17 9 9 14 13 9 9 - 9 9 9 9 14 13 9 9 9 9 11 16 16 16 12 9 9 11 16 12 9 9 9 9 9 9 9 14 21 4 19 31 27 17 9 9 9 9 9 9 + 9 9 9 9 14 13 9 9 9 9 11 16 16 16 12 9 9 11 16 12 9 9 9 9 9 9 9 14 21 47 19 31 27 17 9 9 9 9 9 9 9 9 9 9 9 9 9 11 16 16 22 24 25 26 23 16 16 22 19 23 16 16 12 9 9 9 9 9 15 47 19 30 28 17 9 9 9 9 9 9 9 9 9 11 16 16 16 22 19 19 19 30 36 34 25 26 19 24 25 25 25 26 23 16 16 16 16 16 22 47 20 18 18 13 9 9 9 9 9 9 - 9 9 9 15 24 25 26 19 19 19 19 19 30 29 29 28 19 30 29 29 36 34 25 26 19 19 48 4 40 42 17 9 9 9 9 9 9 9 9 9 - 9 9 9 15 31 32 27 4 40 39 19 48 40 40 4 19 48 40 40 4 30 29 29 28 19 19 47 20 18 18 13 9 9 9 9 9 9 9 9 9 + 9 9 9 15 24 25 26 19 19 19 19 19 30 29 29 28 19 30 29 29 36 34 25 26 19 19 48 40 40 42 17 9 9 9 9 9 9 9 9 9 + 9 9 9 15 31 32 27 40 40 39 19 48 40 40 39 19 48 40 40 39 30 29 29 28 19 19 47 20 18 18 13 9 9 9 9 9 9 9 9 9 9 9 9 15 30 36 34 26 19 47 19 47 19 19 47 19 47 19 19 47 19 19 19 48 40 40 42 23 12 9 9 9 9 11 12 9 9 9 9 9 - 9 9 9 14 21 30 29 28 19 37 4 42 19 19 47 19 47 19 19 47 19 19 19 4 19 19 24 26 17 9 9 9 9 14 13 9 9 9 9 9 - 9 9 9 9 14 18 18 18 21 19 19 19 19 19 47 19 47 19 4 42 19 19 48 42 24 25 33 27 17 9 9 9 9 9 9 9 9 9 9 9 - 9 9 9 9 9 9 9 9 14 21 19 24 25 26 4 40 42 19 47 19 19 19 47 19 30 29 36 27 17 9 9 9 9 9 9 9 9 9 9 9 - 9 9 9 11 12 9 9 9 9 14 21 30 36 34 25 26 19 19 37 40 4 40 42 19 20 21 30 28 17 9 9 11 16 16 12 9 9 9 9 9 + 9 9 9 14 21 30 29 28 19 37 40 42 19 19 47 19 47 19 19 47 19 19 19 47 19 19 24 26 17 9 9 9 9 14 13 9 9 9 9 9 + 9 9 9 9 14 18 18 18 21 19 19 19 19 19 47 19 47 19 48 42 19 19 48 42 24 25 33 27 17 9 9 9 9 9 9 9 9 9 9 9 + 9 9 9 9 9 9 9 9 14 21 19 24 25 26 37 40 42 19 47 19 19 19 47 19 30 29 36 27 17 9 9 9 9 9 9 9 9 9 9 9 + 9 9 9 11 12 9 9 9 9 14 21 30 36 34 25 26 19 19 37 40 40 40 42 19 20 21 30 28 17 9 9 11 16 16 12 9 9 9 9 9 9 9 9 14 13 9 9 9 9 9 14 21 31 32 32 34 25 25 25 25 26 19 19 20 13 14 18 18 13 9 9 14 21 19 23 12 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 15 30 29 29 29 29 29 29 29 28 19 20 13 11 12 9 9 9 9 9 9 14 18 18 13 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 14 18 18 18 18 18 18 18 18 18 18 13 9 14 13 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 )) + + (levels + (level (name "default/level1.stl") + (x 5) + (y 4)) + (level (name "default/level2.stl") + (x 4) + (y 7)) + (level (name "default/level3.stl") + (x 5) + (y 11)) + (level (name "Level 4") + (x 7) + (y 11)) + (level (name "Level 5") + (x 7) + (y 8)) + (level (name "Level 6") + (x 11) + (y 9)) + (level (name "Level 7") + (x 14) + (y 9)) + (level (name "Level 8") + (x 16) + (y 8)) + (level (name "Level 9") + (x 16) + (y 6)) + (level (name "Level 10") + (x 21) + (y 8)) + (level (name "Level 11") + (x 26) + (y 7)) + (level (name "Level 12") + (x 28) + (y 9)) + (level (name "Level 13") + (x 31) + (y 9)) + (level (name "Level 14") + (x 34) + (y 11)) + (level (name "Level 15") + (x 29) + (y 11)) + (level (name "Level 16") + (x 28) + (y 13)) + (level (name "Level 17") + (x 29) + (y 16)) + (level (name "Level 18") + (x 27) + (y 19)) + (level (name "Level 19") + (x 23) + (y 22)) + (level (name "Level 20") + (x 20) + (y 25)) + (level (name "Level 21") + (x 18) + (y 23)) + (level (name "Level 22") + (x 19) + (y 20)) + (level (name "Level 23") + (x 14) + (y 24)) + (level (name "Level 24") + (x 14) + (y 20)) + (level (name "Level 25") + (x 10) + (y 22)) + (level (name "Level 26") + (x 7) + (y 20)) + ) ) |
From: Ingo R. <gr...@us...> - 2004-04-17 14:14:02
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5424 Modified Files: worldmap.cpp worldmap.h Log Message: sik0fewl's worldmap patch Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- worldmap.cpp 17 Apr 2004 13:56:48 -0000 1.28 +++ worldmap.cpp 17 Apr 2004 14:13:53 -0000 1.29 @@ -181,7 +181,7 @@ { // We reached the next tile, so we check what to do now offset -= 32; - if (worldmap->at(tile_pos)->stop) + if (worldmap->at(tile_pos)->stop || worldmap->at_level()) { stop(); } @@ -490,6 +490,20 @@ return TileManager::instance()->get(tilemap[width * p.y + p.x]); } +bool +WorldMap::at_level() +{ + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (i->x == tux->get_tile_pos().x && + i->y == tux->get_tile_pos().y) + return true; + } + + return false; +} + + void WorldMap::draw(const Point& offset) { Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- worldmap.h 17 Apr 2004 13:56:48 -0000 1.17 +++ worldmap.h 17 Apr 2004 14:13:53 -0000 1.18 @@ -166,6 +166,7 @@ Point get_next_tile(Point pos, Direction direction); Tile* at(Point pos); + bool at_level(); /** Check if it is possible to walk from \a pos into \a direction, if possible, write the new position to \a new_pos */ |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1518 Modified Files: gameloop.cpp gameloop.h player.cpp scene.h title.cpp world.cpp world.h worldmap.cpp worldmap.h Log Message: - changed/clean up level end detection a bit, still not really as it should be Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- world.h 13 Apr 2004 12:25:22 -0000 1.22 +++ world.h 17 Apr 2004 13:56:48 -0000 1.23 @@ -58,6 +58,8 @@ static World* current() { return current_; } static void set_current(World* w) { current_ = w; } + World(const std::string& filename); + World(const std::string& subset, int level_nr); World(); ~World(); @@ -74,16 +76,6 @@ case (or not). */ void collision_handler(); - void arrays_free(); - - /** Load data for this level: - Returns -1, if the loading of the level failed. */ - int load(const std::string& subset, int level); - - /** Load data for this level: - Returns -1, if the loading of the level failed. */ - int load(const std::string& filename); - void activate_particle_systems(); void activate_bad_guys(); Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- gameloop.h 16 Apr 2004 16:52:17 -0000 1.39 +++ gameloop.h 17 Apr 2004 13:56:47 -0000 1.40 @@ -24,6 +24,7 @@ #define ST_GL_TEST 1 #define ST_GL_LOAD_GAME 2 #define ST_GL_LOAD_LEVEL_FILE 3 +#define ST_GL_DEMO_GAME 4 extern int game_started; @@ -35,12 +36,11 @@ class GameSession { private: - bool quit; Timer fps_timer; Timer frame_timer; World* world; int st_gl_mode; - + int levelnb; float fps_fps; unsigned int last_update_time; unsigned int update_time; @@ -50,21 +50,20 @@ // FIXME: Hack for restarting the level std::string subset; - int levelnb; + enum ExitStatus { NONE, LEVEL_FINISHED, GAME_OVER, LEVEL_ABORT }; + ExitStatus exit_status; public: Timer time_left; - GameSession(); - GameSession(const std::string& filename); GameSession(const std::string& subset, int levelnb, int mode); ~GameSession(); /** Enter the busy loop */ - int run(); + ExitStatus run(); void draw(); - int action(double frame_ratio); + void action(double frame_ratio); Level* get_level() { return world->get_level(); } World* get_world() { return world; } @@ -73,8 +72,9 @@ private: static GameSession* current_; - void init(); + void restart_level(); + void check_end_conditions(); void start_timers(); void process_events(); Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- player.cpp 16 Apr 2004 16:52:17 -0000 1.38 +++ player.cpp 17 Apr 2004 13:56:47 -0000 1.39 @@ -281,13 +281,6 @@ play_current_music(); } - /* End of level? */ - if (base.x >= World::current()->get_level()->endpos - && World::current()->get_level()->endpos != 0) - { - player_status.next_level = 1; - } - // check some timers skidding_timer.check(); invincible_timer.check(); @@ -822,9 +815,6 @@ void Player::is_dying() { - /* He died :^( */ - - --player_status.lives; remove_powerups(); dying = DYING_NOT; } Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- title.cpp 17 Apr 2004 00:49:54 -0000 1.43 +++ title.cpp 17 Apr 2004 13:56:48 -0000 1.44 @@ -230,7 +230,7 @@ st_pause_ticks_init(); - GameSession session(datadir + "/levels/misc/menu.stl"); + GameSession session(datadir + "/levels/misc/menu.stl", 0, ST_GL_DEMO_GAME); //FIXME:activate_particle_systems(); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- worldmap.cpp 17 Apr 2004 00:49:54 -0000 1.27 +++ worldmap.cpp 17 Apr 2004 13:56:48 -0000 1.28 @@ -206,7 +206,6 @@ { tux = new Tux(this); - quit = false; width = 20; height = 15; @@ -309,7 +308,7 @@ switch(event.type) { case SDL_QUIT: - quit = true; + st_abort("Received window close", ""); break; case SDL_KEYDOWN: Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- world.cpp 16 Apr 2004 14:50:41 -0000 1.26 +++ world.cpp 17 Apr 2004 13:56:48 -0000 1.27 @@ -33,7 +33,7 @@ World* World::current_ = 0; -World::World() +World::World(const std::string& filename) { // FIXME: Move this to action and draw and everywhere else where the // world calls child functions @@ -41,6 +41,32 @@ level = new Level; tux.init(); + + level->load(filename); + set_defaults(); + + get_level()->load_gfx(); + activate_bad_guys(); + activate_particle_systems(); + get_level()->load_song(); +} + +World::World(const std::string& subset, int level_nr) +{ + // FIXME: Move this to action and draw and everywhere else where the + // world calls child functions + current_ = this; + + level = new Level; + tux.init(); + + level->load(subset, level_nr); + set_defaults(); + + get_level()->load_gfx(); + activate_bad_guys(); + activate_particle_systems(); + get_level()->load_song(); } World::~World() @@ -63,35 +89,6 @@ set_current_music(LEVEL_MUSIC); } -int -World::load(const std::string& subset, int level_nr) -{ - return level->load(subset, level_nr); -} - -int -World::load(const std::string& filename) -{ - return level->load(filename); -} - -void -World::arrays_free(void) -{ - bad_guys.clear(); - bouncy_distros.clear(); - broken_bricks.clear(); - bouncy_bricks.clear(); - floating_scores.clear(); - upgrades.clear(); - bullets.clear(); - std::vector<ParticleSystem*>::iterator i; - for(i = particle_systems.begin(); i != particle_systems.end(); ++i) { - delete *i; - } - particle_systems.clear(); -} - void World::activate_bad_guys() { Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- scene.h 16 Apr 2004 16:52:18 -0000 1.24 +++ scene.h 17 Apr 2004 13:56:48 -0000 1.25 @@ -25,7 +25,6 @@ int distros; int lives; - int next_level; int score_multiplier; PlayerStatus(); Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- worldmap.h 17 Apr 2004 00:49:54 -0000 1.16 +++ worldmap.h 17 Apr 2004 13:56:48 -0000 1.17 @@ -114,12 +114,12 @@ private: Tux* tux; + bool quit; + Surface* level_sprite; Surface* leveldot_green; Surface* leveldot_red; - bool quit; - std::string name; std::string music; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- gameloop.cpp 17 Apr 2004 00:49:54 -0000 1.73 +++ gameloop.cpp 17 Apr 2004 13:56:47 -0000 1.74 @@ -46,77 +46,46 @@ GameSession* GameSession::current_ = 0; -void -GameSession::init() -{ - game_pause = false; -} - -GameSession::GameSession() -{ - current_ = this; - assert(0); -} - -GameSession::GameSession(const std::string& filename) +GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) + : world(0), st_gl_mode(mode), levelnb(levelnb_), subset(subset_) { - init(); - - //assert(!"Don't call me"); current_ = this; - - world = new World; - - fps_timer.init(true); - frame_timer.init(true); - - world->load(filename); + restart_level(); } -GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) - : subset(subset_), - levelnb(levelnb_) +void +GameSession::restart_level() { - init(); - - current_ = this; - - world = new World; + game_pause = false; + exit_status = NONE; fps_timer.init(true); frame_timer.init(true); - st_gl_mode = mode; - - /* Init the game: */ - world->arrays_free(); - world->set_defaults(); - if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) { - if (world->load(subset)) - exit(1); + world = new World(subset); + } + else if (st_gl_mode == ST_GL_DEMO_GAME) + { + world = new World(subset); } else { - if(world->load(subset, levelnb) != 0) - exit(1); + world = new World(subset, levelnb); } + + if (st_gl_mode != ST_GL_DEMO_GAME) + { + if(st_gl_mode != ST_GL_TEST) + load_hs(); - world->get_level()->load_gfx(); - - world->activate_bad_guys(); - world->activate_particle_systems(); - world->get_level()->load_song(); - - if(st_gl_mode != ST_GL_TEST) - load_hs(); - - if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE) - levelintro(); + if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE) + levelintro(); + } time_left.init(true); - start_timers(); + start_timers(); } GameSession::~GameSession() @@ -131,14 +100,11 @@ /* Level Intro: */ clearscreen(0, 0, 0); - sprintf(str, "LEVEL %d", levelnb); - blue_text->drawf(str, 0, 200, A_HMIDDLE, A_TOP, 1); - sprintf(str, "%s", world->get_level()->name.c_str()); - gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1); + gold_text->drawf(str, 0, 200, A_HMIDDLE, A_TOP, 1); sprintf(str, "TUX x %d", player_status.lives); - white_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1); + white_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1); sprintf(str, "by %s", world->get_level()->author.c_str()); white_small_text->drawf(str, 0, 400, A_HMIDDLE, A_TOP, 1); @@ -174,8 +140,9 @@ switch(event.type) { case SDL_QUIT: /* Quit event - quit: */ - quit = true; + st_abort("Received window close", ""); break; + case SDL_KEYDOWN: /* A keypress! */ { SDLKey key = event.key.keysym.sym; @@ -189,7 +156,9 @@ if(!game_pause) { if(st_gl_mode == ST_GL_TEST) - quit = true; + { + exit_status = LEVEL_ABORT; + } else if(show_menu) { Menu::set_current(game_menu); @@ -249,10 +218,6 @@ if(debug_mode) player_status.distros += 50; break; - case SDLK_SPACE: - if(debug_mode) - player_status.next_level = 1; - break; case SDLK_DELETE: if(debug_mode) tux.got_coffee = 1; @@ -335,100 +300,58 @@ } /* while */ } -int -GameSession::action(double frame_ratio) + +void +GameSession::check_end_conditions() { - Player& tux = *world->get_tux(); + Player* tux = world->get_tux(); - if (tux.is_dead() || player_status.next_level) + /* End of level? */ + if (tux->base.x >= World::current()->get_level()->endpos + && World::current()->get_level()->endpos != 0) { - /* Tux either died, or reached the end of a level! */ - halt_music(); - - if (player_status.next_level) - { - /* End of a level! */ - levelnb++; - player_status.next_level = 0; - if(st_gl_mode != ST_GL_TEST) - { - drawresultscreen(); - } - else - { - world->get_level()->free_gfx(); - world->get_level()->cleanup(); - world->get_level()->free_song(); - world->arrays_free(); - - return(0); - } - tux.level_begin(); - } - else + exit_status = LEVEL_FINISHED; + } + else + { + // Check End conditions + if (tux->is_dead()) { - tux.is_dying(); - - /* No more lives!? */ - + if (player_status.lives < 0) - { + { // No more lives!? if(st_gl_mode != ST_GL_TEST) drawendscreen(); - + if(st_gl_mode != ST_GL_TEST) { if (player_status.score > hs_score) save_hs(player_status.score); } - - world->get_level()->free_gfx(); - world->get_level()->cleanup(); - world->get_level()->free_song(); - world->arrays_free(); - - return(0); - } /* if (lives < 0) */ + + exit_status = GAME_OVER; + } + else + { // Still has lives, so reset Tux to the levelstart + restart_level(); + } } + } +} - /* Either way, (re-)load the (next) level... */ - tux.level_begin(); - world->set_defaults(); +void +GameSession::action(double frame_ratio) +{ + check_end_conditions(); + + if (exit_status == NONE) + { + Player* tux = world->get_tux(); - world->get_level()->cleanup(); - - if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) - { - if(world->get_level()->load(subset) != 0) - return 0; - } - else - { - if(world->get_level()->load(subset, levelnb) != 0) - return 0; - } - - world->arrays_free(); - world->activate_bad_guys(); - world->activate_particle_systems(); - - world->get_level()->free_gfx(); - world->get_level()->load_gfx(); - world->get_level()->free_song(); - world->get_level()->load_song(); - - if(st_gl_mode != ST_GL_TEST) - levelintro(); - start_timers(); - /* Play music: */ - play_current_music(); + // Update Tux and the World + tux->action(frame_ratio); + world->action(frame_ratio); } - - tux.action(frame_ratio); - - world->action(frame_ratio); - - return -1; } void @@ -458,14 +381,13 @@ } -int +GameSession::ExitStatus GameSession::run() { - Player& tux = *world->get_tux(); + Player* tux = world->get_tux(); current_ = this; int fps_cnt; - bool done; global_frame_counter = 0; game_pause = false; @@ -489,9 +411,7 @@ draw(); - done = false; - quit = false; - while (!done && !quit) + while (exit_status == NONE) { /* Calculate the movement-factor */ double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); @@ -505,7 +425,7 @@ } /* Handle events: */ - tux.input.old_fire = tux.input.fire; + tux->input.old_fire = tux->input.fire; process_events(); @@ -527,7 +447,7 @@ break; case 7: st_pause_ticks_stop(); - done = true; + exit_status = LEVEL_ABORT; break; } } @@ -540,24 +460,13 @@ process_load_game_menu(); } } - - - /* Handle actions: */ - + + // Handle actions: if(!game_pause && !show_menu) { - /*float z = frame_ratio; - frame_ratio = 1; - while(z >= 1) - {*/ - if (action(frame_ratio) == 0) - { - /* == 0: no more lives */ - /* == -1: continues */ - return 0; - } - /* --z; - }*/ + action(frame_ratio); + if (exit_status != NONE) + return exit_status; } else { @@ -603,15 +512,14 @@ { /* are we low on time ? */ if (time_left.get_left() < TIME_WARNING - && (get_current_music() != HURRYUP_MUSIC)) /* play the fast music */ + && (get_current_music() != HURRYUP_MUSIC)) /* play the fast music */ { set_current_music(HURRYUP_MUSIC); play_current_music(); } - } - else if(tux.dying == DYING_NOT) - tux.kill(KILL); + else if(tux->dying == DYING_NOT) + tux->kill(KILL); /* Calculate frames per second */ if(show_fps) @@ -633,9 +541,7 @@ world->get_level()->cleanup(); world->get_level()->free_song(); - world->arrays_free(); - - return quit; + return exit_status; } /* Bounce a brick: */ |
From: Ingo R. <gr...@us...> - 2004-04-17 13:29:48
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28725 Modified Files: leveleditor.cpp Log Message: - removed level editors dependency on the World class Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- leveleditor.cpp 13 Apr 2004 12:25:22 -0000 1.48 +++ leveleditor.cpp 17 Apr 2004 13:29:38 -0000 1.49 @@ -24,7 +24,6 @@ #include <SDL_image.h> #include "leveleditor.h" -#include "world.h" #include "screen.h" #include "defines.h" #include "globals.h" @@ -79,13 +78,41 @@ void update_subset_settings_menu(); void save_subset_settings_menu(); +static Level* le_current_level; + +struct LevelEditorWorld +{ + std::vector<BadGuy> bad_guys; + void arrays_free(void) + { + bad_guys.clear(); + } + + void add_bad_guy(float x, float y, BadGuyKind kind) + { + bad_guys.push_back(BadGuy()); + BadGuy& new_bad_guy = bad_guys.back(); + + new_bad_guy.init(x,y,kind); + } + + void activate_bad_guys() + { + for (std::vector<BadGuyData>::iterator i = le_current_level->badguy_data.begin(); + i != le_current_level->badguy_data.end(); + ++i) + { + add_bad_guy(i->x, i->y, i->kind); + } + } +}; + /* leveleditor internals */ static string_list_type level_subsets; static bool le_level_changed; /* if changes, ask for saving, when quiting*/ static int pos_x, cursor_x, cursor_y, fire; static int le_level; -static Level* le_current_level; -static World le_world; +static LevelEditorWorld le_world; static st_subset le_level_subset; static int le_show_grid; static int le_frame; |
From: Ingo R. <gr...@us...> - 2004-04-17 12:13:51
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16259/data Modified Files: supertux.strf Log Message: - fixed some bugs in the resource file Index: supertux.strf =================================================================== RCS file: /cvsroot/super-tux/supertux/data/supertux.strf,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- supertux.strf 17 Apr 2004 10:48:03 -0000 1.1 +++ supertux.strf 17 Apr 2004 12:13:42 -0000 1.2 @@ -29,6 +29,12 @@ (sprite (name "bsod-squished-right") (images "shared/bsod-squished-right.png")) + (sprite (name "snowball-squished-left") + (images "shared/bsod-squished-left.png")) + + (sprite (name "snowball-squished-right") + (images "shared/bsod-squished-right.png")) + (sprite (name "bsod-falling-left") (images "shared/bsod-falling-left.png")) @@ -59,11 +65,11 @@ (sprite (name "laptop-falling-right") (images "shared/laptop-falling-right.png")) - (sprite (name "img-jumpy-left-up") + (sprite (name "jumpy-left-up") (images "shared/jumpy-left-up-0.png")) - (sprite (name "img-jumpy-left-down") + (sprite (name "jumpy-left-down") (images "shared/jumpy-left-down-0.png")) - (sprite (name "img-jumpy-middle-up") + (sprite (name "jumpy-left-middle") (images "shared/jumpy-left-middle-0.png")) (sprite (name "mrbomb-left") @@ -102,7 +108,7 @@ (images "shared/fish-left-0.png" "shared/fish-left-1.png")) - (sprite (name "fish") + (sprite (name "fish-down") (images "shared/fish-down-0.png")) (sprite (name "bouncingsnowball-left") @@ -152,11 +158,6 @@ "shared/snowball-right-2.png" "shared/snowball-right-1.png")) - (sprite (name "bsod-squished-left") - (images "shared/bsod-squished-left.png")) - - (sprite (name "bsod-squished-right") - (images "shared/bsod-squished-right.png")) ) ;; EOF ;; |
From: Ricardo C. <rm...@us...> - 2004-04-17 12:00:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14086/src Modified Files: badguy.cpp Log Message: Applied patch from Ryan: « This patch causes badguys to be killed when they run into an exploding bomb or get hit by stalactite (as suggested by Ricardo). » Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- badguy.cpp 17 Apr 2004 10:48:04 -0000 1.35 +++ badguy.cpp 17 Apr 2004 12:00:31 -0000 1.36 @@ -973,6 +973,27 @@ pbad_c->kill_me(); kill_me(); } + + /* Kill badguys that run into exploding bomb */ + else if (kind == BAD_BOMB && dying == DYING_NOT) + { + if (pbad_c->kind == BAD_MRBOMB) + { + // FIXME: this is where other MrBombs *should* explode istead of dying + pbad_c->kill_me(); + } + else if (pbad_c->kind != BAD_BOMB) + { + pbad_c->kill_me(); + } + } + + /* Kill any badguys that get hit by stalactite */ + else if (kind == BAD_STALACTITE && dying == DYING_NOT) + { + pbad_c->kill_me(); + } + break; } } |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3202/src Modified Files: Makefile.am badguy.cpp badguy.h resources.cpp resources.h sprite.cpp sprite.h Added Files: sprite_manager.cpp sprite_manager.h Log Message: - moved badguys to use sprite class Index: resources.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- resources.h 13 Apr 2004 02:19:13 -0000 1.4 +++ resources.h 17 Apr 2004 10:48:04 -0000 1.5 @@ -1,6 +1,8 @@ #ifndef SUPERTUX_RESOURCES_H #define SUPERTUX_RESOURCES_H +class SpriteManager; + extern Surface* img_waves[3]; extern Surface* img_water; extern Surface* img_pole; @@ -13,6 +15,8 @@ extern Surface* img_super_bkgd; extern Surface* img_red_glow; +extern SpriteManager* sprite_manager; + void loadshared(); void unloadshared(); Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Makefile.am 13 Apr 2004 02:19:13 -0000 1.17 +++ Makefile.am 17 Apr 2004 10:48:03 -0000 1.18 @@ -67,6 +67,8 @@ gameobjs.h \ gameobjs.cpp \ sprite.h \ -sprite.cpp +sprite.cpp \ +sprite_manager.cpp \ +sprite_manager.h # EOF # --- NEW FILE: sprite_manager.cpp --- // $Id: sprite_manager.cpp,v 1.1 2004/04/17 10:48:04 grumbel Exp $ // // Pingus - A free Lemmings clone // Copyright (C) 2002 Ingo Ruhnke <gr...@gm...> // // 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 <iostream> #include "lispreader.h" #include "sprite_manager.h" SpriteManager::SpriteManager(const std::string& filename) { load_resfile(filename); } void SpriteManager::load_resfile(const std::string& filename) { lisp_object_t* cur = lisp_read_from_file(filename); if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-resources") != 0) 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)); 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; } cur = lisp_cdr(cur); } } Sprite* SpriteManager::load(const std::string& name) { Sprites::iterator i = sprites.find(name); if (i != sprites.end()) { return i->second; } else { std::cout << "SpriteManager: Sprite '" << name << "' not found" << std::endl; return 0; } } /* EOF */ Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- sprite.h 13 Apr 2004 12:25:22 -0000 1.3 +++ sprite.h 17 Apr 2004 10:48:04 -0000 1.4 @@ -28,6 +28,8 @@ class Sprite { private: + std::string name; + int x_hotspot; int y_hotspot; @@ -47,10 +49,18 @@ /** cur has to be a pointer to data in the form of ((x-hotspot 5) (y-hotspot 10) ...) */ Sprite(lisp_object_t* cur); + + void reset(); /** Update the sprite and process to the next frame */ void update(float delta); - void draw(int x, int y); + void draw(float x, float y); + + int get_current_frame() const; + + std::string get_name() const { return name; } + int get_width() const; + int get_height() const; }; #endif Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- badguy.h 16 Apr 2004 21:16:12 -0000 1.25 +++ badguy.h 17 Apr 2004 10:48:04 -0000 1.26 @@ -20,13 +20,11 @@ #include "texture.h" #include "physic.h" #include "collision.h" +#include "sprite.h" -extern Surface* img_bsod_left[4]; -extern Surface* img_bsod_right[4]; -extern Surface* img_laptop_left[4]; -extern Surface* img_jumpy_left_up; -extern Surface* img_jumpy_left_down; -extern Surface* img_jumpy_left_middle; +extern Sprite* img_bsod_left; +extern Sprite* img_bsod_right; +extern Sprite* img_laptop_left; /* Enemy modes: */ enum { @@ -101,8 +99,9 @@ Timer timer; Physic physic; - Surface** texture_left; - Surface** texture_right; + Sprite* sprite_left; + Sprite* sprite_right; + int animation_offset; size_t animation_length; float animation_speed; @@ -156,7 +155,7 @@ /** squish ourself, give player score and set dying to DYING_SQICHED */ void squish_me(Player* player); /** set image of the badguy */ - void set_texture(Surface** left, Surface** right, + void set_sprite(Sprite* left, Sprite* right, int animlength = 1, float animspeed = 1); }; Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- badguy.cpp 16 Apr 2004 21:16:12 -0000 1.34 +++ badguy.cpp 17 Apr 2004 10:48:04 -0000 1.35 @@ -20,43 +20,45 @@ #include "screen.h" #include "world.h" #include "tile.h" +#include "resources.h" +#include "sprite_manager.h" -Surface* img_bsod_squished_left[1]; -Surface* img_bsod_squished_right[1]; -Surface* img_bsod_falling_left[1]; -Surface* img_bsod_falling_right[1]; -Surface* img_laptop_flat_left[1]; -Surface* img_laptop_flat_right[1]; -Surface* img_laptop_falling_left[1]; -Surface* img_laptop_falling_right[1]; -Surface* img_bsod_left[4]; -Surface* img_bsod_right[4]; -Surface* img_laptop_left[4]; -Surface* img_laptop_right[4]; -Surface* img_jumpy_left_up; -Surface* img_jumpy_left_down; -Surface* img_jumpy_left_middle; -Surface* img_mrbomb_left[4]; -Surface* img_mrbomb_right[4]; -Surface* img_mrbomb_ticking_left[1]; -Surface* img_mrbomb_ticking_right[1]; -Surface* img_mrbomb_explosion[1]; -Surface* img_stalactite[1]; -Surface* img_stalactite_broken[1]; -Surface* img_flame[2]; -Surface* img_fish[2]; -Surface* img_fish_down[1]; -Surface* img_bouncingsnowball_left[6]; -Surface* img_bouncingsnowball_right[6]; -Surface* img_bouncingsnowball_squished[1]; -Surface* img_flyingsnowball[2]; -Surface* img_flyingsnowball_squished[1]; -Surface* img_spiky_left[3]; -Surface* img_spiky_right[3]; -Surface* img_snowball_left[4]; -Surface* img_snowball_right[4]; -Surface* img_snowball_squished_left[1]; -Surface* img_snowball_squished_right[1]; +Sprite* img_bsod_squished_left; +Sprite* img_bsod_squished_right; +Sprite* img_bsod_falling_left; +Sprite* img_bsod_falling_right; +Sprite* img_laptop_flat_left; +Sprite* img_laptop_flat_right; +Sprite* img_laptop_falling_left; +Sprite* img_laptop_falling_right; +Sprite* img_bsod_left; +Sprite* img_bsod_right; +Sprite* img_laptop_left; +Sprite* img_laptop_right; +Sprite* img_jumpy_left_up; +Sprite* img_jumpy_left_down; +Sprite* img_jumpy_left_middle; +Sprite* img_mrbomb_left; +Sprite* img_mrbomb_right; +Sprite* img_mrbomb_ticking_left; +Sprite* img_mrbomb_ticking_right; +Sprite* img_mrbomb_explosion; +Sprite* img_stalactite; +Sprite* img_stalactite_broken; +Sprite* img_flame; +Sprite* img_fish; +Sprite* img_fish_down; +Sprite* img_bouncingsnowball_left; +Sprite* img_bouncingsnowball_right; +Sprite* img_bouncingsnowball_squished; +Sprite* img_flyingsnowball; +Sprite* img_flyingsnowball_squished; +Sprite* img_spiky_left; +Sprite* img_spiky_right; +Sprite* img_snowball_left; +Sprite* img_snowball_right; +Sprite* img_snowball_squished_left; +Sprite* img_snowball_squished_right; BadGuyKind badguykind_from_string(const std::string& str) { @@ -150,47 +152,47 @@ animation_speed = 1; animation_length = 1; animation_offset = 0; - texture_left = texture_right = 0; + sprite_left = sprite_right = 0; physic.reset(); timer.init(true); if(kind == BAD_BSOD) { physic.set_velocity(-1.3, 0); - set_texture(img_bsod_left, img_bsod_right, 4); + set_sprite(img_bsod_left, img_bsod_right, 4); } else if(kind == BAD_MRBOMB) { physic.set_velocity(-1.3, 0); - set_texture(img_mrbomb_left, img_mrbomb_right, 4); + set_sprite(img_mrbomb_left, img_mrbomb_right, 4); } else if (kind == BAD_LAPTOP) { physic.set_velocity(-1.3, 0); - set_texture(img_laptop_left, img_laptop_right, 4, 5); + set_sprite(img_laptop_left, img_laptop_right, 4, 5); } else if(kind == BAD_MONEY) { - set_texture(&img_jumpy_left_up, &img_jumpy_left_up, 1); + set_sprite(img_jumpy_left_up, img_jumpy_left_up, 1); } else if(kind == BAD_BOMB) { - set_texture(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1); + set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1); // hack so that the bomb doesn't hurt until it expldes... dying = DYING_SQUISHED; } else if(kind == BAD_FLAME) { base.ym = 0; // we misuse base.ym as angle for the flame physic.enable_gravity(false); - set_texture(img_flame, img_flame, 2, 0.5); + set_sprite(img_flame, img_flame, 2, 0.5); } else if(kind == BAD_BOUNCINGSNOWBALL) { physic.set_velocity(-1.3, 0); - set_texture(img_bouncingsnowball_left, img_bouncingsnowball_right, 6); + set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right, 6); } else if(kind == BAD_STALACTITE) { physic.enable_gravity(false); - set_texture(img_stalactite, img_stalactite, 1); + set_sprite(img_stalactite, img_stalactite, 1); } else if(kind == BAD_FISH) { - set_texture(img_fish, img_fish, 2, 1); + set_sprite(img_fish, img_fish, 2, 1); physic.enable_gravity(true); } else if(kind == BAD_FLYINGSNOWBALL) { - set_texture(img_flyingsnowball, img_flyingsnowball, 2, 5); + set_sprite(img_flyingsnowball, img_flyingsnowball, 2, 5); physic.enable_gravity(false); } else if(kind == BAD_SPIKY) { physic.set_velocity(-1.3, 0); - set_texture(img_spiky_left, img_spiky_right, 3); + set_sprite(img_spiky_left, img_spiky_right, 3); } else if(kind == BAD_SNOWBALL) { physic.set_velocity(-1.3, 0); - set_texture(img_snowball_left, img_snowball_right, 4, 5); + set_sprite(img_snowball_left, img_snowball_right, 4, 5); } // if we're in a solid tile at start correct that now @@ -277,7 +279,7 @@ old_base = base; mode=KICK; - set_texture(img_laptop_flat_left, img_laptop_flat_right, 1); + set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); physic.set_velocity((dir == LEFT) ? -8 : 8, -8); play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER); } @@ -305,7 +307,7 @@ if(!timer.check()) { mode = NORMAL; - set_texture(img_laptop_left, img_laptop_right, 4, 5); + set_sprite(img_laptop_left, img_laptop_right, 4, 5); physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0); } } @@ -395,11 +397,11 @@ BadGuy::action_money(float frame_ratio) { if (fabsf(physic.get_velocity_y()) < 2.5f) - set_texture(&img_jumpy_left_middle, &img_jumpy_left_middle, 1); + set_sprite(img_jumpy_left_middle, img_jumpy_left_middle, 1); else if (physic.get_velocity_y() < 0) - set_texture(&img_jumpy_left_up, &img_jumpy_left_up, 1); + set_sprite(img_jumpy_left_up, img_jumpy_left_up, 1); else - set_texture(&img_jumpy_left_down, &img_jumpy_left_down, 1); + set_sprite(img_jumpy_left_down, img_jumpy_left_down, 1); Player& tux = *World::current()->get_tux(); @@ -458,7 +460,7 @@ } else if(!timer.check()) { if(mode == BOMB_TICKING) { mode = BOMB_EXPLODE; - set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1); + set_sprite(img_mrbomb_explosion, img_mrbomb_explosion, 1); dying = DYING_NOT; // now the bomb hurts timer.start(EXPLODETIME); } else if(mode == BOMB_EXPLODE) { @@ -501,7 +503,7 @@ timer.start(2000); dying = DYING_SQUISHED; mode = FLAT; - set_texture(img_stalactite_broken, img_stalactite_broken, 1); + set_sprite(img_stalactite_broken, img_stalactite_broken, 1); } } else if(mode == FLAT) { fall(); @@ -536,7 +538,7 @@ && physic.get_velocity_y() <= 0 && mode == NORMAL) { mode = FISH_WAIT; - set_texture(0, 0); + set_sprite(0, 0); physic.set_velocity(0, 0); physic.enable_gravity(false); timer.start(WAITTIME); @@ -544,7 +546,7 @@ else if(mode == FISH_WAIT && !timer.check()) { // jump again - set_texture(img_fish, img_fish, 2, 2); + set_sprite(img_fish, img_fish, 2, 2); animation_offset = global_frame_counter; // restart animation mode = NORMAL; physic.set_velocity(0, JUMPV); @@ -556,7 +558,7 @@ collision_swept_object_map(&old_base, &base); if(physic.get_velocity_y() < 0) - set_texture(img_fish_down, img_fish_down); + set_sprite(img_fish_down, img_fish_down); } void @@ -748,23 +750,26 @@ // Don't try to draw stuff that is outside of the screen if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w) return; - if(texture_left == 0 || texture_right == 0) - return; + + if(sprite_left == 0 || sprite_right == 0) + { + std::cout << "BadGuy: Error no sprite loaded" << std::endl; + return; + } float global_frame = (float(global_frame_counter - animation_offset) / 10); global_frame *= animation_speed; - size_t frame = size_t(global_frame) % animation_length; - Surface* texture = - (dir == LEFT) ? texture_left[frame] : texture_right[frame]; - texture->draw(base.x - scroll_x, base.y); + //size_t frame = size_t(global_frame) % animation_length; + Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right; + sprite->draw(base.x - scroll_x, base.y); if (debug_mode) fillrect(base.x - scroll_x, base.y, base.width, base.height, 75,0,75, 150); } void -BadGuy::set_texture(Surface** left, Surface** right, - int nanimlength, float nanimspeed) +BadGuy::set_sprite(Sprite* left, Sprite* right, + int nanimlength, float nanimspeed) { if (1) { @@ -778,13 +783,13 @@ // representation if(left != 0) { if(base.width == 0 && base.height == 0) { - base.width = left[0]->w; - base.height = left[0]->h; - } else if(base.width != left[0]->w || base.height != left[0]->h) { - base.x -= (left[0]->w - base.width) / 2; - base.y -= left[0]->h - base.height; - base.width = left[0]->w; - base.height = left[0]->h; + base.width = left->get_width(); + base.height = left->get_height(); + } else if(base.width != left->get_width() || base.height != left->get_height()) { + base.x -= (left->get_width() - base.width) / 2; + base.y -= left->get_height() - base.height; + base.width = left->get_width(); + base.height = left->get_height(); old_base = base; } } else { @@ -795,8 +800,8 @@ animation_length = nanimlength; animation_speed = nanimspeed; animation_offset = 0; - texture_left = left; - texture_right = right; + sprite_left = left; + sprite_right = right; } void @@ -847,7 +852,7 @@ } else if(kind == BAD_BSOD) { squish_me(player); - set_texture(img_bsod_squished_left, img_bsod_squished_right, 1); + set_sprite(img_bsod_squished_left, img_bsod_squished_right, 1); physic.set_velocity(0, physic.get_velocity_y()); return; @@ -857,7 +862,7 @@ /* Flatten! */ play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER); mode = FLAT; - set_texture(img_laptop_flat_left, img_laptop_flat_right, 1); + set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); physic.set_velocity(0, physic.get_velocity_y()); timer.start(4000); @@ -874,7 +879,7 @@ } mode = KICK; - set_texture(img_laptop_flat_left, img_laptop_flat_right, 1); + set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1); } make_player_jump(player); @@ -897,15 +902,15 @@ return; } else if(kind == BAD_BOUNCINGSNOWBALL) { squish_me(player); - set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1); + set_sprite(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1); return; } else if(kind == BAD_FLYINGSNOWBALL) { squish_me(player); - set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1); + set_sprite(img_flyingsnowball_squished,img_flyingsnowball_squished,1); return; } else if(kind == BAD_SNOWBALL) { squish_me(player); - set_texture(img_snowball_squished_left, img_snowball_squished_right, 1); + set_sprite(img_snowball_squished_left, img_snowball_squished_right, 1); return; } } @@ -918,9 +923,9 @@ dying = DYING_FALLING; if(kind == BAD_LAPTOP) - set_texture(img_laptop_falling_left, img_laptop_falling_right, 1); + set_sprite(img_laptop_falling_left, img_laptop_falling_right, 1); else if(kind == BAD_BSOD) - set_texture(img_bsod_falling_left, img_bsod_falling_right, 1); + set_sprite(img_bsod_falling_left, img_bsod_falling_right, 1); physic.enable_gravity(true); physic.set_velocity(physic.get_velocity_x(), 0); @@ -976,52 +981,89 @@ void load_badguy_gfx() { + img_bsod_squished_left = sprite_manager->load("bsod-squished-left"); + img_bsod_squished_right = sprite_manager->load("bsod-squished-right"); + img_bsod_falling_left = sprite_manager->load("bsod-falling-left"); + img_bsod_falling_right = sprite_manager->load("bsod-falling-right"); + img_laptop_flat_left = sprite_manager->load("laptop-flat-left"); + img_laptop_flat_right = sprite_manager->load("laptop-flat-right"); + img_laptop_falling_left = sprite_manager->load("laptop-falling-left"); + img_laptop_falling_right = sprite_manager->load("laptop-falling-right"); + img_bsod_left = sprite_manager->load("bsod-left"); + img_bsod_right = sprite_manager->load("bsod-right"); + img_laptop_left = sprite_manager->load("laptop-left"); + img_laptop_right = sprite_manager->load("laptop-right"); + img_jumpy_left_up = sprite_manager->load("jumpy-left-up"); + img_jumpy_left_down = sprite_manager->load("jumpy-left-down"); + img_jumpy_left_middle = sprite_manager->load("jumpy-left-middle"); + img_mrbomb_left = sprite_manager->load("mrbomb-left"); + img_mrbomb_right = sprite_manager->load("mrbomb-right"); + img_mrbomb_ticking_left = sprite_manager->load("mrbomb-ticking-left"); + img_mrbomb_ticking_right = sprite_manager->load("mrbomb-ticking-right"); + img_mrbomb_explosion = sprite_manager->load("mrbomb-explosion"); + img_stalactite = sprite_manager->load("stalactite"); + img_stalactite_broken = sprite_manager->load("stalactite-broken"); + img_flame = sprite_manager->load("flame"); + img_fish = sprite_manager->load("fish"); + img_fish_down = sprite_manager->load("fish-down"); + img_bouncingsnowball_left = sprite_manager->load("bouncingsnowball-left"); + img_bouncingsnowball_right = sprite_manager->load("bouncingsnowball-right"); + img_bouncingsnowball_squished = sprite_manager->load("bouncingsnowball-squished"); + img_flyingsnowball = sprite_manager->load("flyingsnowball"); + img_flyingsnowball_squished = sprite_manager->load("flyingsnowball-squished"); + img_spiky_left = sprite_manager->load("spiky-left"); + img_spiky_right = sprite_manager->load("spiky-right"); + img_snowball_left = sprite_manager->load("snowball-left"); + img_snowball_right = sprite_manager->load("snowball-right"); + img_snowball_squished_left = sprite_manager->load("snowball-squished-left"); + img_snowball_squished_right = sprite_manager->load("snowball-squished-right"); +#if 0 /* (BSOD) */ img_bsod_left[0] = new Surface(datadir + "/images/shared/bsod-left-0.png", USE_ALPHA); img_bsod_left[1] = new Surface(datadir + - "/images/shared/bsod-left-1.png", - USE_ALPHA); + "/images/shared/bsod-left-1.png", + USE_ALPHA); img_bsod_left[2] = new Surface(datadir + - "/images/shared/bsod-left-2.png", - USE_ALPHA); + "/images/shared/bsod-left-2.png", + USE_ALPHA); img_bsod_left[3] = new Surface(datadir + - "/images/shared/bsod-left-3.png", - USE_ALPHA); + "/images/shared/bsod-left-3.png", + USE_ALPHA); img_bsod_right[0] = new Surface(datadir + - "/images/shared/bsod-right-0.png", - USE_ALPHA); + "/images/shared/bsod-right-0.png", + USE_ALPHA); img_bsod_right[1] = new Surface(datadir + - "/images/shared/bsod-right-1.png", - USE_ALPHA); + "/images/shared/bsod-right-1.png", + USE_ALPHA); img_bsod_right[2] = new Surface(datadir + - "/images/shared/bsod-right-2.png", - USE_ALPHA); + "/images/shared/bsod-right-2.png", + USE_ALPHA); img_bsod_right[3] = new Surface(datadir + - "/images/shared/bsod-right-3.png", - USE_ALPHA); + "/images/shared/bsod-right-3.png", + USE_ALPHA); img_bsod_squished_left[0] = new Surface(datadir + - "/images/shared/bsod-squished-left.png", - USE_ALPHA); + "/images/shared/bsod-squished-left.png", + USE_ALPHA); img_bsod_squished_right[0] = new Surface(datadir + - "/images/shared/bsod-squished-right.png", - USE_ALPHA); + "/images/shared/bsod-squished-right.png", + USE_ALPHA); img_bsod_falling_left[0] = new Surface(datadir + - "/images/shared/bsod-falling-left.png", - USE_ALPHA); + "/images/shared/bsod-falling-left.png", + USE_ALPHA); img_bsod_falling_right[0] = new Surface(datadir + - "/images/shared/bsod-falling-right.png", - USE_ALPHA); + "/images/shared/bsod-falling-right.png", + USE_ALPHA); /* (Laptop) */ @@ -1037,101 +1079,101 @@ img_laptop_right[3] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA); img_laptop_flat_left[0] = new Surface( - datadir + "/images/shared/laptop-flat-left.png", - USE_ALPHA); + datadir + "/images/shared/laptop-flat-left.png", + USE_ALPHA); img_laptop_flat_right[0] = new Surface(datadir + - "/images/shared/laptop-flat-right.png", - USE_ALPHA); + "/images/shared/laptop-flat-right.png", + USE_ALPHA); img_laptop_falling_left[0] = new Surface(datadir + - "/images/shared/laptop-falling-left.png", - USE_ALPHA); + "/images/shared/laptop-falling-left.png", + USE_ALPHA); img_laptop_falling_right[0] = new Surface(datadir + - "/images/shared/laptop-falling-right.png", - USE_ALPHA); + "/images/shared/laptop-falling-right.png", + USE_ALPHA); /* (Money) */ img_jumpy_left_up = new Surface(datadir + - "/images/shared/jumpy-left-up-0.png", - USE_ALPHA); + "/images/shared/jumpy-left-up-0.png", + USE_ALPHA); img_jumpy_left_down = new Surface(datadir + "/images/shared/jumpy-left-down-0.png", USE_ALPHA); img_jumpy_left_middle = new Surface(datadir + - "/images/shared/jumpy-left-middle-0.png", - USE_ALPHA); + "/images/shared/jumpy-left-middle-0.png", + USE_ALPHA); /* Mr. Bomb */ for(int i=0; i<4; ++i) { - char num[4]; - snprintf(num, 4, "%d", i); - img_mrbomb_left[i] = new Surface( - datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA); - img_mrbomb_right[i] = new Surface( - datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA); + char num[4]; + snprintf(num, 4, "%d", i); + img_mrbomb_left[i] = new Surface( + datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA); + img_mrbomb_right[i] = new Surface( + datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA); } img_mrbomb_ticking_left[0] = new Surface( - datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA); + datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA); img_mrbomb_ticking_right[0] = new Surface( - datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA); + datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA); img_mrbomb_explosion[0] = new Surface( - datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA); + datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA); /* stalactite */ img_stalactite[0] = new Surface( - datadir + "/images/shared/stalactite.png", USE_ALPHA); + datadir + "/images/shared/stalactite.png", USE_ALPHA); img_stalactite_broken[0] = new Surface( - datadir + "/images/shared/stalactite-broken.png", USE_ALPHA); + datadir + "/images/shared/stalactite-broken.png", USE_ALPHA); /* flame */ img_flame[0] = new Surface( - datadir + "/images/shared/flame-0.png", USE_ALPHA); + datadir + "/images/shared/flame-0.png", USE_ALPHA); img_flame[1] = new Surface( - datadir + "/images/shared/flame-1.png", USE_ALPHA); + datadir + "/images/shared/flame-1.png", USE_ALPHA); /* fish */ img_fish[0] = new Surface( - datadir + "/images/shared/fish-left-0.png", USE_ALPHA); + datadir + "/images/shared/fish-left-0.png", USE_ALPHA); img_fish[1] = new Surface( - datadir + "/images/shared/fish-left-1.png", USE_ALPHA); + datadir + "/images/shared/fish-left-1.png", USE_ALPHA); img_fish_down[0] = new Surface( - datadir + "/images/shared/fish-down-0.png", USE_ALPHA); + datadir + "/images/shared/fish-down-0.png", USE_ALPHA); /* bouncing snowball */ for(int i=0; i<6; ++i) { - char num[4]; - snprintf(num, 4, "%d", i); - img_bouncingsnowball_left[i] = new Surface( - datadir + "/images/shared/bouncingsnowball-left-" + num + ".png", - USE_ALPHA); - img_bouncingsnowball_right[i] = new Surface( - datadir + "/images/shared/bouncingsnowball-right-" + num + ".png", - USE_ALPHA); + char num[4]; + snprintf(num, 4, "%d", i); + img_bouncingsnowball_left[i] = new Surface( + datadir + "/images/shared/bouncingsnowball-left-" + num + ".png", + USE_ALPHA); + img_bouncingsnowball_right[i] = new Surface( + datadir + "/images/shared/bouncingsnowball-right-" + num + ".png", + USE_ALPHA); } img_bouncingsnowball_squished[0] = new Surface( - datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); + datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); /* flying snowball */ img_flyingsnowball[0] = new Surface( - datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA); + datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA); img_flyingsnowball[1] = new Surface( - datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA); + datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA); img_flyingsnowball_squished[0] = new Surface( - datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); + datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); /* spiky */ for(int i = 0; i < 3; ++i) { - char num[4]; - snprintf(num, 4, "%d", i); - img_spiky_left[i] = new Surface( - datadir + "/images/shared/spiky-left-" + num + ".png", - USE_ALPHA); - img_spiky_right[i] = new Surface( - datadir + "/images/shared/spiky-right-" + num + ".png", - USE_ALPHA); + char num[4]; + snprintf(num, 4, "%d", i); + img_spiky_left[i] = new Surface( + datadir + "/images/shared/spiky-left-" + num + ".png", + USE_ALPHA); + img_spiky_right[i] = new Surface( + datadir + "/images/shared/spiky-right-" + num + ".png", + USE_ALPHA); } /** snowball */ @@ -1146,79 +1188,14 @@ img_snowball_right[3] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA); img_snowball_squished_left[0] = new Surface( - datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); + datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA); img_snowball_squished_right[0] = new Surface( - datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA); + datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA); +#endif } void free_badguy_gfx() { - for (int i = 0; i < 4; i++) - { - delete img_bsod_left[i]; - delete img_bsod_right[i]; - } - - delete img_bsod_squished_left[0]; - delete img_bsod_squished_right[0]; - - delete img_bsod_falling_left[0]; - delete img_bsod_falling_right[0]; - - for (int i = 0; i < 4; i++) - { - delete img_laptop_left[i]; - delete img_laptop_right[i]; - } - - delete img_laptop_flat_left[0]; - delete img_laptop_flat_right[0]; - - delete img_laptop_falling_left[0]; - delete img_laptop_falling_right[0]; - - delete img_jumpy_left_up; - delete img_jumpy_left_down; - - for(int i = 0; i < 4; i++) { - delete img_mrbomb_left[i]; - delete img_mrbomb_right[i]; - } - - delete img_mrbomb_ticking_left[0]; - delete img_mrbomb_ticking_right[0]; - delete img_mrbomb_explosion[0]; - - delete img_stalactite[0]; - delete img_stalactite_broken[0]; - - delete img_flame[0]; - delete img_flame[1]; - - delete img_fish[0]; - delete img_fish[1]; - delete img_fish_down[0]; - - for(int i=0; i<6; ++i) { - delete img_bouncingsnowball_left[i]; - delete img_bouncingsnowball_right[i]; - } - delete img_bouncingsnowball_squished[0]; - - delete img_flyingsnowball[0]; - delete img_flyingsnowball[1]; - delete img_flyingsnowball_squished[0]; - - for(int i = 0; i<3; ++i) { - delete img_spiky_left[i]; - delete img_spiky_right[i]; - } - for(int i = 0; i<4; ++i) { - delete img_snowball_left[i]; - delete img_snowball_right[i]; - } - delete img_snowball_squished_left[0]; - delete img_snowball_squished_right[0]; } // EOF // Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sprite.cpp 13 Apr 2004 02:19:13 -0000 1.2 +++ sprite.cpp 17 Apr 2004 10:48:04 -0000 1.3 @@ -27,9 +27,10 @@ LispReader reader(cur); + reader.read_string("name", &name); reader.read_int("x-hotspot", &x_hotspot); reader.read_int("y-hotspot", &y_hotspot); - reader.read_float("fps", &fps); + reader.read_float("fps", &fps); std::vector<std::string> images; reader.read_string_vector("images", &images); surfaces.resize(images.size()); @@ -38,6 +39,8 @@ { surfaces[i] = new Surface(datadir + "/images/" + images[i], USE_ALPHA); } + + frame_delay = 1000.0f/fps; } void @@ -45,32 +48,51 @@ { x_hotspot = 0; y_hotspot = 0; - fps = 15; + fps = 10; time = 0; frame_delay = 1000.0f/fps; } void -Sprite::update(float delta) +Sprite::update(float /*delta*/) { - time += 10*delta; + //time += 10*delta; //std::cout << "Delta: " << delta << std::endl; } void -Sprite::draw(int x, int y) +Sprite::draw(float x, float y) { - unsigned int frame = static_cast<int>(fmodf(time, surfaces.size()*frame_delay)/frame_delay); - - /* - std::cout << "Frame: " - << frame << " " - << time << " " - << surfaces.size() << " " - << frame_delay << " " - << static_cast<int>(fmodf(time, surfaces.size()*frame_delay)/frame_delay) << std::endl;*/ + time = SDL_GetTicks(); + unsigned int frame = get_current_frame(); + if (frame < surfaces.size()) surfaces[frame]->draw(x - x_hotspot, y - y_hotspot); } +void +Sprite::reset() +{ + time = 0; +} + +int +Sprite::get_current_frame() const +{ + unsigned int frame = static_cast<int>(fmodf(time, surfaces.size()*frame_delay)/frame_delay); + return frame % surfaces.size(); +} + +int +Sprite::get_width() const +{ + return surfaces[get_current_frame()]->w; +} + +int +Sprite::get_height() const +{ + return surfaces[get_current_frame()]->h; +} + /* EOF */ --- NEW FILE: sprite_manager.h --- // $Id: sprite_manager.h,v 1.1 2004/04/17 10:48:04 grumbel Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef HEADER_SPRITE_MANAGER_HXX #define HEADER_SPRITE_MANAGER_HXX #include <map> #include "sprite.h" class SpriteManager { private: typedef std::map<std::string, Sprite*> Sprites; Sprites sprites; public: SpriteManager(const std::string& filename); void load_resfile(const std::string& filename); Sprite* load(const std::string& name); }; #endif /* Local Variables: */ /* mode:c++ */ /* End: */ Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- resources.cpp 13 Apr 2004 02:19:13 -0000 1.8 +++ resources.cpp 17 Apr 2004 10:48:04 -0000 1.9 @@ -5,6 +5,7 @@ #include "gameobjs.h" #include "special.h" #include "resources.h" +#include "sprite_manager.h" Surface* img_waves[3]; Surface* img_water; @@ -17,11 +18,15 @@ Surface* img_box_empty; Surface* img_red_glow; +SpriteManager* sprite_manager = 0; + /* Load graphics/sounds shared between all levels: */ void loadshared() { int i; + sprite_manager = new SpriteManager(datadir + "/supertux.strf"); + /* Tuxes: */ smalltux_stand_left = new Surface(datadir + "/images/shared/smalltux-left-6.png", USE_ALPHA); smalltux_stand_right = new Surface(datadir + "/images/shared/smalltux-right-6.png", USE_ALPHA); @@ -287,6 +292,8 @@ /* Free shared data: */ void unloadshared(void) { + delete sprite_manager; + int i; free_special_gfx(); |
From: Ingo R. <gr...@us...> - 2004-04-17 10:48:12
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3202/data Added Files: supertux.strf Log Message: - moved badguys to use sprite class --- NEW FILE: supertux.strf --- (supertux-resources (sprite (name "smalltux") (fps 15.0) (x-hotspot 5) (y-hotspot 9) (images "shared/smalltux-right-1.png" "shared/smalltux-right-2.png" "shared/smalltux-right-3.png" "shared/smalltux-right-4.png" "shared/smalltux-right-5.png" "shared/smalltux-right-6.png" "shared/smalltux-right-7.png" "shared/smalltux-right-8.png")) (sprite (name "bsod-left") (images "shared/bsod-left-0.png" "shared/bsod-left-1.png" "shared/bsod-left-2.png" "shared/bsod-left-3.png")) (sprite (name "bsod-right") (images "shared/bsod-right-0.png" "shared/bsod-right-1.png" "shared/bsod-right-2.png" "shared/bsod-right-3.png")) (sprite (name "bsod-squished-left") (images "shared/bsod-squished-left.png")) (sprite (name "bsod-squished-right") (images "shared/bsod-squished-right.png")) (sprite (name "bsod-falling-left") (images "shared/bsod-falling-left.png")) (sprite (name "bsod-falling-right") (images "shared/bsod-falling-right.png")) (sprite (name "laptop-left") (images "shared/mriceblock-left-0.png" "shared/mriceblock-left-1.png" "shared/mriceblock-left-2.png" "shared/mriceblock-left-1.png")) (sprite (name "laptop-right") (images "shared/mriceblock-right-0.png" "shared/mriceblock-right-1.png" "shared/mriceblock-right-2.png" "shared/mriceblock-right-1.png")) (sprite (name "laptop-flat-left") (images "shared/laptop-flat-left.png")) (sprite (name "laptop-flat-right") (images "shared/laptop-flat-right.png")) (sprite (name "laptop-falling-left") (images "shared/laptop-falling-left.png")) (sprite (name "laptop-falling-right") (images "shared/laptop-falling-right.png")) (sprite (name "img-jumpy-left-up") (images "shared/jumpy-left-up-0.png")) (sprite (name "img-jumpy-left-down") (images "shared/jumpy-left-down-0.png")) (sprite (name "img-jumpy-middle-up") (images "shared/jumpy-left-middle-0.png")) (sprite (name "mrbomb-left") (images "shared/mrbomb-left-0.png") (images "shared/mrbomb-left-1.png") (images "shared/mrbomb-left-2.png") (images "shared/mrbomb-left-3.png")) (sprite (name "mrbomb-right") (images "shared/mrbomb-right-0.png") (images "shared/mrbomb-right-1.png") (images "shared/mrbomb-right-2.png") (images "shared/mrbomb-right-3.png")) (sprite (name "mrbomb-ticking-left") (images "shared/mrbombx-left-0.png")) (sprite (name "mrbomb-ticking-right") (images "shared/mrbombx-right-0.png")) (sprite (name "mrbomb-explosion") (images "shared/mrbomb-explosion.png")) (sprite (name "stalactite") (images "shared/stalactite.png")) (sprite (name "stalactite-broken") (images "shared/stalactite-broken.png")) (sprite (name "flame") (images "shared/flame-0.png" "shared/flame-1.png")) (sprite (name "fish") (images "shared/fish-left-0.png" "shared/fish-left-1.png")) (sprite (name "fish") (images "shared/fish-down-0.png")) (sprite (name "bouncingsnowball-left") (images "shared/bouncingsnowball-left-0.png" "shared/bouncingsnowball-left-1.png" "shared/bouncingsnowball-left-2.png" "shared/bouncingsnowball-left-3.png" "shared/bouncingsnowball-left-4.png" "shared/bouncingsnowball-left-5.png")) (sprite (name "bouncingsnowball-right") (images "shared/bouncingsnowball-right-0.png" "shared/bouncingsnowball-right-1.png" "shared/bouncingsnowball-right-2.png" "shared/bouncingsnowball-right-3.png" "shared/bouncingsnowball-right-4.png" "shared/bouncingsnowball-right-5.png")) (sprite (name "bouncingsnowball-squished") (images "shared/bsod-squished-left.png")) (sprite (name "flyingsnowball") (images "shared/flyingsnowball-left-0.png" "shared/flyingsnowball-left-1.png")) (sprite (name "flyingsnowball-squished") (images "shared/bsod-squished-left.png")) (sprite (name "spiky-left") (images "shared/spiky-left-0.png" "shared/spiky-left-1.png" "shared/spiky-left-2.png")) (sprite (name "spiky-right") (images "shared/spiky-right-0.png" "shared/spiky-right-1.png" "shared/spiky-right-2.png")) (sprite (name "snowball-left") (images "shared/snowball-left-0.png" "shared/snowball-left-1.png" "shared/snowball-left-2.png" "shared/snowball-left-1.png")) (sprite (name "snowball-right") (images "shared/snowball-right-0.png" "shared/snowball-right-1.png" "shared/snowball-right-2.png" "shared/snowball-right-1.png")) (sprite (name "bsod-squished-left") (images "shared/bsod-squished-left.png")) (sprite (name "bsod-squished-right") (images "shared/bsod-squished-right.png")) ) ;; EOF ;; |
From: Ingo R. <gr...@us...> - 2004-04-17 01:23:48
|
Update of /cvsroot/super-tux/supertux/data/levels/cave In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21757 Modified Files: level1.stl level2.stl level3.stl level4.stl level5.stl level6.stl Log Message: - added cave background to cave levels Index: level1.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level1.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level1.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level1.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,14 +5,13 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "arctis.png") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 150) (bkgd_green 200) (bkgd_blue 255) (time 500) (gravity 10) - (particle_system "snow") (theme "antarctica") (interactive-tm 36 36 43 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 43 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 43 0 0 0 0 0 0 0 0 0 38 36 36 Index: level5.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level5.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level5.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level5.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,14 +5,14 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "arctis.png") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 150) (bkgd_green 200) (bkgd_blue 255) (time 500) (gravity 10) - (particle_system "snow") + (particle_system "") (theme "antarctica") (interactive-tm 36 43 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 Index: level2.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level2.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level2.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level2.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,7 +5,7 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 0) (bkgd_green 0) Index: level4.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level4.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level4.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level4.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,14 +5,14 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "arctis.png") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 150) (bkgd_green 200) (bkgd_blue 255) (time 500) (gravity 10) - (particle_system "snow") +;; (particle_system "snow") (theme "antarctica") (interactive-tm 36 36 36 0 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 43 0 0 0 0 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 Index: level3.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level3.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level3.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level3.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,14 +5,14 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "arctis.png") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 150) (bkgd_green 200) (bkgd_blue 255) (time 500) (gravity 10) - (particle_system "snow") + (particle_system "") (theme "antarctica") (interactive-tm 36 36 43 0 0 0 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 Index: level6.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/cave/level6.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level6.stl 12 Apr 2004 23:20:40 -0000 1.1 +++ level6.stl 17 Apr 2004 01:23:39 -0000 1.2 @@ -5,14 +5,14 @@ (author "Ingo Ruhnke") (width 500) (height 15) - (background "arctis.png") + (background "cave2.jpg") (music "Mortimers_chipdisko.mod") (bkgd_red 150) (bkgd_green 200) (bkgd_blue 255) (time 500) (gravity 10) - (particle_system "snow") + (particle_system "") (theme "antarctica") (interactive-tm 36 36 43 0 0 0 38 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 |
From: Ingo R. <gr...@us...> - 2004-04-17 00:50:05
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15512 Modified Files: gameloop.cpp setup.cpp setup.h supertux.cpp title.cpp worldmap.cpp worldmap.h Log Message: - added load game support for the worldmap Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- setup.cpp 16 Apr 2004 16:52:18 -0000 1.39 +++ setup.cpp 17 Apr 2004 00:49:54 -0000 1.40 @@ -11,6 +11,7 @@ */ #include <assert.h> +#include <stdio.h> #include <iostream> #include <stdio.h> #include <stdlib.h> @@ -440,18 +441,14 @@ highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0); } -void update_load_save_game_menu(Menu* pmenu, int load) +void update_load_save_game_menu(Menu* pmenu) { for(int i = 2; i < 7; ++i) { // FIXME: Insert a real savegame struct/class here instead of // doing string vodoo - std::string tmp = slotinfo(i-1); - - if(load && tmp.length() == strlen("Slot X - Free")) - pmenu->item[i].kind = MN_ACTION; - else - pmenu->item[i].kind = MN_ACTION; + std::string tmp = slotinfo(i - 1); + pmenu->item[i].kind = MN_ACTION; pmenu->item[i].change_text(tmp.c_str()); } } @@ -462,21 +459,18 @@ if(slot != -1) { - // FIXME: Insert a real savegame struct/class here instead of - // doing string vodoo - std::string tmp = slotinfo(slot-1); + WorldMapNS::WorldMap worldmap; + + char slotfile[1024]; + snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot-1); + + worldmap.loadgame(slotfile); + + worldmap.display(); + + show_menu = true; + Menu::set_current(main_menu); - if (tmp.length() == strlen("Slot X - Free")) - { // Slot is free, so start a new game - worldmap_run(); - - show_menu = true; - Menu::set_current(main_menu); - } - else - { - puts("Warning: Loading games isn't supported at the moment"); - } st_pause_ticks_stop(); return true; } Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- setup.h 16 Apr 2004 16:52:18 -0000 1.16 +++ setup.h 17 Apr 2004 00:49:54 -0000 1.17 @@ -39,7 +39,7 @@ /** Return true if the gameloop() was entered, false otherwise */ bool process_load_game_menu(); -void update_load_save_game_menu(Menu* pmenu, int load); +void update_load_save_game_menu(Menu* pmenu); void parseargs(int argc, char * argv[]); #endif /*SUPERTUX_SETUP_H*/ Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- title.cpp 13 Apr 2004 12:25:22 -0000 1.42 +++ title.cpp 17 Apr 2004 00:49:54 -0000 1.43 @@ -408,7 +408,7 @@ #endif case 0: // Start Game, ie. goto the slots menu - update_load_save_game_menu(load_game_menu, true); + update_load_save_game_menu(load_game_menu); break; case 1: // Contrib Menu Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- worldmap.cpp 16 Apr 2004 16:52:18 -0000 1.26 +++ worldmap.cpp 17 Apr 2004 00:49:54 -0000 1.27 @@ -450,7 +450,8 @@ play_music(song, 1); show_menu = 0; menu_reset(); - savegame(std::string(st_save_dir) + "/slot1.stsg"); + if (!savegame_file.empty()) + savegame(savegame_file); return; } } @@ -591,14 +592,23 @@ void WorldMap::savegame(const std::string& filename) { + std::cout << "savegame: " << filename << std::endl; std::ofstream out(filename.c_str()); + int nb_solved_levels = 0; + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (i->solved) + ++nb_solved_levels; + } + out << "(supertux-savegame\n" << " (version 1)\n" + << " (title \"Icyisland - " << nb_solved_levels << "/" << levels.size() << "\")\n" << " (lives " << player_status.lives << ")\n" << " (score " << player_status.score << ")\n" << " (distros " << player_status.distros << ")\n" - << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")\n" + << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << "))\n" << " (levels\n"; for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) @@ -614,13 +624,60 @@ << " )\n\n;; EOF ;;" << std::endl; } -} // namespace WorldMapNS - -void worldmap_run() +void +WorldMap::loadgame(const std::string& filename) { - WorldMapNS::WorldMap worldmap; + std::cout << "loadgame: " << filename << std::endl; + savegame_file = filename; + + if (access(filename.c_str(), F_OK) == 0) + { + lisp_object_t* cur = lisp_read_from_file(filename); + + if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-savegame") != 0) + return; + + cur = lisp_cdr(cur); + LispReader reader(cur); - worldmap.display(); + reader.read_int("lives", &player_status.lives); + reader.read_int("score", &player_status.score); + reader.read_int("distros", &player_status.distros); + + lisp_object_t* tux_cur = 0; + if (reader.read_lisp("tux", &tux_cur)) + { + Point p; + LispReader tux_reader(tux_cur); + tux_reader.read_int("x", &p.x); + tux_reader.read_int("y", &p.y); + + tux->set_tile_pos(p); + } + + lisp_object_t* level_cur = 0; + if (reader.read_lisp("levels", &level_cur)) + { + while(level_cur) + { + std::string name; + bool solved = false; + LispReader level_reader(level_cur); + level_reader.read_string("name", &name); + level_reader.read_bool("solved", &solved); + + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (name == i->name) + i->solved = solved; + } + + level_cur = lisp_cdr(level_cur); + } + } + } } +} // namespace WorldMapNS + /* EOF */ Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- supertux.cpp 11 Apr 2004 19:10:41 -0000 1.10 +++ supertux.cpp 17 Apr 2004 00:49:54 -0000 1.11 @@ -41,7 +41,8 @@ if (launch_worldmap_mode) { - worldmap_run(); + WorldMapNS::WorldMap worldmap; + worldmap.display(); } else if (level_startup_file) { Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- worldmap.h 16 Apr 2004 16:52:18 -0000 1.15 +++ worldmap.h 17 Apr 2004 00:49:54 -0000 1.16 @@ -144,6 +144,7 @@ bool enter_level; Point offset; + std::string savegame_file; void draw_status(); public: @@ -171,12 +172,11 @@ bool path_ok(Direction direction, Point pos, Point* new_pos); void savegame(const std::string& filename); + void loadgame(const std::string& filename); }; } // namespace WorldMapNS -void worldmap_run(); - #endif /* Local Variables: */ Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- gameloop.cpp 16 Apr 2004 18:49:13 -0000 1.72 +++ gameloop.cpp 17 Apr 2004 00:49:54 -0000 1.73 @@ -519,10 +519,11 @@ st_pause_ticks_stop(); break; case 3: - update_load_save_game_menu(save_game_menu, false); + // FIXME: + //update_load_save_game_menu(save_game_menu); break; case 4: - update_load_save_game_menu(load_game_menu, true); + update_load_save_game_menu(load_game_menu); break; case 7: st_pause_ticks_stop(); @@ -737,33 +738,16 @@ std::string slotinfo(int slot) { - FILE* fi; + char tmp[1024]; char slotfile[1024]; - char tmp[200]; - char str[5]; - int slot_level; - sprintf(slotfile,"%s/slot%d.save",st_save_dir,slot); - - fi = fopen(slotfile, "rb"); - - sprintf(tmp,"Slot %d - ",slot); + sprintf(slotfile,"%s/slot%d.stsg",st_save_dir,slot); - if (fi == NULL) - { - strcat(tmp,"Free"); - } + if (access(slotfile, F_OK) == 0) + sprintf(tmp,"Slot %d - Savegame",slot); else - { - fgets(str, 100, fi); - str[strlen(str)-1] = '\0'; - strcat(tmp, str); - strcat(tmp, " / Level:"); - fread(&slot_level,sizeof(int),1,fi); - sprintf(str,"%d",slot_level); - strcat(tmp,str); - fclose(fi); - } + sprintf(tmp,"Slot %d - Free",slot); return tmp; } + |
From: Ingo R. <gr...@us...> - 2004-04-16 21:16:21
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6655 Modified Files: badguy.cpp badguy.h Log Message: - added new jumpy/money gfx Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- badguy.h 13 Apr 2004 02:19:13 -0000 1.24 +++ badguy.h 16 Apr 2004 21:16:12 -0000 1.25 @@ -24,7 +24,9 @@ extern Surface* img_bsod_left[4]; extern Surface* img_bsod_right[4]; extern Surface* img_laptop_left[4]; -extern Surface* img_money_left[2]; +extern Surface* img_jumpy_left_up; +extern Surface* img_jumpy_left_down; +extern Surface* img_jumpy_left_middle; /* Enemy modes: */ enum { Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- badguy.cpp 13 Apr 2004 18:50:23 -0000 1.33 +++ badguy.cpp 16 Apr 2004 21:16:12 -0000 1.34 @@ -9,6 +9,8 @@ // Copyright: See COPYING file that comes with this distribution // // + +#include <iostream> #include <math.h> #include "globals.h" @@ -31,8 +33,9 @@ Surface* img_bsod_right[4]; Surface* img_laptop_left[4]; Surface* img_laptop_right[4]; -Surface* img_money_left[2]; -Surface* img_money_right[2]; +Surface* img_jumpy_left_up; +Surface* img_jumpy_left_down; +Surface* img_jumpy_left_middle; Surface* img_mrbomb_left[4]; Surface* img_mrbomb_right[4]; Surface* img_mrbomb_ticking_left[1]; @@ -161,7 +164,7 @@ physic.set_velocity(-1.3, 0); set_texture(img_laptop_left, img_laptop_right, 4, 5); } else if(kind == BAD_MONEY) { - set_texture(img_money_left, img_money_right, 1); + set_texture(&img_jumpy_left_up, &img_jumpy_left_up, 1); } else if(kind == BAD_BOMB) { set_texture(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1); // hack so that the bomb doesn't hurt until it expldes... @@ -391,6 +394,13 @@ void BadGuy::action_money(float frame_ratio) { + if (fabsf(physic.get_velocity_y()) < 2.5f) + set_texture(&img_jumpy_left_middle, &img_jumpy_left_middle, 1); + else if (physic.get_velocity_y() < 0) + set_texture(&img_jumpy_left_up, &img_jumpy_left_up, 1); + else + set_texture(&img_jumpy_left_down, &img_jumpy_left_down, 1); + Player& tux = *World::current()->get_tux(); static const float JUMPV = 6; @@ -401,12 +411,11 @@ { physic.set_velocity(physic.get_velocity_x(), JUMPV); physic.enable_gravity(true); - set_texture(&img_money_left[1], &img_money_right[1], 1); + mode = MONEY_JUMP; } else if(mode == MONEY_JUMP) { - set_texture(&img_money_left[0], &img_money_right[0], 1); mode = NORMAL; } @@ -750,27 +759,38 @@ texture->draw(base.x - scroll_x, base.y); if (debug_mode) - fillrect(base.x - scroll_x, base.y, 32, 32, 75,0,75, 150); + fillrect(base.x - scroll_x, base.y, base.width, base.height, 75,0,75, 150); } void BadGuy::set_texture(Surface** left, Surface** right, int nanimlength, float nanimspeed) { - if(left != 0) { - if(base.width == 0 && base.height == 0) { - base.width = left[0]->w; - base.height = left[0]->h; - } else if(base.width != left[0]->w || base.height != left[0]->h) { - base.x -= (left[0]->w - base.width) / 2; - base.y -= left[0]->h - base.height; - base.width = left[0]->w; - base.height = left[0]->h; - old_base = base; + if (1) + { + base.width = 32; + base.height = 32; + } + else + { + // FIXME: Using the image size for the physics and collision is + // a bad idea, since images should always overlap there physical + // representation + if(left != 0) { + if(base.width == 0 && base.height == 0) { + base.width = left[0]->w; + base.height = left[0]->h; + } else if(base.width != left[0]->w || base.height != left[0]->h) { + base.x -= (left[0]->w - base.width) / 2; + base.y -= left[0]->h - base.height; + base.width = left[0]->w; + base.height = left[0]->h; + old_base = base; + } + } else { + base.width = base.height = 0; + } } - } else { - base.width = base.height = 0; - } animation_length = nanimlength; animation_speed = nanimspeed; @@ -1034,22 +1054,15 @@ /* (Money) */ - - img_money_left[0] = new Surface(datadir + - "/images/shared/bag-left-0.png", - USE_ALPHA); - - img_money_left[1] = new Surface(datadir + - "/images/shared/bag-left-1.png", - USE_ALPHA); - - img_money_right[0] = new Surface(datadir + - "/images/shared/bag-right-0.png", - USE_ALPHA); - - img_money_right[1] = new Surface(datadir + - "/images/shared/bag-right-1.png", - USE_ALPHA); + img_jumpy_left_up = new Surface(datadir + + "/images/shared/jumpy-left-up-0.png", + USE_ALPHA); + img_jumpy_left_down = new Surface(datadir + + "/images/shared/jumpy-left-down-0.png", + USE_ALPHA); + img_jumpy_left_middle = new Surface(datadir + + "/images/shared/jumpy-left-middle-0.png", + USE_ALPHA); /* Mr. Bomb */ for(int i=0; i<4; ++i) { @@ -1164,11 +1177,8 @@ delete img_laptop_falling_left[0]; delete img_laptop_falling_right[0]; - for (int i = 0; i < 2; i++) - { - delete img_money_left[i]; - delete img_money_right[i]; - } + delete img_jumpy_left_up; + delete img_jumpy_left_down; for(int i = 0; i < 4; i++) { delete img_mrbomb_left[i]; |
From: Ingo R. <gr...@us...> - 2004-04-16 21:15:07
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6261 Added Files: jumpy-left-down-0.png jumpy-left-middle-0.png jumpy-left-up-0.png Log Message: - added jumpy --- NEW FILE: jumpy-left-up-0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jumpy-left-middle-0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jumpy-left-down-0.png --- (This appears to be a binary file; contents omitted.) |
From: Ricardo C. <rm...@us...> - 2004-04-16 18:49:21
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6499/src Modified Files: gameloop.cpp Log Message: As requested by Ingo Ruhnke, now the author name is much more discrete. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- gameloop.cpp 16 Apr 2004 16:52:17 -0000 1.71 +++ gameloop.cpp 16 Apr 2004 18:49:13 -0000 1.72 @@ -137,11 +137,12 @@ sprintf(str, "%s", world->get_level()->name.c_str()); gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1); + sprintf(str, "TUX x %d", player_status.lives); + white_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1); + sprintf(str, "by %s", world->get_level()->author.c_str()); - red_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1); + white_small_text->drawf(str, 0, 400, A_HMIDDLE, A_TOP, 1); - sprintf(str, "TUX x %d", player_status.lives); - white_text->drawf(str, 0, 288, A_HMIDDLE, A_TOP, 1); flipscreen(); |
From: Ingo R. <gr...@us...> - 2004-04-16 16:52:27
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12476 Modified Files: gameloop.cpp gameloop.h player.cpp player.h scene.cpp scene.h setup.cpp setup.h special.cpp text.h worldmap.cpp worldmap.h Log Message: - some more savegame stuff - added status on worldmap - made worldmap start on 'start game' - moved lives, distros, score into PlayerStatus Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- scene.cpp 11 Apr 2004 15:33:53 -0000 1.20 +++ scene.cpp 16 Apr 2004 16:52:18 -0000 1.21 @@ -15,6 +15,13 @@ PlayerStatus player_status; +PlayerStatus::PlayerStatus() + : score(0), + distros(0), + lives(3) +{ +} + // FIXME: Move this into a view class float scroll_x; Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- player.h 13 Apr 2004 02:19:13 -0000 1.26 +++ player.h 16 Apr 2004 16:52:18 -0000 1.27 @@ -94,9 +94,6 @@ { public: player_keymap_type keymap; - int lives; - int score; - int distros; player_input_type input; bool got_coffee; Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- setup.h 10 Apr 2004 18:56:17 -0000 1.15 +++ setup.h 16 Apr 2004 16:52:18 -0000 1.16 @@ -36,8 +36,6 @@ void st_abort(const std::string& reason, const std::string& details); void process_options_menu(void); -void process_save_game_menu(); - /** Return true if the gameloop() was entered, false otherwise */ bool process_load_game_menu(); Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- special.cpp 13 Apr 2004 18:24:06 -0000 1.17 +++ special.cpp 16 Apr 2004 16:52:18 -0000 1.18 @@ -307,8 +307,8 @@ } else if (kind == UPGRADE_1UP) { - if(pplayer->lives < MAX_LIVES) { - pplayer->lives++; + if(player_status.lives < MAX_LIVES) { + player_status.lives++; play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER); } } Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- worldmap.cpp 15 Apr 2004 19:08:01 -0000 1.25 +++ worldmap.cpp 16 Apr 2004 16:52:18 -0000 1.26 @@ -18,6 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <iostream> +#include <fstream> #include <vector> #include <assert.h> #include "globals.h" @@ -270,6 +271,7 @@ { Level level; LispReader reader(lisp_cdr(element)); + level.solved = false; reader.read_string("name", &level.name); reader.read_int("x", &level.x); reader.read_int("y", &level.y); @@ -438,10 +440,17 @@ { std::cout << "Enter the current level: " << i->name << std::endl;; halt_music(); - GameSession session(datadir + "levels/default/" + i->name, + GameSession session(datadir + "levels/" + i->name, 1, ST_GL_LOAD_LEVEL_FILE); session.run(); + + if (1) // FIXME: insert exit status checker here + i->solved = true; + play_music(song, 1); + show_menu = 0; + menu_reset(); + savegame(std::string(st_save_dir) + "/slot1.stsg"); return; } } @@ -499,11 +508,54 @@ } tux->draw(offset); + draw_status(); +} + +void +WorldMap::draw_status() +{ + char str[80]; + sprintf(str, "%d", player_status.score); + white_text->draw("SCORE", 0, 0); + gold_text->draw(str, 96, 0); + + sprintf(str, "%d", player_status.distros); + white_text->draw_align("COINS", 320-64, 0, A_LEFT, A_TOP); + gold_text->draw_align(str, 320+64, 0, A_RIGHT, A_TOP); + + white_text->draw("LIVES", 480, 0); + if (player_status.lives >= 5) + { + sprintf(str, "%dx", player_status.lives); + gold_text->draw(str, 585, 0); + tux_life->draw(565+(18*3), 0); + } + else + { + for(int i= 0; i < player_status.lives; ++i) + tux_life->draw(565+(18*i),0); + } + + if (!tux->is_moving()) + { + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (i->x == tux->get_tile_pos().x && + i->y == tux->get_tile_pos().y) + { + white_text->draw_align(i->name.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM); + break; + } + } + } } void WorldMap::display() { + show_menu = 0; + menu_reset(); + quit = false; song = load_song(datadir + "/music/" + music); @@ -536,6 +588,32 @@ free_music(song); } +void +WorldMap::savegame(const std::string& filename) +{ + std::ofstream out(filename.c_str()); + + out << "(supertux-savegame\n" + << " (version 1)\n" + << " (lives " << player_status.lives << ")\n" + << " (score " << player_status.score << ")\n" + << " (distros " << player_status.distros << ")\n" + << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")\n" + << " (levels\n"; + + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (i->solved) + { + out << " (level (name \"" << i->name << "\")\n" + << " (solved #t))\n"; + } + } + + out << " )\n" + << " )\n\n;; EOF ;;" << std::endl; +} + } // namespace WorldMapNS void worldmap_run() Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- scene.h 11 Apr 2004 15:33:53 -0000 1.23 +++ scene.h 16 Apr 2004 16:52:18 -0000 1.24 @@ -23,8 +23,12 @@ { int score; int distros; + int lives; + int next_level; int score_multiplier; + + PlayerStatus(); }; extern PlayerStatus player_status; Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- worldmap.h 15 Apr 2004 19:08:02 -0000 1.14 +++ worldmap.h 16 Apr 2004 16:52:18 -0000 1.15 @@ -132,6 +132,7 @@ int x; int y; std::string name; + bool solved; }; typedef std::vector<Level> Levels; @@ -143,6 +144,8 @@ bool enter_level; Point offset; + + void draw_status(); public: WorldMap(); ~WorldMap(); @@ -166,6 +169,8 @@ /** Check if it is possible to walk from \a pos into \a direction, if possible, write the new position to \a new_pos */ bool path_ok(Direction direction, Point pos, Point* new_pos); + + void savegame(const std::string& filename); }; } // namespace WorldMapNS Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- gameloop.cpp 13 Apr 2004 18:39:56 -0000 1.70 +++ gameloop.cpp 16 Apr 2004 16:52:17 -0000 1.71 @@ -117,9 +117,6 @@ time_left.init(true); start_timers(); - - if(st_gl_mode == ST_GL_LOAD_GAME) - loadgame(levelnb); } GameSession::~GameSession() @@ -130,8 +127,6 @@ void GameSession::levelintro(void) { - Player& tux = *world->get_tux(); - char str[60]; /* Level Intro: */ clearscreen(0, 0, 0); @@ -145,7 +140,7 @@ sprintf(str, "by %s", world->get_level()->author.c_str()); red_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1); - sprintf(str, "TUX x %d", tux.lives); + sprintf(str, "TUX x %d", player_status.lives); white_text->drawf(str, 0, 288, A_HMIDDLE, A_TOP, 1); flipscreen(); @@ -267,7 +262,7 @@ break; case SDLK_l: if(debug_mode) - --tux.lives; + --player_status.lives; break; case SDLK_s: if(debug_mode) @@ -375,7 +370,7 @@ /* No more lives!? */ - if (tux.lives < 0) + if (player_status.lives < 0) { if(st_gl_mode != ST_GL_TEST) drawendscreen(); @@ -538,10 +533,6 @@ { process_options_menu(); } - else if(current_menu == save_game_menu ) - { - process_save_game_menu(); - } else if(current_menu == load_game_menu ) { process_load_game_menu(); @@ -658,7 +649,6 @@ void GameSession::drawstatus() { - Player& tux = *world->get_tux(); char str[60]; sprintf(str, "%d", player_status.score); @@ -696,7 +686,7 @@ gold_text->draw(str, screen->h + 60, 40, 1); } - for(int i= 0; i < tux.lives; ++i) + for(int i= 0; i < player_status.lives; ++i) { tux_life->draw(565+(18*i),20); } @@ -714,7 +704,7 @@ sprintf(str, "SCORE: %d", player_status.score); gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1); - sprintf(str, "DISTROS: %d", player_status.distros); + sprintf(str, "COINS: %d", player_status.distros); gold_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1); flipscreen(); @@ -744,100 +734,6 @@ wait_for_event(event,2000,5000,true); } -void -GameSession::savegame(int) -{ -#if 0 - char savefile[1024]; - FILE* fi; - unsigned int ui; - - sprintf(savefile,"%s/slot%d.save",st_save_dir,slot); - - fi = fopen(savefile, "wb"); - - if (fi == NULL) - { - fprintf(stderr, "Warning: I could not open the slot file "); - } - else - { - fputs(level_subset, fi); - fputs("\n", fi); - fwrite(&level,sizeof(int),1,fi); - fwrite(&score,sizeof(int),1,fi); - fwrite(&distros,sizeof(int),1,fi); - fwrite(&scroll_x,sizeof(float),1,fi); - //FIXME:fwrite(&tux,sizeof(Player),1,fi); - //FIXME:timer_fwrite(&tux.invincible_timer,fi); - //FIXME:timer_fwrite(&tux.skidding_timer,fi); - //FIXME:timer_fwrite(&tux.safe_timer,fi); - //FIXME:timer_fwrite(&tux.frame_timer,fi); - timer_fwrite(&time_left,fi); - ui = st_get_ticks(); - fwrite(&ui,sizeof(int),1,fi); - } - fclose(fi); -#endif -} - -void -GameSession::loadgame(int) -{ -#if 0 - char savefile[1024]; - char str[100]; - FILE* fi; - unsigned int ui; - - sprintf(savefile,"%s/slot%d.save",st_save_dir,slot); - - fi = fopen(savefile, "rb"); - - if (fi == NULL) - { - fprintf(stderr, "Warning: I could not open the slot file "); - - } - else - { - fgets(str, 100, fi); - strcpy(level_subset, str); - level_subset[strlen(level_subset)-1] = '\0'; - fread(&level,sizeof(int),1,fi); - - world->set_defaults(); - world->get_level()->cleanup(); - world->arrays_free(); - world->get_level()->free_gfx(); - world->get_level()->free_song(); - - if(world->get_level()->load(level_subset,level) != 0) - exit(1); - - world->activate_bad_guys(); - world->activate_particle_systems(); - world->get_level()->load_gfx(); - world->get_level()->load_song(); - - levelintro(); - update_time = st_get_ticks(); - - fread(&score, sizeof(int),1,fi); - fread(&distros, sizeof(int),1,fi); - fread(&scroll_x,sizeof(float),1,fi); - //FIXME:fread(&tux, sizeof(Player), 1, fi); - //FIXME:timer_fread(&tux.invincible_timer,fi); - //FIXME:timer_fread(&tux.skidding_timer,fi); - //FIXME:timer_fread(&tux.safe_timer,fi); - //FIXME:timer_fread(&tux.frame_timer,fi); - timer_fread(&time_left,fi); - fread(&ui,sizeof(int),1,fi); - fclose(fi); - } -#endif -} - std::string slotinfo(int slot) { FILE* fi; Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- gameloop.h 11 Apr 2004 16:38:58 -0000 1.38 +++ gameloop.h 16 Apr 2004 16:52:17 -0000 1.39 @@ -69,9 +69,6 @@ Level* get_level() { return world->get_level(); } World* get_world() { return world; } - void savegame(int slot); - void loadgame(int slot); - static GameSession* current() { return current_; } private: static GameSession* current_; Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- setup.cpp 13 Apr 2004 14:32:48 -0000 1.38 +++ setup.cpp 16 Apr 2004 16:52:18 -0000 1.39 @@ -40,6 +40,7 @@ #include "gameloop.h" #include "configfile.h" #include "scene.h" +#include "worldmap.h" #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) @@ -455,13 +456,6 @@ } } -void process_save_game_menu() -{ - int slot = save_game_menu->check(); - if (slot != -1) - GameSession::current()->savegame(slot - 1); -} - bool process_load_game_menu() { int slot = load_game_menu->check(); @@ -474,30 +468,14 @@ if (tmp.length() == strlen("Slot X - Free")) { // Slot is free, so start a new game - GameSession session("default", 1, ST_GL_PLAY); - session.run(); - + worldmap_run(); + show_menu = true; Menu::set_current(main_menu); } else { puts("Warning: Loading games isn't supported at the moment"); -#if 0 - // Slot contains a level, so load it - if (game_started) - { - GameSession session("default",slot - 1,ST_GL_LOAD_GAME); - session.run(); - - show_menu = true; - Menu::set_current(main_menu); - } - else - { - //loadgame(slot - 1); - } -#endif } st_pause_ticks_stop(); return true; Index: text.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/text.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- text.h 13 Apr 2004 12:25:22 -0000 1.10 +++ text.h 16 Apr 2004 16:52:18 -0000 1.11 @@ -47,10 +47,10 @@ Text(const std::string& file, int kind, int w, int h); ~Text(); - void draw(const char* text, int x, int y, int shadowsize, int update = NO_UPDATE); + void draw(const char* text, int x, int y, int shadowsize = 1, int update = NO_UPDATE); void draw_chars(Surface* pchars, const char* text, int x, int y, int update = NO_UPDATE); void drawf(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE); - void draw_align(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE); + void draw_align(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize = 1, int update = NO_UPDATE); void erasetext(const char * text, int x, int y, Surface* surf, int update, int shadowsize); void erasecenteredtext(const char * text, int y, Surface* surf, int update, int shadowsize); }; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- player.cpp 16 Apr 2004 16:24:54 -0000 1.37 +++ player.cpp 16 Apr 2004 16:52:17 -0000 1.38 @@ -83,10 +83,7 @@ frame_main = 0; frame_ = 0; - lives = 3; - score = 0; - distros = 0; - + player_input_init(&input); keymap.jump = SDLK_UP; @@ -504,11 +501,11 @@ } /* Enough distros for a One-up? */ - if (distros >= DISTROS_LIFEUP) + if (player_status.distros >= DISTROS_LIFEUP) { - distros = distros - DISTROS_LIFEUP; - if(lives < MAX_LIVES) - lives++; + player_status.distros = player_status.distros - DISTROS_LIFEUP; + if(player_status.lives < MAX_LIVES) + ++player_status.lives; /*We want to hear the sound even, if MAX_LIVES is reached*/ play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER); } @@ -723,9 +720,6 @@ } } - if(dying) - gold_text->drawf("Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1); - if (debug_mode) fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150); } @@ -830,7 +824,7 @@ { /* He died :^( */ - --lives; + --player_status.lives; remove_powerups(); dying = DYING_NOT; } |
From: Ricardo C. <rm...@us...> - 2004-04-16 16:25:04
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/data/images/tilesets Modified Files: supertux.stgt Log Message: This patch was send to the mailing list by Ryan (aka sik0fewl). « I've made it so that sliding on ice works again (after the changes to the input handling functions--looks much nicer now, btw). I also changed supertux.stgt to make snow5.png ice. You can try out sliding around on ice in the second level. I wasn't really sure what would be a good sliding rate so people should try fiddling with different values. Right now the accel/decel rate is the direct inverse of the velocity.. this inverse can be increased or decreased. Also, the smalltux animation doesn't "slide", he walks to a stop.. haven't really looked into where to fix this, but I'm sure others could find it and fix it before I could. » Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- supertux.stgt 16 Apr 2004 14:31:58 -0000 1.15 +++ supertux.stgt 16 Apr 2004 16:24:53 -0000 1.16 @@ -30,7 +30,8 @@ (solid #t)) (tile (id 11) (images "snow5.png") - (solid #t)) + (solid #t) + (ice #t)) (tile (id 12) (images "snow6.png") (solid #t)) |
From: Ricardo C. <rm...@us...> - 2004-04-16 16:25:04
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/src Modified Files: player.cpp Log Message: This patch was send to the mailing list by Ryan (aka sik0fewl). « I've made it so that sliding on ice works again (after the changes to the input handling functions--looks much nicer now, btw). I also changed supertux.stgt to make snow5.png ice. You can try out sliding around on ice in the second level. I wasn't really sure what would be a good sliding rate so people should try fiddling with different values. Right now the accel/decel rate is the direct inverse of the velocity.. this inverse can be increased or decreased. Also, the smalltux animation doesn't "slide", he walks to a stop.. haven't really looked into where to fix this, but I'm sure others could find it and fix it before I could. » Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- player.cpp 13 Apr 2004 18:17:26 -0000 1.36 +++ player.cpp 16 Apr 2004 16:24:54 -0000 1.37 @@ -379,7 +379,20 @@ ax = WALK_ACCELERATION_X * -1.5; } } - + + // if we're on ice slow down acceleration or deceleration + if (isice(base.x, base.y + base.height)) + { + /* the acceleration/deceleration rate on ice is inversely proportional to + * the current velocity. + */ + + // increasing 1 will increase acceleration/deceleration rate + // decreasing 1 will decrease acceleration/deceleration rate + // must stay above zero, though + if (ax != 0) ax *= 1 / fabs(vx); + } + physic.set_velocity(vx, vy); physic.set_acceleration(ax, ay); } |