super-tux-commit Mailing List for Super Tux (Page 103)
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: Ingo R. <gr...@us...> - 2004-03-25 10:37:48
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29834 Modified Files: supertux.stgt Log Message: - made TileManager::get() always return a valid tile - made conversion code more robust against unknown tiles - added next_tile/next_tile2 to replace the old one on some events Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- supertux.stgt 25 Mar 2004 02:29:04 -0000 1.2 +++ supertux.stgt 25 Mar 2004 10:26:59 -0000 1.3 @@ -1,3 +1,5 @@ +;; -*- mode: scheme -*- + (supertux-tiles (properties (id 0)) @@ -86,6 +88,7 @@ (images "bonus1.png") (solid #t) (fullbox #t) + (next-tile 84) (data 1)) (tile (id 27) (images "block1.png") @@ -248,11 +251,15 @@ (tile (id 77) (images "brick0.png") - (brick #t) + (brick #t) + (data 1) + (next-tile 0) (solid #t)) (tile (id 78) (images "brick1.png") (brick #t) + (data 1) + (next-tile 0) (solid #t)) (tile (id 79) @@ -274,6 +281,7 @@ (images "box-full.png") (fullbox #t) (solid #t) + (next-tile 84) (data 1)) (tile (id 84) @@ -304,10 +312,12 @@ (images "box-full.png") (solid #t) (fullbox #t) - (data 2)) + (data 2) + (next-tile 84)) (tile (id 103) (images "box-full.png") (solid #t) (fullbox #t) - (data 3)) + (data 3) + (next-tile 84)) ) \ No newline at end of file |
From: Ingo R. <gr...@us...> - 2004-03-25 10:36:55
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29713 Modified Files: gameloop.cpp level.cpp tile.cpp tile.h Log Message: - made TileManager::get() always return a valid tile - made conversion code more robust against unknown tiles - added next_tile/next_tile2 to replace the old one on some events Index: tile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tile.h 25 Mar 2004 02:13:17 -0000 1.2 +++ tile.h 25 Mar 2004 10:26:07 -0000 1.3 @@ -23,7 +23,10 @@ */ struct Tile { + int id; + std::vector<texture_type> images; + std::vector<std::string> filenames; /** solid tile that is indestructable by Tux */ bool solid; @@ -43,6 +46,11 @@ /** General purpose data attached to a tile (content of a box, type of coin) */ int data; + /** Id of the tile that is going to replace this tile once it has + been collected or jumped at */ + int next_tile; + int next_tile2; + int anim_speed; unsigned char alpha; }; @@ -57,7 +65,19 @@ public: static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); } - Tile* get(unsigned int id) { if( id < tiles.size()) { return tiles[id]; } else { return NULL; } } + Tile* get(unsigned int id) { + if(id < tiles.size()) + { + return tiles[id]; + } + else + { + // Never return 0, but return the 0th tile instead so that + // user code doesn't have to check for NULL pointers all over + // the place + return tiles[0]; + } + } }; #endif Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- level.cpp 25 Mar 2004 02:27:45 -0000 1.13 +++ level.cpp 25 Mar 2004 10:26:07 -0000 1.14 @@ -10,6 +10,7 @@ // // +#include <map> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -300,54 +301,57 @@ // Convert old levels to the new tile numbers if (version == 0) { - int transtable[256]; - transtable[(int)'.'] = 0; - transtable[(int)'0'] = 0; - transtable[(int)'1'] = 1; - transtable[(int)'2'] = 2; - transtable[(int)'x'] = 77; - transtable[(int)'X'] = 77; - transtable[(int)'y'] = 78; - transtable[(int)'Y'] = 78; - transtable[(int)'A'] = 83; - transtable[(int)'B'] = 102; - transtable[(int)'!'] = 103; - transtable[(int)'a'] = 84; - transtable[(int)'C'] = 85; - transtable[(int)'D'] = 86; - transtable[(int)'E'] = 87; - transtable[(int)'F'] = 88; - transtable[(int)'c'] = 89; - transtable[(int)'d'] = 90; - transtable[(int)'e'] = 91; - transtable[(int)'f'] = 92; + std::map<char, int> transtable; + transtable['.'] = 0; + transtable['0'] = 0; + transtable['1'] = 1; + transtable['2'] = 2; + transtable['x'] = 77; + transtable['X'] = 77; + transtable['y'] = 78; + transtable['Y'] = 78; + transtable['A'] = 83; + transtable['B'] = 102; + transtable['!'] = 103; + transtable['a'] = 84; + transtable['C'] = 85; + transtable['D'] = 86; + transtable['E'] = 87; + transtable['F'] = 88; + transtable['c'] = 89; + transtable['d'] = 90; + transtable['e'] = 91; + transtable['f'] = 92; - transtable[(int)'G'] = 93; - transtable[(int)'H'] = 94; - transtable[(int)'I'] = 95; - transtable[(int)'J'] = 96; + transtable['G'] = 93; + transtable['H'] = 94; + transtable['I'] = 95; + transtable['J'] = 96; - transtable[(int)'g'] = 97; - transtable[(int)'h'] = 98; - transtable[(int)'i'] = 99; - transtable[(int)'j'] = 100 -; - transtable[(int)'#'] = 11; - transtable[(int)'['] = 13; - transtable[(int)'='] = 14; - transtable[(int)']'] = 15; - transtable[(int)'$'] = 82; - transtable[(int)'^'] = 76; - transtable[(int)'*'] = 80; - transtable[(int)'|'] = 79; - transtable[(int)'\\'] = 81; - transtable[(int)'&'] = 75; + transtable['g'] = 97; + transtable['h'] = 98; + transtable['i'] = 99; + transtable['j'] = 100 + ; + transtable['#'] = 11; + transtable['['] = 13; + transtable['='] = 14; + transtable[']'] = 15; + transtable['$'] = 82; + transtable['^'] = 76; + transtable['*'] = 80; + transtable['|'] = 79; + transtable['\\'] = 81; + transtable['&'] = 75; for(std::vector<int>::iterator i = ia_tm.begin(); i != ia_tm.end(); ++i) - if (*i < 256) - *i = transtable[*i]; - else - puts("Error: Value to high, conversion will fail"); + { + std::map<char, int>::iterator j = transtable.find(*i); + if (j != transtable.end()) + *i = j->second; + else + printf("Error: conversion will fail, unsupported char: '%c' (%d)\n", *i, *i); + } } } Index: tile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tile.cpp 25 Mar 2004 02:27:45 -0000 1.3 +++ tile.cpp 25 Mar 2004 10:26:07 -0000 1.4 @@ -38,10 +38,8 @@ if (strcmp(lisp_symbol(lisp_car(element)), "tile") == 0) { - int id = 0; - std::vector<std::string> filenames; - - Tile* tile = new Tile; + Tile* tile = new Tile; + tile->id = -1; tile->solid = false; tile->brick = false; tile->ice = false; @@ -49,10 +47,12 @@ tile->distro = false; tile->data = 0; tile->alpha = 0; + tile->next_tile = 0; + tile->next_tile2 = 0; tile->anim_speed = 25; LispReader reader(lisp_cdr(element)); - reader.read_int("id", &id); + assert(reader.read_int("id", &tile->id)); reader.read_bool("solid", &tile->solid); reader.read_bool("brick", &tile->brick); reader.read_bool("ice", &tile->ice); @@ -61,9 +61,13 @@ reader.read_int("data", (int*)&tile->data); reader.read_int("alpha", (int*)&tile->alpha); reader.read_int("anim-speed", &tile->anim_speed); - reader.read_string_vector("images", &filenames); + reader.read_int("next-tile", &tile->next_tile); + reader.read_int("next-tile2", &tile->next_tile2); + reader.read_string_vector("images", &tile->filenames); - for(std::vector<std::string>::iterator it = filenames.begin(); it != filenames.end(); ++it) + for(std::vector<std::string>::iterator it = tile->filenames.begin(); + it != tile->filenames.end(); + ++it) { texture_type cur_image; tile->images.push_back(cur_image); @@ -72,10 +76,10 @@ USE_ALPHA); } - if (id+tileset_id >= int(tiles.size())) - tiles.resize(id+tileset_id+1); + if (tile->id + tileset_id >= int(tiles.size())) + tiles.resize(tile->id + tileset_id+1); - tiles[id+tileset_id] = tile; + tiles[tile->id + tileset_id] = tile; } else if (strcmp(lisp_symbol(lisp_car(element)), "tileset") == 0) { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- gameloop.cpp 25 Mar 2004 02:27:45 -0000 1.25 +++ gameloop.cpp 25 Mar 2004 10:26:07 -0000 1.26 @@ -1327,10 +1327,14 @@ { texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y); } - else + else if (ptile->images.size() == 1) { texture_draw(&ptile->images[0],x,y); } + else + { + printf("Tile not dravable %u\n", c); + } } } @@ -1508,12 +1512,12 @@ void trybreakbrick(float x, float y) { - if (isbrick(x, y)) + Tile* tile = gettile(x, y); + if (tile->brick) { - if (shape(x, y) == 'x' || shape(x, y) == 'y') + if (tile->data > 0) { /* Get a distro from it: */ - add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32); @@ -1524,7 +1528,7 @@ } if (distro_counter <= 0) - level_change(¤t_level,x, y, TM_IA, 'a'); + level_change(¤t_level,x, y, TM_IA, tile->next_tile2); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; @@ -1533,8 +1537,7 @@ else { /* Get rid of it: */ - - level_change(¤t_level,x, y, TM_IA, '.'); + level_change(¤t_level,x, y, TM_IA, tile->next_tile); } @@ -1568,7 +1571,8 @@ void tryemptybox(float x, float y, int col_side) { - if (!isfullbox(x, y)) + Tile* tile = gettile(x,y); + if (!tile->fullbox) return; // according to the collision side, set the upgrade direction @@ -1579,7 +1583,7 @@ col_side = LEFT; // FIXME: Content of boxes must be handled otherwise - switch(gettile(x,y)->data) + switch(tile->data) { case 1: //'A': /* Box with a distro! */ add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); @@ -1602,7 +1606,7 @@ } /* Empty the box: */ - level_change(¤t_level,x, y, TM_IA, 'a'); + level_change(¤t_level,x, y, TM_IA, tile->next_tile); } @@ -1613,7 +1617,7 @@ Tile* tile = gettile(x, y); if (tile && tile->distro) { - level_change(¤t_level,x, y, TM_IA, '.'); + level_change(¤t_level,x, y, TM_IA, tile->next_tile); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); if (bounciness == BOUNCE) |
From: Ingo R. <gr...@us...> - 2004-03-25 02:45:50
|
Update of /cvsroot/super-tux/supertux/contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6100 Modified Files: levelconverter-0.0.6_0.0.7.py Log Message: - fixes for the converter Index: levelconverter-0.0.6_0.0.7.py =================================================================== RCS file: /cvsroot/super-tux/supertux/contrib/levelconverter-0.0.6_0.0.7.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- levelconverter-0.0.6_0.0.7.py 25 Mar 2004 00:24:55 -0000 1.5 +++ levelconverter-0.0.6_0.0.7.py 25 Mar 2004 02:35:07 -0000 1.6 @@ -12,8 +12,8 @@ ['y', "brick1.png", 78], ['Y', "brick1.png", 78], ['A', "box-full.png", 83], - ['B', "box-full.png", 83], - ['!', "box-full.png", 83], + ['B', "box-full.png", 102], + ['!', "box-full.png", 103], ['a', "box-empty.png", 84], ['C', "cloud-00.png", 85], ['D', "cloud-00.png", 86], @@ -23,14 +23,17 @@ ['d', "cloud-00.png", 90], ['e', "cloud-00.png", 91], ['f', "cloud-00.png", 92], - ['g', "bkgd-00.png", 93], - ['h', "bkgd-01.png", 94], - ['i', "bkgd-02.png", 95], - ['j', "bkgd-03.png", 96], - ['G', "bkgd-10.png", 97], - ['H', "bkgd-11.png", 98], - ['I', "bkgd-12.png", 99], - ['J', "bkgd-13.png", 100], + + ['G', "bkgd-00.png", 93], + ['H', "bkgd-01.png", 94], + ['I', "bkgd-02.png", 95], + ['J', "bkgd-03.png", 96], + + ['g', "bkgd-10.png", 97], + ['h', "bkgd-11.png", 98], + ['i', "bkgd-12.png", 99], + ['j', "bkgd-13.png", 100], + ['#', "solid0.png", 11], ['[', "solid1.png", 13], ['=', "solid2.png", 14], @@ -76,6 +79,7 @@ gravity = content[9] print "(supertux-level" +print " (version 1)" print " (name \"%s\")" % name print " (theme \"%s\")" % theme print " (music \"%s\")" % music |
From: Ingo R. <gr...@us...> - 2004-03-25 02:39:47
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4878/images/tilesets Modified Files: supertux.stgt Added Files: coin1.png coin2.png coin3.png Log Message: - fixed up tileset a bit --- NEW FILE: coin3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: coin2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: coin1.png --- (This appears to be a binary file; contents omitted.) Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- supertux.stgt 25 Mar 2004 01:30:44 -0000 1.1 +++ supertux.stgt 25 Mar 2004 02:29:04 -0000 1.2 @@ -1,6 +1,8 @@ (supertux-tiles (properties (id 0)) + ;; Zero tile + (tile (id 0)) (tile (id 1) (images "background1.png") @@ -83,7 +85,8 @@ (tile (id 26) (images "bonus1.png") (solid #t) - (fullbox #t)) + (fullbox #t) + (data 1)) (tile (id 27) (images "block1.png") (solid #t)) @@ -137,16 +140,18 @@ (images "darksnow12.png") (solid #t)) -;; (tile (id 44) -;; (images "coin1.png") -; (solid #t)) -; (tile (id 45) -; (images "coin2.png") -; (solid #t)) -; (tile (id 46) -; (images "coin3.png") -; (solid #t)) - + (tile (id 44) + (images "coin1.png" "coin2.png" "coin3.png") + (distro #t) + (anim-speed 25)) + (tile (id 45) + (images "coin1.png" "coin2.png" "coin3.png") + (distro #t) + (anim-speed 25)) + (tile (id 46) + (images "coin1.png" "coin2.png" "coin3.png") + (distro #t) + (anim-speed 25)) (tile (id 47) (images "block4.png") @@ -243,12 +248,12 @@ (tile (id 77) (images "brick0.png") - (solid #t) - (solid #t)) + (brick #t) + (solid #t)) (tile (id 78) (images "brick1.png") - (solid #t) - (brick #t)) + (brick #t) + (solid #t)) (tile (id 79) (images "pole.png") @@ -259,15 +264,20 @@ (tile (id 81) (images "flag-0.png" "flag-1.png") (solid #f)) + (tile (id 82) (images "distro-0.png" "distro-1.png" "distro-2.png" "distro-3.png") - (solid #f)) + (solid #f) + (distro #t)) (tile (id 83) (images "box-full.png") + (fullbox #t) + (solid #t) (data 1)) (tile (id 84) + (solid #t) (images "box-empty.png")) @@ -292,8 +302,12 @@ (tile (id 102) (images "box-full.png") + (solid #t) + (fullbox #t) (data 2)) (tile (id 103) (images "box-full.png") + (solid #t) + (fullbox #t) (data 3)) ) \ No newline at end of file |
From: Ingo R. <gr...@us...> - 2004-03-25 02:38:32
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4583 Modified Files: gameloop.cpp gameloop.h level.cpp player.cpp tile.cpp Log Message: - fixed bricktile Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- player.cpp 25 Mar 2004 02:13:17 -0000 1.12 +++ player.cpp 25 Mar 2004 02:27:45 -0000 1.13 @@ -15,6 +15,7 @@ #include "player.h" #include "defines.h" #include "scene.h" +#include "tile.h" #include "screen.h" texture_type tux_life; @@ -243,8 +244,8 @@ if(size == SMALL) { /* Get a distro from a brick? */ - if (shape(base.x, base.y) == 'x' || - shape(base.x, base.y) == 'y') + if (gettile(base.x, base.y)->brick || + gettile(base.x, base.y)->brick) { add_bouncy_distro((((int)base.x) / 32) * 32, @@ -262,8 +263,8 @@ score = score + SCORE_DISTRO; distros++; } - else if (shape(base.x+ 31, base.y) == 'x' || - shape(base.x+ 31, base.y) == 'y') + else if (gettile(base.x+ 31, base.y)->brick || + gettile(base.x+ 31, base.y)->brick) { add_bouncy_distro((((int)base.x + 31) / 32) * 32, Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gameloop.h 24 Mar 2004 22:23:48 -0000 1.19 +++ gameloop.h 25 Mar 2004 02:27:45 -0000 1.20 @@ -28,7 +28,9 @@ extern st_level current_level; /* Function prototypes: */ +class Tile; +Tile* gettile(float x, float y); int gameloop(const char * subset, int levelnb, int mode); void savegame(int slot); void loadgame(int slot); Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- level.cpp 25 Mar 2004 02:13:17 -0000 1.12 +++ level.cpp 25 Mar 2004 02:27:45 -0000 1.13 @@ -290,7 +290,10 @@ reader.read_string("background", &plevel->bkgd_image); reader.read_string("particle_system", &plevel->particle_system); reader.read_int_vector("background-tm", &bg_tm); - reader.read_int_vector("interactive-tm", &ia_tm); + + if (!reader.read_int_vector("interactive-tm", &ia_tm)) + reader.read_int_vector("tilemap", &ia_tm); + reader.read_int_vector("dynamic-tm", &dn_tm); reader.read_int_vector("foreground-tm", &fg_tm); @@ -614,8 +617,6 @@ /* Change the size of a level (width) */ void level_change_size (st_level* plevel, int new_width) { - int y; - if(new_width < 21) new_width = 21; tilemap_change_size((unsigned int***)&plevel->ia_tiles,new_width,plevel->width); Index: tile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tile.cpp 25 Mar 2004 02:13:17 -0000 1.2 +++ tile.cpp 25 Mar 2004 02:27:45 -0000 1.3 @@ -42,13 +42,13 @@ std::vector<std::string> filenames; Tile* tile = new Tile; - tile->solid = false; - tile->brick = false; - tile->ice = false; + tile->solid = false; + tile->brick = false; + tile->ice = false; tile->fullbox = false; - tile->alpha = 0; - tile->distro = 0; - tile->data = 0; + tile->distro = false; + tile->data = 0; + tile->alpha = 0; tile->anim_speed = 25; LispReader reader(lisp_cdr(element)); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- gameloop.cpp 25 Mar 2004 02:13:17 -0000 1.24 +++ gameloop.cpp 25 Mar 2004 02:27:45 -0000 1.25 @@ -1318,17 +1318,19 @@ void drawshape(float x, float y, unsigned int c) { - Tile* ptile = TileManager::instance()->get - (c); - if(ptile) + if (c != 0) { - if(ptile->images.size() > 1) - { - texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y); - } - else + Tile* ptile = TileManager::instance()->get(c); + if(ptile) { - texture_draw(&ptile->images[0],x,y); + if(ptile->images.size() > 1) + { + texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y); + } + else + { + texture_draw(&ptile->images[0],x,y); + } } } |
From: Ingo R. <gr...@us...> - 2004-03-25 02:24:03
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2089 Modified Files: gameloop.cpp level.cpp player.cpp tile.cpp tile.h Log Message: - added translation table for the old format Index: tile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tile.h 24 Mar 2004 22:25:33 -0000 1.1 +++ tile.h 25 Mar 2004 02:13:17 -0000 1.2 @@ -23,27 +23,41 @@ */ struct Tile { -std::vector<texture_type> images; -bool solid; -bool brick; -bool ice; -bool fullbox; -int anim_speed; -unsigned char alpha; + std::vector<texture_type> images; + + /** solid tile that is indestructable by Tux */ + bool solid; + + /** a brick that can be destroyed by jumping under it */ + bool brick; + + /** FIXME: ? */ + bool ice; + + /** Bonusbox, content is stored in \a data */ + bool fullbox; + + /** Tile is a distro/coin */ + bool distro; + + /** General purpose data attached to a tile (content of a box, type of coin) */ + int data; + + int anim_speed; + unsigned char alpha; }; class TileManager { -private: - TileManager(); - std::vector<Tile*> tiles; - static TileManager* instance_ ; - void load_tileset(std::string filename); + private: + TileManager(); + std::vector<Tile*> tiles; + static TileManager* instance_ ; + void load_tileset(std::string filename); -public: - static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); } - Tile* get(unsigned int id) { if( id < tiles.size()) { return tiles[id]; } else { return NULL; } } ; - + public: + static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); } + Tile* get(unsigned int id) { if( id < tiles.size()) { return tiles[id]; } else { return NULL; } } }; #endif Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- player.cpp 24 Mar 2004 22:23:48 -0000 1.11 +++ player.cpp 25 Mar 2004 02:13:17 -0000 1.12 @@ -62,8 +62,10 @@ size = SMALL; got_coffee = false; - base.x = 0; + // FIXME: Make the start position configurable via the levelfile + base.x = 100; base.y = 240; + base.xm = 0; base.ym = 0; old_base = base; @@ -130,8 +132,8 @@ void Player::level_begin() { - base.x = 0; - base.y = 240; + base.x = 100; + base.y = 240; base.xm = 0; base.ym = 0; old_base = base; @@ -241,7 +243,6 @@ if(size == SMALL) { /* Get a distro from a brick? */ - if (shape(base.x, base.y) == 'x' || shape(base.x, base.y) == 'y') { Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- level.cpp 24 Mar 2004 22:23:48 -0000 1.11 +++ level.cpp 25 Mar 2004 02:13:17 -0000 1.12 @@ -249,7 +249,6 @@ int level_load(st_level* plevel, const char* filename) { - int x, y, j; FILE * fi; lisp_object_t* root_obj = 0; fi = fopen(filename, "r"); @@ -273,10 +272,12 @@ vector<int> bg_tm; vector<int> fg_tm; + int version = 0; if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) { LispReader reader(lisp_cdr(root_obj)); + reader.read_int("version", &version); reader.read_int("width", &plevel->width); reader.read_int("time", &plevel->time_left); reader.read_int("bkgd_red", &plevel->bkgd_red); @@ -289,14 +290,65 @@ reader.read_string("background", &plevel->bkgd_image); reader.read_string("particle_system", &plevel->particle_system); reader.read_int_vector("background-tm", &bg_tm); - reader.read_int_vector("interactive-tm", &ia_tm); - reader.read_int_vector("dynamic-tm", &dn_tm); + reader.read_int_vector("interactive-tm", &ia_tm); + reader.read_int_vector("dynamic-tm", &dn_tm); reader.read_int_vector("foreground-tm", &fg_tm); - } + // Convert old levels to the new tile numbers + if (version == 0) + { + int transtable[256]; + transtable[(int)'.'] = 0; + transtable[(int)'0'] = 0; + transtable[(int)'1'] = 1; + transtable[(int)'2'] = 2; + transtable[(int)'x'] = 77; + transtable[(int)'X'] = 77; + transtable[(int)'y'] = 78; + transtable[(int)'Y'] = 78; + transtable[(int)'A'] = 83; + transtable[(int)'B'] = 102; + transtable[(int)'!'] = 103; + transtable[(int)'a'] = 84; + transtable[(int)'C'] = 85; + transtable[(int)'D'] = 86; + transtable[(int)'E'] = 87; + transtable[(int)'F'] = 88; + transtable[(int)'c'] = 89; + transtable[(int)'d'] = 90; + transtable[(int)'e'] = 91; + transtable[(int)'f'] = 92; - int i; - for( i = 0; i < 15; ++i) + transtable[(int)'G'] = 93; + transtable[(int)'H'] = 94; + transtable[(int)'I'] = 95; + transtable[(int)'J'] = 96; + + transtable[(int)'g'] = 97; + transtable[(int)'h'] = 98; + transtable[(int)'i'] = 99; + transtable[(int)'j'] = 100 +; + transtable[(int)'#'] = 11; + transtable[(int)'['] = 13; + transtable[(int)'='] = 14; + transtable[(int)']'] = 15; + transtable[(int)'$'] = 82; + transtable[(int)'^'] = 76; + transtable[(int)'*'] = 80; + transtable[(int)'|'] = 79; + transtable[(int)'\\'] = 81; + transtable[(int)'&'] = 75; + + for(std::vector<int>::iterator i = ia_tm.begin(); i != ia_tm.end(); ++i) + if (*i < 256) + *i = transtable[*i]; + else + puts("Error: Value to high, conversion will fail"); + } + } + + for(int i = 0; i < 15; ++i) { plevel->dn_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); plevel->ia_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); @@ -304,10 +356,10 @@ plevel->fg_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); } - i = j = 0; + int i = 0; + int j = 0; for(vector<int>::iterator it = ia_tm.begin(); it != ia_tm.end(); ++it, ++i) { - plevel->ia_tiles[j][i] = (*it); if(i == plevel->width - 1) { @@ -358,16 +410,16 @@ /* Mark the end position of this level! - Is a bit wrong here thought * / for (y = 0; y < 15; ++y) - { - for (x = 0; x < plevel->width; ++x) - { - if(plevel->tiles[y][x] == '|') - { - if(x*32 > endpos) - endpos = x*32; - } - } - }*/ + { + for (x = 0; x < plevel->width; ++x) + { + if(plevel->tiles[y][x] == '|') + { + if(x*32 > endpos) + endpos = x*32; + } + } + }*/ fclose(fi); return 0; @@ -402,6 +454,7 @@ fprintf(fi,";SuperTux-Level\n"); fprintf(fi,"(supertux-level\n"); + fprintf(fi," (version %d)\n", 1); fprintf(fi," (name \"%s\")\n", plevel->name.c_str()); fprintf(fi," (theme \"%s\")\n", plevel->theme.c_str()); fprintf(fi," (music \"%s\")\n", plevel->song_title.c_str()); Index: tile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tile.cpp 24 Mar 2004 22:25:33 -0000 1.1 +++ tile.cpp 25 Mar 2004 02:13:17 -0000 1.2 @@ -16,7 +16,7 @@ TileManager::TileManager() { - std::string filename = datadir + "images/tilesets/main.stgt"; + std::string filename = datadir + "images/tilesets/supertux.stgt"; load_tileset(filename); } @@ -46,7 +46,9 @@ tile->brick = false; tile->ice = false; tile->fullbox = false; - tile->alpha = 0; + tile->alpha = 0; + tile->distro = 0; + tile->data = 0; tile->anim_speed = 25; LispReader reader(lisp_cdr(element)); @@ -55,18 +57,20 @@ reader.read_bool("brick", &tile->brick); reader.read_bool("ice", &tile->ice); reader.read_bool("fullbox", &tile->fullbox); + reader.read_bool("distro", &tile->distro); + reader.read_int("data", (int*)&tile->data); reader.read_int("alpha", (int*)&tile->alpha); reader.read_int("anim-speed", &tile->anim_speed); reader.read_string_vector("images", &filenames); for(std::vector<std::string>::iterator it = filenames.begin(); it != filenames.end(); ++it) - { - texture_type cur_image; - tile->images.push_back(cur_image); - texture_load(&tile->images[tile->images.size()-1], - datadir + "images/tilesets/" + (*it), - USE_ALPHA); - } + { + texture_type cur_image; + tile->images.push_back(cur_image); + texture_load(&tile->images[tile->images.size()-1], + datadir + "images/tilesets/" + (*it), + USE_ALPHA); + } if (id+tileset_id >= int(tiles.size())) tiles.resize(id+tileset_id+1); @@ -100,3 +104,6 @@ assert(0); } } + +// EOF // + Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- gameloop.cpp 24 Mar 2004 22:23:48 -0000 1.23 +++ gameloop.cpp 25 Mar 2004 02:13:17 -0000 1.24 @@ -1318,8 +1318,6 @@ void drawshape(float x, float y, unsigned int c) { - int z; - Tile* ptile = TileManager::instance()->get (c); if(ptile) @@ -1396,7 +1394,6 @@ /* What shape is at some position? */ - unsigned int shape(float x, float y) { @@ -1416,6 +1413,11 @@ return(c); } +Tile* gettile(float x, float y) +{ + return TileManager::instance()->get(shape(x, y)); +} + /* Is is ground? */ @@ -1494,6 +1496,12 @@ } } +bool isdistro(float x, float y) +{ + Tile* tile = TileManager::instance()->get(shape(x,y)); + return tile && tile->distro; +} + /* Break a brick: */ void trybreakbrick(float x, float y) @@ -1568,22 +1576,23 @@ else col_side = LEFT; - switch(shape(x,y)) + // FIXME: Content of boxes must be handled otherwise + switch(gettile(x,y)->data) { - case 'A': /* Box with a distro! */ + case 1: //'A': /* Box with a distro! */ add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; distros++; break; - case 'B': /* Add an upgrade! */ + case 2: // 'B': /* Add an upgrade! */ if (tux.size == SMALL) /* Tux is small, add mints! */ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_MINTS); else /* Tux is big, add coffee: */ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_COFFEE); play_sound(sounds[SND_UPGRADE], SOUND_CENTER_SPEAKER); break; - case '!': /* Add a golden herring */ + case 3:// '!': /* Add a golden herring */ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_HERRING); break; default: @@ -1599,7 +1608,8 @@ void trygrabdistro(float x, float y, int bounciness) { - if (shape(x, y) == '$') + Tile* tile = gettile(x, y); + if (tile && tile->distro) { level_change(¤t_level,x, y, TM_IA, '.'); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); |
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27605 Added Files: bkgd-00.png bkgd-01.png bkgd-02.png bkgd-03.png bkgd-10.png bkgd-11.png bkgd-12.png bkgd-13.png bonus1.png box-empty.png box-full.png distro-0.png distro-1.png distro-2.png distro-3.png flag-0.png flag-1.png pipe1.png pipe2.png pipe3.png pipe4.png pipe5.png pipe6.png pipe7.png pipe8.png pole.png poletop.png supertux.stgt Log Message: - created a tileset that is compatible with the old levels and the new ones --- NEW FILE: pipe2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-01.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-12.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-13.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe8.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: distro-2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: flag-1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: box-empty.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: poletop.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-00.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe7.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-03.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pipe5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: distro-1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: distro-0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: distro-3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-02.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: box-full.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: flag-0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: supertux.stgt --- (supertux-tiles (properties (id 0)) (tile (id 1) (images "background1.png") (solid #f)) (tile (id 2) (images "background2.png") (solid #f)) (tile (id 3) (images "background3.png") (solid #f)) (tile (id 4) (images "background4.png") (solid #f)) (tile (id 5) (images "background5.png") (solid #f)) (tile (id 6) (images "background6.png") (solid #f)) (tile (id 7) (images "snow1.png") (solid #f)) (tile (id 8) (images "snow2.png") (solid #f)) (tile (id 9) (images "snow3.png") (solid #f)) (tile (id 10) (images "snow4.png") (solid #t)) (tile (id 11) (images "snow5.png") (solid #t)) (tile (id 12) (images "snow6.png") (solid #t)) (tile (id 13) (images "snow7.png") (solid #t)) (tile (id 14) (images "snow8.png") (solid #t)) (tile (id 15) (images "snow9.png") (solid #t)) (tile (id 16) (images "snow10.png") (solid #t)) (tile (id 17) (images "snow11.png") (solid #t)) (tile (id 18) (images "snow12.png") (solid #t)) (tile (id 19) (images "snow13.png") (solid #t)) (tile (id 20) (images "snow14.png") (solid #t)) (tile (id 21) (images "snow15.png") (solid #t)) (tile (id 22) (images "snow16.png") (solid #t)) (tile (id 23) (images "snow17.png") (solid #t)) (tile (id 24) (images "background7.png") (solid #f)) (tile (id 25) (images "background8.png") (solid #f)) (tile (id 26) (images "bonus1.png") (solid #t) (fullbox #t)) (tile (id 27) (images "block1.png") (solid #t)) (tile (id 28) (images "block2.png") (solid #t)) (tile (id 29) (images "block3.png") (solid #t)) (tile (id 30) (images "snow18.png") (solid #t)) (tile (id 31) (images "snow19.png") (solid #t)) (tile (id 32) (images "darksnow1.png") (solid #f)) (tile (id 33) (images "darksnow2.png") (solid #f)) (tile (id 34) (images "darksnow3.png") (solid #f)) (tile (id 35) (images "darksnow4.png") (solid #t)) (tile (id 36) (images "darksnow5.png") (solid #t)) (tile (id 37) (images "darksnow6.png") (solid #t)) (tile (id 38) (images "darksnow7.png") (solid #t)) (tile (id 39) (images "darksnow8.png") (solid #t)) (tile (id 40) (images "darksnow9.png") (solid #t)) (tile (id 41) (images "darksnow10.png") (solid #t)) (tile (id 42) (images "darksnow11.png") (solid #t)) (tile (id 43) (images "darksnow12.png") (solid #t)) ;; (tile (id 44) ;; (images "coin1.png") ; (solid #t)) ; (tile (id 45) ; (images "coin2.png") ; (solid #t)) ; (tile (id 46) ; (images "coin3.png") ; (solid #t)) (tile (id 47) (images "block4.png") (solid #t)) (tile (id 48) (images "block5.png") (solid #t)) (tile (id 49) (images "block6.png") (solid #t)) (tile (id 50) (images "block7.png") (solid #t)) (tile (id 51) (images "block8.png") (solid #t)) (tile (id 52) (images "block9.png") (solid #t)) (tile (id 53) (images "pipe1.png") (solid #t)) (tile (id 54) (images "pipe2.png") (solid #t)) (tile (id 55) (images "pipe3.png") (solid #t)) (tile (id 56) (images "pipe4.png") (solid #t)) (tile (id 57) (images "pipe5.png") (solid #t)) (tile (id 58) (images "pipe6.png") (solid #t)) (tile (id 59) (images "pipe7.png") (solid #t)) (tile (id 60) (images "pipe8.png") (solid #t)) (tile (id 61) (images "block10.png") (solid #t)) (tile (id 62) (images "block11.png") (solid #t)) ; (tile (id 63) ; (images "backgroundtile1.png") ; (solid #t)) (tile (id 64) (images "grey.png") (solid #t)) (tile (id 65) (images "grey2.png") (solid #t)) (tile (id 66) (images "grey3.png") (solid #t)) (tile (id 67) (images "grey4.png") (solid #t)) (tile (id 68) (images "grey5.png") (solid #t)) (tile (id 69) (images "grey6.png") (solid #t)) (tile (id 70) (images "backgroundtile1.png") (solid #t)) (tile (id 71) (images "backgroundtile2.png") (solid #t)) (tile (id 72) (images "backgroundtile3.png") (solid #t)) (tile (id 73) (images "backgroundtile4.png") (solid #t)) (tile (id 74) (images "backgroundtile5.png") (solid #t)) (tile (id 75) (images "water.png")) (tile (id 76) (images "waves-0.png" "waves-1.png" "waves-2.png") (anim-speed 25)) (tile (id 77) (images "brick0.png") (solid #t) (solid #t)) (tile (id 78) (images "brick1.png") (solid #t) (brick #t)) (tile (id 79) (images "pole.png") (solid #f)) (tile (id 80) (images "poletop.png") (solid #f)) (tile (id 81) (images "flag-0.png" "flag-1.png") (solid #f)) (tile (id 82) (images "distro-0.png" "distro-1.png" "distro-2.png" "distro-3.png") (solid #f)) (tile (id 83) (images "box-full.png") (data 1)) (tile (id 84) (images "box-empty.png")) (tile (id 85) (images "cloud-00.png")) (tile (id 86) (images "cloud-01.png")) (tile (id 87) (images "cloud-02.png")) (tile (id 88) (images "cloud-03.png")) (tile (id 89) (images "cloud-10.png")) (tile (id 90) (images "cloud-11.png")) (tile (id 91) (images "cloud-12.png")) (tile (id 92) (images "cloud-13.png")) (tile (id 93) (images "bkgd-00.png")) (tile (id 94) (images "bkgd-01.png")) (tile (id 95) (images "bkgd-02.png")) (tile (id 96) (images "bkgd-03.png")) (tile (id 97) (images "bkgd-10.png")) (tile (id 98) (images "bkgd-11.png")) (tile (id 99) (images "bkgd-12.png")) (tile (id 100) (images "bkgd-13.png")) (tile (id 101) (images "bkgd-00.png")) (tile (id 102) (images "box-full.png") (data 2)) (tile (id 103) (images "box-full.png") (data 3)) ) --- NEW FILE: bkgd-11.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pole.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bonus1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bkgd-10.png --- (This appears to be a binary file; contents omitted.) |
From: Ingo R. <gr...@us...> - 2004-03-25 00:35:39
|
Update of /cvsroot/super-tux/supertux/contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15247 Modified Files: levelconverter-0.0.6_0.0.7.py Log Message: fixed converter to handle the new format Index: levelconverter-0.0.6_0.0.7.py =================================================================== RCS file: /cvsroot/super-tux/supertux/contrib/levelconverter-0.0.6_0.0.7.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- levelconverter-0.0.6_0.0.7.py 24 Mar 2004 22:39:36 -0000 1.4 +++ levelconverter-0.0.6_0.0.7.py 25 Mar 2004 00:24:55 -0000 1.5 @@ -2,6 +2,53 @@ import sys +translate_array \ + =[['.', "none", 0], + ['0', "enemy0", 0], + ['1', "enemy1", 1], + ['2', "enemy2", 2], + ['x', "brick0.png", 77], + ['X', "brick0.png", 77], + ['y', "brick1.png", 78], + ['Y', "brick1.png", 78], + ['A', "box-full.png", 83], + ['B', "box-full.png", 83], + ['!', "box-full.png", 83], + ['a', "box-empty.png", 84], + ['C', "cloud-00.png", 85], + ['D', "cloud-00.png", 86], + ['E', "cloud-00.png", 87], + ['F', "cloud-00.png", 88], + ['c', "cloud-00.png", 89], + ['d', "cloud-00.png", 90], + ['e', "cloud-00.png", 91], + ['f', "cloud-00.png", 92], + ['g', "bkgd-00.png", 93], + ['h', "bkgd-01.png", 94], + ['i', "bkgd-02.png", 95], + ['j', "bkgd-03.png", 96], + ['G', "bkgd-10.png", 97], + ['H', "bkgd-11.png", 98], + ['I', "bkgd-12.png", 99], + ['J', "bkgd-13.png", 100], + ['#', "solid0.png", 11], + ['[', "solid1.png", 13], + ['=', "solid2.png", 14], + [']', "solid3.png", 15], + ['$', "distro", 82], + ['^', "water", 76], + ['*', "poletop.png", 80], + ['|', "pole.png", 79], + ['\\',"flag.png", 81], + ['&', "water.png", 75]] + +def translate(c): + for i in translate_array: + if c == i[0]: + return i[2] + print >>sys.stderr, "Couldn't translate tile %s" % c + return 0 + if len(sys.argv) != 2: print "Usage: %s FILENAME" % sys.argv[0] sys.exit() @@ -39,10 +86,10 @@ print " (time %s)" % time print " (width %s)" % width print " (gravity %s)" % gravity -print " (tilemap " +print " (interactive-tm " for i in content[10:]: for x in i: - sys.stdout.write("%3d" % ord(x)) + sys.stdout.write("%3d" % translate(x)) sys.stdout.write(" ") print "" print " )" |
From: Ingo R. <gr...@us...> - 2004-03-24 22:50:20
|
Update of /cvsroot/super-tux/supertux/contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18309 Modified Files: levelconverter-0.0.6_0.0.7.py Log Message: fixed incorrect color handling Index: levelconverter-0.0.6_0.0.7.py =================================================================== RCS file: /cvsroot/super-tux/supertux/contrib/levelconverter-0.0.6_0.0.7.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- levelconverter-0.0.6_0.0.7.py 20 Mar 2004 21:35:25 -0000 1.3 +++ levelconverter-0.0.6_0.0.7.py 24 Mar 2004 22:39:36 -0000 1.4 @@ -22,8 +22,8 @@ music = content[3] background = content[4] red = content[5] -blue = content[6] -green = content[7] +green = content[6] +blue = content[7] width = content[8] height = "15" gravity = content[9] |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:43:45
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17021/data/images/shared Added Files: cloud.png snow0.png snow1.png snow2.png Log Message: images for particle_sytem --- NEW FILE: cloud.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow2.png --- (This appears to be a binary file; contents omitted.) |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:42:30
|
Update of /cvsroot/super-tux/supertux/data/levels/default In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16718/data/levels/default Modified Files: level1.stl Log Message: added line for use of particle_system Index: level1.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/default/level1.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level1.stl 20 Mar 2004 22:08:46 -0000 1.1 +++ level1.stl 24 Mar 2004 22:31:47 -0000 1.2 @@ -4,13 +4,14 @@ (theme "antarctica") (music "Mortimers_chipdisko.mod") (background "arctis.png") + (particle_system "snow") (bkgd_red 128) (bkgd_green 255) (bkgd_blue 192) (time 111) (width 375) (gravity 10) - (tilemap + (interactive-tm 46 46 46 46 46 46 99 100 101 102 46 46 46 46 46 46 50 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 100 101 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 99 100 101 102 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 67 68 69 68 69 70 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 91 46 46 46 46 46 46 46 46 46 42 46 46 46 46 46 46 |
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16146/data/images/tilesets Added Files: background1.png background2.png background3.png background4.png background5.png background6.png background7.png background8.png background.stgt backgroundtile1.png backgroundtile2.png backgroundtile3.png backgroundtile4.png backgroundtile5.png block10.png block11.png block1.png block2.png block3.png block4.png block5.png block6.png block7.png block8.png block9.png block.stgt brick0.png brick1.png cloud-00.png cloud-01.png cloud-02.png cloud-03.png cloud-10.png cloud-11.png cloud-12.png cloud-13.png darksnow10.png darksnow11.png darksnow12.png darksnow1.png darksnow2.png darksnow3.png darksnow4.png darksnow5.png darksnow6.png darksnow7.png darksnow8.png darksnow9.png darksnow.stgt grey2.png grey3.png grey4.png grey5.png grey6.png grey.png grey.stgt main.stgt misc.stgt snow10.png snow11.png snow12.png snow13.png snow14.png snow15.png snow16.png snow17.png snow18.png snow19.png snow1.png snow2.png snow3.png snow4.png snow5.png snow6.png snow7.png snow8.png snow9.png snow.stgt water.png waves-0.png waves-1.png waves-2.png Log Message: the new tiles and tileset-definitions for the new levelformat. (most tiles were contributed by Ingo Ruhnke) --- NEW FILE: snow13.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow7.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow18.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: backgroundtile1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: backgroundtile2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow19.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block7.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow9.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow11.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-00.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block8.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: brick0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow9.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: backgroundtile5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow12.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow10.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow17.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block9.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow15.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow14.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 1)) (tile (id 1) (images "block1.png") (solid #t)) (tile (id 2) (images "block2.png") (solid #t)) (tile (id 3) (images "block3.png") (solid #t)) (tile (id 4) (images "block4.png") (solid #t)) (tile (id 5) (images "block5.png") (solid #t)) (tile (id 6) (images "block6.png") (solid #t)) (tile (id 7) (images "block7.png") (solid #t)) (tile (id 8) (images "block8.png") (solid #t)) (tile (id 9) (images "block9.png") (solid #t)) (tile (id 10) (images "block10.png") (solid #t)) ) --- NEW FILE: background6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: misc.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 2)) (tile (id 1) (images "water.png")) (tile (id 2) (images "waves-0.png" "waves-1.png" "waves-2.png") (anim-speed 25)) (tile (id 3) (images "brick0.png") (solid #t)) (tile (id 4) (images "brick1.png") (solid #t)) ) --- NEW FILE: waves-0.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: waves-2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-11.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-12.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 4)) (tile (id 1) (images "grey.png") (solid #t)) (tile (id 2) (images "grey2.png") (solid #t)) (tile (id 3) (images "grey3.png") (solid #t)) (tile (id 4) (images "grey4.png") (solid #t)) (tile (id 5) (images "grey5.png") (solid #t)) (tile (id 6) (images "grey6.png") (solid #t)) ) --- NEW FILE: cloud-10.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: backgroundtile3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: brick1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow11.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow10.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow16.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: backgroundtile4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: waves-1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow8.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block2.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 3)) (tile (id 1) (images "darksnow1.png") (solid #t)) (tile (id 2) (images "darksnow2.png") (solid #t)) (tile (id 3) (images "darksnow3.png") (solid #t)) (tile (id 4) (images "darksnow4.png") (solid #t)) (tile (id 5) (images "darksnow5.png") (solid #t)) (tile (id 6) (images "darksnow6.png") (solid #t)) (tile (id 7) (images "darksnow7.png") (solid #t)) (tile (id 8) (images "darksnow8.png") (solid #t)) (tile (id 9) (images "darksnow9.png") (solid #t)) (tile (id 10) (images "darksnow10.png") (solid #t)) (tile (id 11) (images "darksnow11.png") (solid #t)) (tile (id 12) (images "darksnow12.png") (solid #t)) ) --- NEW FILE: cloud-01.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-13.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background8.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: water.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block11.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey3.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 0)) (tile (id 1) (images "background1.png")) (tile (id 2) (images "background2.png")) (tile (id 3) (images "background3.png")) (tile (id 4) (images "background4.png")) (tile (id 5) (images "background5.png")) (tile (id 6) (images "background6.png")) (tile (id 7) (images "background7.png")) (tile (id 9) (images "backgroundtile1.png")) (tile (id 10) (images "backgroundtile2.png")) (tile (id 11) (images "backgroundtile3.png")) (tile (id 12) (images "backgroundtile4.png")) (tile (id 13) (images "backgroundtile5.png")) (tile (id 14) (images "cloud-00.png")) (tile (id 15) (images "cloud-01.png")) (tile (id 16) (images "cloud-02.png")) (tile (id 17) (images "cloud-03.png")) (tile (id 18) (images "cloud-10.png")) (tile (id 19) (images "cloud-11.png")) (tile (id 20) (images "cloud-12.png")) (tile (id 21) (images "cloud-13.png")) ) --- NEW FILE: block4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: grey4.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block6.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background7.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: block1.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow12.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow7.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-03.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cloud-02.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: main.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (tileset (file "background.stgt")) (tileset (file "block.stgt")) (tileset (file "misc.stgt")) (tileset (file "darksnow.stgt")) (tileset (file "grey.stgt")) (tileset (file "snow.stgt")) ) --- NEW FILE: block5.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow.stgt --- ;SuperTux-Tile-Definition (supertux-tiles (properties (id 5)) (tile (id 1) (images "snow1.png")) (tile (id 2) (images "snow2.png")) (tile (id 3) (images "snow3.png")) (tile (id 4) (images "snow4.png") (solid #t)) (tile (id 5) (images "snow5.png") (solid #t)) (tile (id 6) (images "snow6.png") (solid #t)) (tile (id 7) (images "snow7.png") (solid #t)) (tile (id 8) (images "snow8.png") (solid #t)) (tile (id 9) (images "snow9.png") (solid #t)) (tile (id 10) (images "snow10.png")) (tile (id 11) (images "snow11.png")) (tile (id 12) (images "snow12.png")) (tile (id 13) (images "snow13.png") (solid #t)) (tile (id 14) (images "snow14.png") (solid #t)) (tile (id 15) (images "snow15.png") (solid #t)) (tile (id 16) (images "snow16.png") (solid #t)) (tile (id 17) (images "snow17.png") (solid #t)) (tile (id 18) (images "snow18.png") (solid #t)) (tile (id 19) (images "snow19.png") (solid #t)) ) --- NEW FILE: block10.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: darksnow8.png --- (This appears to be a binary file; contents omitted.) |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:37:13
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15631/data/images/tilesets Log Message: Directory /cvsroot/super-tux/supertux/data/images/tilesets added to the repository |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:36:15
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15368/src Added Files: tile.cpp tile.h Log Message: new levelformat with multiple layers and and new tileset code. Along with a new particlesystem. (the latest one was contributed by Matze Braun) --- NEW FILE: tile.h --- // // C++ Interface: tile // // Description: // // // Author: Tobias Glaesser <tob...@gm...>, (C) 2004 // // Copyright: See COPYING file that comes with this distribution // // #ifndef TILE_H #define TILE_H #include <vector> #include "texture.h" #include "globals.h" #include "lispreader.h" #include "setup.h" /** Tile Class */ struct Tile { std::vector<texture_type> images; bool solid; bool brick; bool ice; bool fullbox; int anim_speed; unsigned char alpha; }; class TileManager { private: TileManager(); std::vector<Tile*> tiles; static TileManager* instance_ ; void load_tileset(std::string filename); public: static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); } Tile* get(unsigned int id) { if( id < tiles.size()) { return tiles[id]; } else { return NULL; } } ; }; #endif --- NEW FILE: tile.cpp --- // // C++ Implementation: tile // // Description: // // // Author: Tobias Glaesser <tob...@gm...>, (C) 2004 // // Copyright: See COPYING file that comes with this distribution // // #include "tile.h" #include "assert.h" TileManager* TileManager::instance_ = 0; TileManager::TileManager() { std::string filename = datadir + "images/tilesets/main.stgt"; load_tileset(filename); } void TileManager::load_tileset(std::string filename) { lisp_object_t* root_obj = lisp_read_from_file(filename); if (!root_obj) st_abort("Couldn't load file", filename); if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-tiles") == 0) { lisp_object_t* cur = lisp_cdr(root_obj); int tileset_id = 0; while(!lisp_nil_p(cur)) { lisp_object_t* element = lisp_car(cur); if (strcmp(lisp_symbol(lisp_car(element)), "tile") == 0) { int id = 0; std::vector<std::string> filenames; Tile* tile = new Tile; tile->solid = false; tile->brick = false; tile->ice = false; tile->fullbox = false; tile->alpha = 0; tile->anim_speed = 25; LispReader reader(lisp_cdr(element)); reader.read_int("id", &id); reader.read_bool("solid", &tile->solid); reader.read_bool("brick", &tile->brick); reader.read_bool("ice", &tile->ice); reader.read_bool("fullbox", &tile->fullbox); reader.read_int("alpha", (int*)&tile->alpha); reader.read_int("anim-speed", &tile->anim_speed); reader.read_string_vector("images", &filenames); for(std::vector<std::string>::iterator it = filenames.begin(); it != filenames.end(); ++it) { texture_type cur_image; tile->images.push_back(cur_image); texture_load(&tile->images[tile->images.size()-1], datadir + "images/tilesets/" + (*it), USE_ALPHA); } if (id+tileset_id >= int(tiles.size())) tiles.resize(id+tileset_id+1); tiles[id+tileset_id] = tile; } else if (strcmp(lisp_symbol(lisp_car(element)), "tileset") == 0) { LispReader reader(lisp_cdr(element)); std::string filename; reader.read_string("file", &filename); filename = datadir + "images/tilesets/" + filename; load_tileset(filename); } else if (strcmp(lisp_symbol(lisp_car(element)), "properties") == 0) { LispReader reader(lisp_cdr(element)); reader.read_int("id", &tileset_id); tileset_id *= 1000; } else { puts("Unhandled symbol"); } cur = lisp_cdr(cur); } } else { assert(0); } } |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:35:19
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15181/src Added Files: particlesystem.cpp particlesystem.h Log Message: new levelformat with multiple layers and and new tileset code. Along with a new particlesystem. (the latest one was contributed by Matze Braun) --- NEW FILE: particlesystem.cpp --- // $Id: particlesystem.cpp,v 1.1 2004/03/24 22:24:38 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "particlesystem.h" #include <iostream> #include <math.h> #include "globals.h" #include "scene.h" ParticleSystem::ParticleSystem() { virtual_width = screen->w; virtual_height = screen->h; } ParticleSystem::~ParticleSystem() { std::vector<Particle*>::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { delete *i; } } void ParticleSystem::draw(float scrollx, float scrolly, int layer) { std::vector<Particle*>::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { Particle* particle = *i; if(particle->layer != layer) continue; // remap x,y coordinates onto screencoordinates float x = fmodf(particle->x - scrollx, virtual_width); if(x < 0) x += virtual_width; float y = fmodf(particle->y - scrolly, virtual_height); if(y < 0) y += virtual_height; float xmax = fmodf(x + particle->texture->w, virtual_width); float ymax = fmodf(y + particle->texture->h, virtual_height); // particle on screen if(x >= screen->w && xmax >= screen->w) continue; if(y >= screen->h && ymax >= screen->h) continue; if(x > screen->w) x -= virtual_width; if(y > screen->h) y -= virtual_height; texture_draw(particle->texture, x, y); } } SnowParticleSystem::SnowParticleSystem() { texture_load(&snowimages[0], datadir+"/images/shared/snow0.png", USE_ALPHA); texture_load(&snowimages[1], datadir+"/images/shared/snow1.png", USE_ALPHA); texture_load(&snowimages[2], datadir+"/images/shared/snow2.png", USE_ALPHA); virtual_width = screen->w * 2; // create some random snowflakes size_t snowflakecount = size_t(virtual_width/10.0); for(size_t i=0; i<snowflakecount; ++i) { SnowParticle* particle = new SnowParticle; particle->x = rand() % int(virtual_width); particle->y = rand() % screen->h; particle->layer = i % 2; int snowsize = rand() % 3; particle->texture = &snowimages[snowsize]; particle->speed = 0.01 + snowsize/50.0 + (rand()%(int)gravity/15.0); particles.push_back(particle); } } SnowParticleSystem::~SnowParticleSystem() { for(int i=0;i<3;++i) texture_free(&snowimages[i]); } void SnowParticleSystem::simulate(float elapsed_time) { std::vector<Particle*>::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { SnowParticle* particle = (SnowParticle*) *i; particle->y += particle->speed * elapsed_time; if(particle->y > screen->h) { particle->y = 0; particle->x = rand() % int(virtual_width); } } } CloudParticleSystem::CloudParticleSystem() { texture_load(&cloudimage, datadir + "/images/shared/cloud.png", USE_ALPHA); virtual_width = 5000.0; // create some random clouds for(size_t i=0; i<15; ++i) { CloudParticle* particle = new CloudParticle; particle->x = rand() % int(virtual_width); particle->y = rand() % int((float) screen->h * 0.3333); particle->layer = 0; particle->texture = &cloudimage; particle->speed = -float(250 + rand() % 200) / 1000.0; particles.push_back(particle); } } CloudParticleSystem::~CloudParticleSystem() { texture_free(&cloudimage); } void CloudParticleSystem::simulate(float elapsed_time) { std::vector<Particle*>::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { CloudParticle* particle = (CloudParticle*) *i; particle->x += particle->speed * elapsed_time; } } --- NEW FILE: particlesystem.h --- // $Id: particlesystem.h,v 1.1 2004/03/24 22:24:38 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_PARTICLESYSTEM_H #define SUPERTUX_PARTICLESYSTEM_H #include <vector> #include "texture.h" /** * This is the base class for particle systems. It is responsible for storing a * set of particles with each having an x- and y-coordinate the number of the * layer where it should be drawn and a texture. * The coordinate system used here is a virtual one. It would be a bad idea to * populate whole levels with particles. So we're using a virtual rectangle * here that is tiled onto the level when drawing. This rectangle has the size * (virtual_width, virtual_height). We're using modulo on the particle * coordinates, so when a particle leaves left, it'll reenter at the right * side. * * Classes that implement a particle system should subclass from this class, * initialize particles in the constructor and move them in the simulate * function. */ class ParticleSystem { public: ParticleSystem(); virtual ~ParticleSystem(); void draw(float scrollx, float scrolly, int layer); virtual void simulate(float elapsed_time) = 0; protected: class Particle { public: virtual ~Particle() { } float x, y; int layer; texture_type* texture; }; std::vector<Particle*> particles; float virtual_width, virtual_height; }; class SnowParticleSystem : public ParticleSystem { public: SnowParticleSystem(); virtual ~SnowParticleSystem(); virtual void simulate(float elapsed_time); private: class SnowParticle : public Particle { public: float speed; }; texture_type snowimages[3]; }; class CloudParticleSystem : public ParticleSystem { public: CloudParticleSystem(); virtual ~CloudParticleSystem(); virtual void simulate(float elapsed_time); private: class CloudParticle : public Particle { public: float speed; }; texture_type cloudimage; }; #endif |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:34:30
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14943/src Modified Files: gameloop.cpp gameloop.h level.cpp level.h leveleditor.cpp player.cpp scene.h setup.cpp texture.cpp Log Message: new levelformat with multiple layers and and new tileset code. Along with a new particlesystem. (the latest one was contributed by Matze Braun) Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- gameloop.h 22 Mar 2004 15:47:31 -0000 1.18 +++ gameloop.h 24 Mar 2004 22:23:48 -0000 1.19 @@ -38,8 +38,8 @@ bool isice(float x, float y); bool isfullbox(float x, float y); bool rectcollision(base_type* one, base_type* two); -void drawshape(float x, float y, unsigned char c); -unsigned char shape(float x, float y); +void drawshape(float x, float y, unsigned int c); +unsigned int shape(float x, float y); void bumpbrick(float x, float y); void trygrabdistro(float x, float y, int bounciness); void trybreakbrick(float x, float y); Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- setup.cpp 24 Mar 2004 21:43:56 -0000 1.17 +++ setup.cpp 24 Mar 2004 22:23:48 -0000 1.18 @@ -80,7 +80,7 @@ return true; } -/* Makes sure a directory is created in either the SuperTux base directory or the SuperTux base directory.*/ +/* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/ int fcreatedir(const char* relative_dir) { char path[1024]; Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- level.h 23 Mar 2004 17:25:15 -0000 1.13 +++ level.h 24 Mar 2004 22:23:48 -0000 1.14 @@ -46,7 +46,11 @@ std::string theme; std::string song_title; std::string bkgd_image; - unsigned int* tiles[15]; + std::string particle_system; + unsigned int* bg_tiles[15]; /* Tiles in the background */ + unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/ + unsigned int* dn_tiles[15]; /* Dynamic tiles (bad guys and moving platforms for example)*/ + unsigned int* fg_tiles[15]; /* Tiles in the foreground */ int time_left; int bkgd_red; int bkgd_green; @@ -55,6 +59,13 @@ float gravity; }; +enum { + TM_BG, + TM_IA, + TM_DN, + TM_FG + }; + extern texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2]; void level_default (st_level* plevel); @@ -64,7 +75,8 @@ void level_save (st_level* plevel, const char * subset, int level); void level_free (st_level* plevel); void level_load_gfx (st_level* plevel); -void level_change (st_level* plevel, float x, float y, unsigned char c); +void level_change (st_level* plevel, float x, float y, int tm, unsigned int c); +void level_change_size (st_level* plevel, int new_width); void level_load_song(st_level* plevel); void level_free_gfx(); void level_load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha); Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- player.cpp 24 Mar 2004 22:10:28 -0000 1.10 +++ player.cpp 24 Mar 2004 22:23:48 -0000 1.11 @@ -255,8 +255,8 @@ } if (distro_counter <= 0) - level_change(¤t_level,base.x,base.y - 1, 'a'); - + level_change(¤t_level,base.x,base.y - 1, TM_IA, 'a'); + play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; distros++; @@ -274,7 +274,7 @@ } if (distro_counter <= 0) - level_change(¤t_level,base.x+ 31, base.y, 'a'); + level_change(¤t_level,base.x+ 31, base.y, TM_IA, 'a'); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- level.cpp 24 Mar 2004 16:12:51 -0000 1.10 +++ level.cpp 24 Mar 2004 22:23:48 -0000 1.11 @@ -206,11 +206,29 @@ for(i = 0; i < 15; ++i) { - plevel->tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int)); - plevel->tiles[i][plevel->width] = (unsigned int) '\0'; + plevel->ia_tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int)); + plevel->ia_tiles[i][plevel->width] = (unsigned int) '\0'; for(y = 0; y < plevel->width; ++y) - plevel->tiles[i][y] = (unsigned int) '.'; - plevel->tiles[i][plevel->width] = (unsigned int) '\0'; + plevel->ia_tiles[i][y] = (unsigned int) '.'; + plevel->ia_tiles[i][plevel->width] = (unsigned int) '\0'; + + plevel->bg_tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int)); + plevel->bg_tiles[i][plevel->width] = (unsigned int) '\0'; + for(y = 0; y < plevel->width; ++y) + plevel->bg_tiles[i][y] = (unsigned int) '.'; + plevel->bg_tiles[i][plevel->width] = (unsigned int) '\0'; + + plevel->fg_tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int)); + plevel->fg_tiles[i][plevel->width] = (unsigned int) '\0'; + for(y = 0; y < plevel->width; ++y) + plevel->fg_tiles[i][y] = (unsigned int) '.'; + plevel->fg_tiles[i][plevel->width] = (unsigned int) '\0'; + + plevel->dn_tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int)); + plevel->dn_tiles[i][plevel->width] = (unsigned int) '\0'; + for(y = 0; y < plevel->width; ++y) + plevel->dn_tiles[i][y] = (unsigned int) '.'; + plevel->dn_tiles[i][plevel->width] = (unsigned int) '\0'; } } @@ -231,7 +249,7 @@ int level_load(st_level* plevel, const char* filename) { - int x, y; + int x, y, j; FILE * fi; lisp_object_t* root_obj = 0; fi = fopen(filename, "r"); @@ -250,12 +268,15 @@ printf("World: Parse Error in file %s", filename); } - vector<int> vi; + vector<int> ia_tm; + vector<int> dn_tm; + vector<int> bg_tm; + vector<int> fg_tm; if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) { LispReader reader(lisp_cdr(root_obj)); - + reader.read_int("width", &plevel->width); reader.read_int("time", &plevel->time_left); reader.read_int("bkgd_red", &plevel->bkgd_red); @@ -266,20 +287,64 @@ reader.read_string("theme", &plevel->theme); reader.read_string("music", &plevel->song_title); reader.read_string("background", &plevel->bkgd_image); - reader.read_int_vector("tilemap", &vi); + reader.read_string("particle_system", &plevel->particle_system); + reader.read_int_vector("background-tm", &bg_tm); + reader.read_int_vector("interactive-tm", &ia_tm); + reader.read_int_vector("dynamic-tm", &dn_tm); + reader.read_int_vector("foreground-tm", &fg_tm); } - - + + int i; for( i = 0; i < 15; ++i) - plevel->tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); + { + plevel->dn_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); + plevel->ia_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); + plevel->bg_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); + plevel->fg_tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) ); + } - i = 0; - int j = 0; - for(vector<int>::iterator it = vi.begin(); it != vi.end(); ++it, ++i) + i = j = 0; + for(vector<int>::iterator it = ia_tm.begin(); it != ia_tm.end(); ++it, ++i) { - plevel->tiles[j][i] = (*it); + plevel->ia_tiles[j][i] = (*it); + if(i == plevel->width - 1) + { + i = -1; + ++j; + } + } + + i = j = 0; + for(vector<int>::iterator it = dn_tm.begin(); it != dn_tm.end(); ++it, ++i) + { + + plevel->dn_tiles[j][i] = (*it); + if(i == plevel->width - 1) + { + i = -1; + ++j; + } + } + + i = j = 0; + for(vector<int>::iterator it = bg_tm.begin(); it != bg_tm.end(); ++it, ++i) + { + + plevel->bg_tiles[j][i] = (*it); + if(i == plevel->width - 1) + { + i = -1; + ++j; + } + } + + i = j = 0; + for(vector<int>::iterator it = fg_tm.begin(); it != fg_tm.end(); ++it, ++i) + { + + plevel->fg_tiles[j][i] = (*it); if(i == plevel->width - 1) { i = -1; @@ -290,7 +355,7 @@ /* Set the global gravity to the latest loaded level's gravity */ gravity = plevel->gravity; - /* Mark the end position of this level! - Is a bit wrong here thought */ + /* Mark the end position of this level! - Is a bit wrong here thought * / for (y = 0; y < 15; ++y) { @@ -302,7 +367,7 @@ endpos = x*32; } } - } + }*/ fclose(fi); return 0; @@ -333,30 +398,58 @@ } - /* Write header: */ - fprintf(fi,";SuperTux-Level\n"); - fprintf(fi,"(supertux-level\n"); + /* Write header: */ + fprintf(fi,";SuperTux-Level\n"); + fprintf(fi,"(supertux-level\n"); + + fprintf(fi," (name \"%s\")\n", plevel->name.c_str()); + fprintf(fi," (theme \"%s\")\n", plevel->theme.c_str()); + fprintf(fi," (music \"%s\")\n", plevel->song_title.c_str()); + fprintf(fi," (background \"%s\")\n", plevel->bkgd_image.c_str()); + fprintf(fi," (particle_system \"%s\")\n", plevel->particle_system.c_str()); + fprintf(fi," (bkgd_red %d)\n", plevel->bkgd_red); + fprintf(fi," (bkgd_green %d)\n", plevel->bkgd_green); + fprintf(fi," (bkgd_blue %d)\n", plevel->bkgd_blue); + fprintf(fi," (time %d)\n", plevel->time_left); + fprintf(fi," (width %d)\n", plevel->width); + fprintf(fi," (gravity %2.1f)\n", plevel->gravity); + fprintf(fi," (background-tm "); - fprintf(fi," (name \"%s\")\n", plevel->name.c_str()); - fprintf(fi," (theme \"%s\")\n", plevel->theme.c_str()); - fprintf(fi," (music \"%s\")\n", plevel->song_title.c_str()); - fprintf(fi," (background \"%s\")\n", plevel->bkgd_image.c_str()); - fprintf(fi," (bkgd_red %d)\n", plevel->bkgd_red); - fprintf(fi," (bkgd_green %d)\n", plevel->bkgd_green); - fprintf(fi," (bkgd_blue %d)\n", plevel->bkgd_blue); - fprintf(fi," (time %d)\n", plevel->time_left); - fprintf(fi," (width %d)\n", plevel->width); - fprintf(fi," (gravity %2.1f)\n", plevel->gravity); - fprintf(fi," (tilemap "); - for(y = 0; y < 15; ++y) { - for(i = 0; i < plevel->width; ++i) - fprintf(fi," %d ", plevel->tiles[y][i]); + for(i = 0; i < plevel->width; ++i) + fprintf(fi," %d ", plevel->bg_tiles[y][i]); } - - fprintf( fi,")"); - fprintf( fi,")\n"); + + fprintf( fi,")\n"); + fprintf(fi," (interactive-tm "); + + for(y = 0; y < 15; ++y) + { + for(i = 0; i < plevel->width; ++i) + fprintf(fi," %d ", plevel->ia_tiles[y][i]); + } + + fprintf( fi,")\n"); + fprintf(fi," (dynamic-tm "); + + for(y = 0; y < 15; ++y) + { + for(i = 0; i < plevel->width; ++i) + fprintf(fi," %d ", plevel->dn_tiles[y][i]); + } + + fprintf( fi,")\n"); + fprintf(fi," (foreground-tm "); + + for(y = 0; y < 15; ++y) + { + for(i = 0; i < plevel->width; ++i) + fprintf(fi," %d ", plevel->fg_tiles[y][i]); + } + + fprintf( fi,")"); + fprintf( fi,")\n"); fclose(fi); } @@ -368,7 +461,13 @@ { int i; for(i=0; i < 15; ++i) - free(plevel->tiles[i]); + free(plevel->bg_tiles[i]); + for(i=0; i < 15; ++i) + free(plevel->ia_tiles[i]); + for(i=0; i < 15; ++i) + free(plevel->dn_tiles[i]); + for(i=0; i < 15; ++i) + free(plevel->fg_tiles[i]); plevel->name.clear(); plevel->theme.clear(); @@ -446,9 +545,37 @@ texture_load(ptexture, fname, use_alpha); } +void tilemap_change_size(unsigned int** tilemap[15], int w, int old_w) +{ + int j,y; + for(y = 0; y < 15; ++y) + { + *tilemap[y] = (unsigned int*) realloc(*tilemap[y],(w+1)*sizeof(unsigned int)); + if(w > old_w) + for(j = 0; j < w - old_w; ++j) + *tilemap[y][old_w+j] = 0; + *tilemap[y][w] = 0; + } +} + +/* Change the size of a level (width) */ +void level_change_size (st_level* plevel, int new_width) +{ + int y; + + if(new_width < 21) + new_width = 21; + tilemap_change_size((unsigned int***)&plevel->ia_tiles,new_width,plevel->width); + tilemap_change_size((unsigned int***)&plevel->dn_tiles,new_width,plevel->width); + tilemap_change_size((unsigned int***)&plevel->bg_tiles,new_width,plevel->width); + tilemap_change_size((unsigned int***)&plevel->fg_tiles,new_width,plevel->width); + plevel->width = new_width; + +} + /* Edit a piece of the map! */ -void level_change(st_level* plevel, float x, float y, unsigned char c) +void level_change(st_level* plevel, float x, float y, int tm, unsigned int c) { int xx, yy; @@ -456,7 +583,19 @@ xx = ((int)x / 32); if (yy >= 0 && yy < 15 && xx >= 0 && xx <= plevel->width) - plevel->tiles[yy][xx] = c; + { + switch(tm) + { + case 0: + plevel->bg_tiles[yy][xx] = c; + case 1: + plevel->ia_tiles[yy][xx] = c; + case 2: + plevel->dn_tiles[yy][xx] = c; + case 4: + plevel->fg_tiles[yy][xx] = c; + } + } } /* Free music data for this level: */ Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- leveleditor.cpp 24 Mar 2004 21:43:56 -0000 1.17 +++ leveleditor.cpp 24 Mar 2004 22:23:48 -0000 1.18 @@ -66,7 +66,7 @@ void le_drawlevel(); void le_drawinterface(); void le_checkevents(); -void le_change(float x, float y, unsigned char c); +void le_change(float x, float y, int tm, unsigned int c); void le_testlevel(); void le_showhelp(); void le_set_defaults(void); @@ -129,8 +129,11 @@ for (y = 0; y < 15; ++y) for (x = 0; x < le_current_level->width; ++x) - if (le_current_level->tiles[y][x] >= '0' && le_current_level->tiles[y][x] <= '9') - add_bad_guy(x * 32, y * 32, static_cast<BadGuyKind>(le_current_level->tiles[y][x] - '0')); + if (le_current_level->dn_tiles[y][x] >= '0' && le_current_level->dn_tiles[y][x] <= '9') + add_bad_guy(x * 32, y * 32, static_cast<BadGuyKind>(le_current_level->dn_tiles[y][x] - '0')); + + + } void le_set_defaults() @@ -620,28 +623,7 @@ le_current_level->song_title = string_list_active(level_settings_menu->item[4].list); - i = le_current_level->width; - le_current_level->width = atoi(level_settings_menu->item[6].input); - if(le_current_level->width < i) - { - if(le_current_level->width < 21) - le_current_level->width = 21; - for(y = 0; y < 15; ++y) - { - le_current_level->tiles[y] = (unsigned int*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned int)); - le_current_level->tiles[y][le_current_level->width] = (unsigned int) '\0'; - } - } - else if(le_current_level->width > i) - { - for(y = 0; y < 15; ++y) - { - le_current_level->tiles[y] = (unsigned int*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned int)); - for(j = 0; j < le_current_level->width - i; ++j) - le_current_level->tiles[y][i+j] = (unsigned int) '.'; - le_current_level->tiles[y][le_current_level->width] = (unsigned int) '\0'; - } - } + level_change_size(le_current_level, atoi(level_settings_menu->item[6].input)); le_current_level->time_left = atoi(level_settings_menu->item[7].input); le_current_level->gravity = atof(level_settings_menu->item[8].input); le_current_level->bkgd_red = atoi(level_settings_menu->item[9].input); @@ -838,12 +820,11 @@ for (y = 0; y < 15; ++y) for (x = 0; x < 20; ++x) { - drawshape(x * 32 - ((int)pos_x % 32), y * 32, - le_current_level->tiles[y][x + (int)(pos_x / 32)]); + drawshape(x * 32 - ((int)pos_x % 32), y * 32, le_current_level->ia_tiles[y][x + (int)(pos_x / 32)]); /* draw whats inside stuff when cursor is selecting those */ /* (draw them all the time - is this the right behaviour?) */ - switch(le_current_level->tiles[y][x + (int)(pos_x/32)]) + switch(le_current_level->ia_tiles[y][x + (int)(pos_x/32)]) { case 'B': texture_draw(&img_mints, x * 32 - ((int)pos_x % 32), y*32); @@ -1250,7 +1231,7 @@ if(le_mouse_pressed[LEFT]) { - le_change(cursor_x, cursor_y, le_current_tile); + le_change(cursor_x, cursor_y, TM_IA, le_current_tile); } } } @@ -1311,7 +1292,7 @@ fillrect(x1*32-pos_x, y1*32,32* (x2 - x1 + 1),32 * (y2 - y1 + 1),173,234,177,103); } -void le_change(float x, float y, unsigned char c) +void le_change(float x, float y, int tm, unsigned int c) { if(le_current_level != NULL) { @@ -1324,7 +1305,7 @@ switch(le_selection_mode) { case CURSOR: - level_change(le_current_level,x,y,c); + level_change(le_current_level,x,y,tm,c); yy = ((int)y / 32); xx = ((int)x / 32); @@ -1378,7 +1359,7 @@ for(xx = x1; xx <= x2; xx++) for(yy = y1; yy <= y2; yy++) { - level_change(le_current_level, xx*32, yy*32, c); + level_change(le_current_level, xx*32, yy*32, tm, c); if(c == '0') // if it's a bad guy add_bad_guy(xx*32, yy*32, BAD_BSOD); Index: texture.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/texture.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- texture.cpp 24 Mar 2004 16:12:51 -0000 1.7 +++ texture.cpp 24 Mar 2004 22:23:48 -0000 1.8 @@ -344,7 +344,6 @@ void texture_draw_sdl(texture_type* ptexture, float x, float y, bool update) { - SDL_Rect dest; dest.x = (int)x; Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- scene.h 24 Mar 2004 22:01:08 -0000 1.13 +++ scene.h 24 Mar 2004 22:23:48 -0000 1.14 @@ -20,6 +20,7 @@ #include "world.h" #include "special.h" #include "level.h" +#include "particlesystem.h" #define FRAME_RATE 10 // 100 Frames per second (10ms) @@ -36,7 +37,7 @@ extern timer_type super_bkgd_timer; extern float scroll_x; -extern int global_frame_counter; +extern unsigned int global_frame_counter; extern std::vector<bouncy_distro_type> bouncy_distros; extern std::vector<broken_brick_type> broken_bricks; extern std::vector<bouncy_brick_type> bouncy_bricks; @@ -44,6 +45,7 @@ extern std::vector<floating_score_type> floating_scores; extern std::vector<upgrade_type> upgrades; extern std::vector<bullet_type> bullets; +extern std::vector<ParticleSystem*> particle_systems; extern Player tux; extern texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; extern timer_type time_left; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- gameloop.cpp 24 Mar 2004 22:10:28 -0000 1.22 +++ gameloop.cpp 24 Mar 2004 22:23:48 -0000 1.23 @@ -16,6 +16,7 @@ #include <string.h> #include <errno.h> #include <unistd.h> +#include <math.h> #include <time.h> #include <SDL.h> @@ -38,6 +39,8 @@ #include "level.h" #include "scene.h" #include "collision.h" +#include "tile.h" +#include "particlesystem.h" /* extern variables */ @@ -105,14 +108,30 @@ { for (x = 0; x < current_level.width; x++) { - if (current_level.tiles[y][x] >= '0' && current_level.tiles[y][x] <= '9') + if (current_level.dn_tiles[y][x] >= '0' && current_level.dn_tiles[y][x] <= '9') { - add_bad_guy(x * 32, y * 32, static_cast<BadGuyKind>(current_level.tiles[y][x] - '0')); - current_level.tiles[y][x] = '.'; + add_bad_guy(x * 32, y * 32, static_cast<BadGuyKind>(current_level.dn_tiles[y][x] - '0')); + current_level.dn_tiles[y][x] = 0; } } } +} +void activate_particle_systems(void) +{ + printf("PSys: %s\n", current_level.particle_system.c_str()); + if(current_level.particle_system == "clouds") + { + particle_systems.push_back(new CloudParticleSystem); + } + else if(current_level.particle_system == "snow") + { + particle_systems.push_back(new SnowParticleSystem); + } + else if(current_level.particle_system != "") + { + st_abort("unknown particle system specified in level", ""); + } } /* --- GAME EVENT! --- */ @@ -222,9 +241,9 @@ case SDLK_f: if(debug_fps) debug_fps = false; - else + else debug_fps = true; - break; + break; default: break; } @@ -374,6 +393,7 @@ arrays_free(); arrays_init(); activate_bad_guys(); + activate_particle_systems(); level_free_gfx(); level_load_gfx(¤t_level); level_free_song(); @@ -450,6 +470,13 @@ bad_guys[i].action(); } + /* update particle systems */ + std::vector<ParticleSystem*>::iterator p; + for(p = particle_systems.begin(); p != particle_systems.end(); ++p) + { + (*p)->simulate(frame_ratio); + } + /* Handle all possible collisions. */ collision_handler(); @@ -460,6 +487,8 @@ void game_draw(void) { +int y,x; + /* Draw screen: */ if (tux.dying && (global_frame_counter % 4) == 0) clearscreen(255, 255, 255); @@ -480,11 +509,36 @@ } } - // Draw background: - for (int y = 0; y < 15; ++y) - for (int x = 0; x < 21; ++x) - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - current_level.tiles[y][x + (int)(scroll_x / 32)]); + /* Draw particle systems (background) */ + std::vector<ParticleSystem*>::iterator p; + for(p = particle_systems.begin(); p != particle_systems.end(); ++p) + { + (*p)->draw(scroll_x, 0, 0); + } + + /* Draw background: */ + + for (y = 0; y < 15; ++y) + { + for (x = 0; x < 21; ++x) + { + drawshape(32*x - fmodf(scroll_x, 32), y * 32, + current_level.bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + } + } + + /* Draw interactive tiles: */ + + for (y = 0; y < 15; ++y) + { + for (x = 0; x < 21; ++x) + { + drawshape(32*x - fmodf(scroll_x, 32), y * 32, + current_level.ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + } + } + + /* (Bouncy bricks): */ for (unsigned int i = 0; i < bouncy_bricks.size(); ++i) bouncy_brick_draw(&bouncy_bricks[i]); @@ -509,6 +563,23 @@ for (unsigned int i = 0; i < broken_bricks.size(); ++i) broken_brick_draw(&broken_bricks[i]); + /* Draw foreground: */ + + for (y = 0; y < 15; ++y) + { + for (x = 0; x < 21; ++x) + { + drawshape(32*x - fmodf(scroll_x, 32), y * 32, + current_level.fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + } + } + + /* Draw particle systems (foreground) */ + for(p = particle_systems.begin(); p != particle_systems.end(); ++p) + { + (*p)->draw(scroll_x, 0, 1); + } + drawstatus(); if(game_pause) @@ -526,10 +597,7 @@ menu_process_current(); /* (Update it all!) */ - updatescreen(); - - } /* --- GAME LOOP! --- */ @@ -565,6 +633,7 @@ level_load_gfx(¤t_level); activate_bad_guys(); + activate_particle_systems(); level_load_song(¤t_level); tux.init(); @@ -583,7 +652,6 @@ if(st_gl_mode == ST_GL_LOAD_GAME) loadgame(levelnb); - /* --- MAIN GAME LOOP!!! --- */ jump = false; @@ -605,7 +673,7 @@ while (SDL_PollEvent(&event)) - {} + {} game_draw(); do @@ -616,7 +684,7 @@ frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; - + if(!timer_check(&frame_timer)) { timer_start(&frame_timer,25); @@ -679,8 +747,8 @@ /* == -1: continues */ return 0; } - /* --z; - }*/ + /* --z; + }*/ } else { @@ -711,7 +779,6 @@ last_update_time = update_time; update_time = st_get_ticks(); - /* Pause till next frame, if the machine running the game is too fast: */ /* FIXME: Works great for in OpenGl mode, where the CPU doesn't have to do that much. But the results in SDL mode aren't perfect (thought the 100 FPS are reached), even on an AMD2500+. */ @@ -1249,10 +1316,25 @@ /* Draw a tile on the screen: */ -void drawshape(float x, float y, unsigned char c) +void drawshape(float x, float y, unsigned int c) { int z; + Tile* ptile = TileManager::instance()->get + (c); + if(ptile) + { + if(ptile->images.size() > 1) + { + texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y); + } + else + { + texture_draw(&ptile->images[0],x,y); + } + } + + /* if (c == 'X' || c == 'x') texture_draw(&img_brick[0], x, y); else if (c == 'Y' || c == 'y') @@ -1308,24 +1390,25 @@ texture_draw(&img_flag[z], x + 16, y); } else if (c == '&') - texture_draw(&img_water, x, y); + texture_draw(&img_water, x, y);*/ + } /* What shape is at some position? */ -unsigned char shape(float x, float y) +unsigned int shape(float x, float y) { int xx, yy; - unsigned char c; + unsigned int c; yy = ((int)y / 32); xx = ((int)x / 32); if (yy >= 0 && yy < 15 && xx >= 0 && xx <= current_level.width) { - c = current_level.tiles[yy][xx]; + c = current_level.ia_tiles[yy][xx]; } else c = '.'; @@ -1338,25 +1421,38 @@ bool issolid(float x, float y) { - return (isbrick(x, y) || - isice(x, y) || - (shape(x, y) == '[') || - (shape(x, y) == '=') || - (shape(x, y) == ']') || - (shape(x, y) == 'A') || - (shape(x, y) == 'B') || - (shape(x, y) == '!') || - (shape(x, y) == 'a')); + Tile* tile = TileManager::instance()->get + (shape(x,y)); + if(tile) + { + if(tile->solid == true) + return true; + else + return false; + } + else + { + return false; + } } /* Is it a brick? */ bool isbrick(float x, float y) { - return (shape(x, y) == 'X' || - shape(x, y) == 'x' || - shape(x, y) == 'Y' || - shape(x, y) == 'y'); + Tile* tile = TileManager::instance()->get + (shape(x,y)); + if(tile) + { + if(tile->brick == true) + return true; + else + return false; + } + else + { + return false; + } } @@ -1364,16 +1460,38 @@ bool isice(float x, float y) { - return (shape(x, y) == '#'); + Tile* tile = TileManager::instance()->get + (shape(x,y)); + if(tile) + { + if(tile->ice == true) + return true; + else + return false; + } + else + { + return false; + } } /* Is it a full box? */ bool isfullbox(float x, float y) { - return (shape(x, y) == 'A' || - shape(x, y) == 'B' || - shape(x, y) == '!'); + Tile* tile = TileManager::instance()->get + (shape(x,y)); + if(tile) + { + if(tile->fullbox == true) + return true; + else + return false; + } + else + { + return false; + } } /* Break a brick: */ @@ -1396,7 +1514,7 @@ } if (distro_counter <= 0) - level_change(¤t_level,x, y, 'a'); + level_change(¤t_level,x, y, TM_IA, 'a'); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; @@ -1406,7 +1524,7 @@ { /* Get rid of it: */ - level_change(¤t_level,x, y,'.'); + level_change(¤t_level,x, y, TM_IA, '.'); } @@ -1473,7 +1591,7 @@ } /* Empty the box: */ - level_change(¤t_level,x, y, 'a'); + level_change(¤t_level,x, y, TM_IA, 'a'); } @@ -1483,7 +1601,7 @@ { if (shape(x, y) == '$') { - level_change(¤t_level,x, y, '.'); + level_change(¤t_level,x, y, TM_IA, '.'); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); if (bounciness == BOUNCE) @@ -1683,6 +1801,7 @@ arrays_free(); arrays_init(); activate_bad_guys(); + activate_particle_systems(); level_free_gfx(); level_load_gfx(¤t_level); level_free_song(); |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:26:25
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13063/src Modified Files: scene.cpp Log Message: new levelformat with multiple layers and and new tileset code. Along with a new particlesystem. (the latest one was contributed by Matze Braun) Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- scene.cpp 24 Mar 2004 22:01:08 -0000 1.8 +++ scene.cpp 24 Mar 2004 22:15:44 -0000 1.9 @@ -25,7 +25,8 @@ int distro_counter; timer_type super_bkgd_timer; float scroll_x; -int global_frame_counter; +unsigned int global_frame_counter; + std::vector<bouncy_distro_type> bouncy_distros; std::vector<broken_brick_type> broken_bricks; std::vector<bouncy_brick_type> bouncy_bricks; @@ -33,6 +34,7 @@ std::vector<floating_score_type> floating_scores; std::vector<upgrade_type> upgrades; std::vector<bullet_type> bullets; +std::vector<ParticleSystem*> particle_systems; Player tux; texture_type img_box_full; texture_type img_box_empty; @@ -49,13 +51,18 @@ void arrays_free(void) { - bad_guys.clear(); - bouncy_distros.clear(); - broken_bricks.clear(); - bouncy_bricks.clear(); - floating_scores.clear(); - upgrades.clear(); - bullets.clear(); +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 set_defaults(void) |
From: Ingo R. <gr...@us...> - 2004-03-24 22:21:11
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11965 Modified Files: badguy.cpp gameloop.cpp player.cpp player.h Log Message: - renamed input/input_ Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- player.cpp 24 Mar 2004 21:43:56 -0000 1.9 +++ player.cpp 24 Mar 2004 22:10:28 -0000 1.10 @@ -79,7 +79,7 @@ score = 0; distros = 0; - player_input_init(&input_); + player_input_init(&input); keymap.jump = SDLK_UP; keymap.duck = SDLK_DOWN; @@ -100,27 +100,27 @@ { if(key == keymap.right) { - input_.right = state; + input.right = state; return true; } else if(key == keymap.left) { - input_.left = state; + input.left = state; return true; } else if(key == keymap.jump) { - input_.up = state; + input.up = state; return true; } else if(key == keymap.duck) { - input_.down = state; + input.down = state; return true; } else if(key == keymap.fire) { - input_.fire = state; + input.fire = state; return true; } else @@ -136,7 +136,7 @@ base.ym = 0; old_base = base; - player_input_init(&input_); + player_input_init(&input); timer_init(&invincible_timer,true); timer_init(&skidding_timer,true); @@ -153,7 +153,7 @@ /* --- HANDLE TUX! --- */ - input(); + handle_input(); /* Move tux: */ @@ -387,7 +387,7 @@ { /* Facing the direction we're jumping? Go full-speed: */ - if (input_.fire == UP) + if (input.fire == UP) { base.xm = base.xm + ( newdir ? WALK_SPEED : -WALK_SPEED) * frame_ratio; @@ -402,7 +402,7 @@ base.xm = -MAX_WALK_XM; } } - else if ( input_.fire == DOWN) + else if ( input.fire == DOWN) { base.xm = base.xm + ( newdir ? RUN_SPEED : -RUN_SPEED) * frame_ratio; @@ -443,7 +443,7 @@ void Player::handle_vertical_input() { - if(input_.up == DOWN) + if(input.up == DOWN) { if (on_ground()) { @@ -460,7 +460,7 @@ } } } - else if(input_.up == UP && jumping) + else if(input.up == UP && jumping) { if (on_ground()) { @@ -490,17 +490,16 @@ } void -Player::input() +Player::handle_input() { /* Handle key and joystick state: */ - if(duck == false) { - if (input_.right == DOWN && input_.left == UP) + if (input.right == DOWN && input.left == UP) { handle_horizontal_input(RIGHT); } - else if (input_.left == DOWN && input_.right == UP) + else if (input.left == DOWN && input.right == UP) { handle_horizontal_input(LEFT); } @@ -523,14 +522,14 @@ /* Jump/jumping? */ - if ( input_.up == DOWN || (input_.up == UP && jumping)) + if ( input.up == DOWN || (input.up == UP && jumping)) { handle_vertical_input(); } /* Shoot! */ - if (input_.fire == DOWN && input_.old_fire == UP && got_coffee) + if (input.fire == DOWN && input.old_fire == UP && got_coffee) { add_bullet(base.x, base.y, base.xm, dir); } @@ -538,7 +537,7 @@ /* Duck! */ - if (input_.down == DOWN) + if (input.down == DOWN) { if (size == BIG && duck != true) { @@ -579,14 +578,14 @@ if(!timer_check(&frame_timer)) { timer_start(&frame_timer,25); - if (input_.right == UP && input_.left == UP) + if (input.right == UP && input.left == UP) { frame_main = 1; frame_ = 1; } else { - if ((input_.fire == DOWN && (global_frame_counter % 2) == 0) || + if ((input.fire == DOWN && (global_frame_counter % 2) == 0) || (global_frame_counter % 4) == 0) frame_main = (frame_main + 1) % 4; @@ -835,7 +834,7 @@ !timer_started(&safe_timer) && pbad_c->mode != HELD) { - if (pbad_c->mode == FLAT && input_.fire != DOWN) + if (pbad_c->mode == FLAT && input.fire != DOWN) { /* Kick: */ @@ -855,7 +854,7 @@ timer_start(&pbad_c->timer,5000); } - else if (pbad_c->mode == FLAT && input_.fire == DOWN) + else if (pbad_c->mode == FLAT && input.fire == DOWN) { pbad_c->mode = HELD; pbad_c->base.y-=8; Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- player.h 24 Mar 2004 17:41:04 -0000 1.17 +++ player.h 24 Mar 2004 22:10:29 -0000 1.18 @@ -87,7 +87,7 @@ class Player { public: - player_input_type input_; + player_input_type input; player_keymap_type keymap; int score; int distros; @@ -115,7 +115,7 @@ int key_event(SDLKey key, int state); void level_begin(); void action(); - void input(); + void handle_input(); void grabdistros(); void draw(); void collision(void* p_c_object, int c_object); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- gameloop.cpp 24 Mar 2004 21:43:56 -0000 1.21 +++ gameloop.cpp 24 Mar 2004 22:10:28 -0000 1.22 @@ -236,32 +236,32 @@ case JOY_X: if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) { - tux.input_.left = DOWN; - tux.input_.right = UP; + tux.input.left = DOWN; + tux.input.right = UP; } else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) { - tux.input_.left = UP; - tux.input_.right = DOWN; + tux.input.left = UP; + tux.input.right = DOWN; } else { - tux.input_.left = DOWN; - tux.input_.right = DOWN; + tux.input.left = DOWN; + tux.input.right = DOWN; } break; case JOY_Y: if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - tux.input_.down = DOWN; + tux.input.down = DOWN; else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - tux.input_.down = UP; + tux.input.down = UP; else - tux.input_.down = UP; + tux.input.down = UP; /* Handle joystick for the menu */ if(show_menu) { - if(tux.input_.down == DOWN) + if(tux.input.down == DOWN) menuaction = MENU_ACTION_DOWN; else menuaction = MENU_ACTION_UP; @@ -273,15 +273,15 @@ break; case SDL_JOYBUTTONDOWN: if (event.jbutton.button == JOY_A) - tux.input_.up = DOWN; + tux.input.up = DOWN; else if (event.jbutton.button == JOY_B) - tux.input_.fire = DOWN; + tux.input.fire = DOWN; break; case SDL_JOYBUTTONUP: if (event.jbutton.button == JOY_A) - tux.input_.up = UP; + tux.input.up = UP; else if (event.jbutton.button == JOY_B) - tux.input_.fire = UP; + tux.input.fire = UP; if(show_menu) menuaction = MENU_ACTION_HIT; @@ -625,7 +625,7 @@ /* Handle events: */ - tux.input_.old_fire = tux.input_.fire; + tux.input.old_fire = tux.input.fire; game_event(); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- badguy.cpp 24 Mar 2004 22:01:08 -0000 1.11 +++ badguy.cpp 24 Mar 2004 22:10:28 -0000 1.12 @@ -160,7 +160,7 @@ base.y = tux.base.y + tux.base.height/1.5 - base.height; } - if(tux.input_.fire != DOWN) /* SHOOT! */ + if(tux.input.fire != DOWN) /* SHOOT! */ { if(dir == LEFT) base.x -= 24; |
From: Tobias Gl??er <to...@us...> - 2004-03-24 22:19:16
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11456/src Modified Files: Makefile.am Log Message: new levelformat with multiple layers, new particlesystem Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 24 Mar 2004 14:35:10 -0000 1.11 +++ Makefile.am 24 Mar 2004 22:08:29 -0000 1.12 @@ -1,62 +1,6 @@ bin_PROGRAMS = supertux -supertux_SOURCES = \ - badguy.cpp \ - badguy.h \ - bitmask.cpp \ - bitmask.h \ - button.cpp \ - button.h \ - configfile.h \ - configfile.cpp \ - collision.cpp \ - collision.h \ - defines.h \ - gameloop.cpp \ - gameloop.h \ - globals.cpp \ - globals.h \ - high_scores.cpp \ - high_scores.h \ - intro.cpp \ - intro.h \ - level.cpp \ - level.h \ - leveleditor.cpp \ - leveleditor.h \ - lispreader.cpp \ - lispreader.h \ - menu.cpp \ - menu.h \ - physic.cpp \ - physic.h \ - player.cpp \ - player.h \ - scene.cpp \ - scene.h \ - screen.cpp \ - screen.h \ - setup.cpp \ - setup.h \ - sound.cpp \ - sound.h \ - special.cpp \ - special.h \ - supertux.cpp \ - supertux.h \ - text.cpp \ - text.h \ - texture.cpp \ - texture.h \ - timer.cpp \ - timer.h \ - title.cpp \ - title.h \ - type.cpp \ - type.h \ - world.cpp \ - world.h \ - worldmap.cpp \ - worldmap.h +supertux_SOURCES = badguy.cpp badguy.h bitmask.cpp bitmask.h button.cpp button.h collision.cpp collision.h configfile.cpp configfile.h defines.h gameloop.cpp gameloop.h globals.cpp globals.h high_scores.cpp high_scores.h intro.cpp intro.h level.cpp level.h leveleditor.cpp leveleditor.h lispreader.cpp lispreader.h menu.cpp menu.h particlesystem.cpp particlesystem.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h screen.cpp screen.h setup.cpp setup.h sound.cpp sound.h special.cpp special.h supertux.cpp supertux.h text.cpp text.h texture.cpp texture.h timer.cpp timer.h title.cpp title.h type.cpp type.h world.cpp world.h worldmap.cpp worldmap.h tile.h tile.cpp # EOF # +noinst_HEADERS = |
From: Ingo R. <gr...@us...> - 2004-03-24 22:11:53
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10080 Modified Files: badguy.cpp badguy.h scene.cpp scene.h Log Message: - minor cleanup Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- scene.cpp 24 Mar 2004 21:18:08 -0000 1.7 +++ scene.cpp 24 Mar 2004 22:01:08 -0000 1.8 @@ -34,16 +34,19 @@ std::vector<upgrade_type> upgrades; std::vector<bullet_type> bullets; Player tux; -texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; +texture_type img_box_full; +texture_type img_box_empty; +texture_type img_mints; +texture_type img_coffee; +texture_type img_super_bkgd; +texture_type img_red_glow; timer_type time_left; double frame_ratio; -/* Initialize all 'dynamic' arrays */ void arrays_init(void) { } -/* Free memory of 'dynamic' arrays */ void arrays_free(void) { bad_guys.clear(); @@ -73,12 +76,8 @@ set_current_music(LEVEL_MUSIC); } -/* Add score: */ - void add_score(float x, float y, int s) { - /* Add the score: */ - score += s; floating_score_type new_floating_score; @@ -86,8 +85,6 @@ floating_scores.push_back(new_floating_score); } -/* Add a bouncy distro: */ - void add_bouncy_distro(float x, float y) { @@ -96,9 +93,6 @@ bouncy_distros.push_back(new_bouncy_distro); } - -/* Add broken brick pieces: */ - void add_broken_brick(float x, float y) { add_broken_brick_piece(x, y, -1, -4); @@ -108,9 +102,6 @@ add_broken_brick_piece(x + 16, y + 16, 1.5, -3); } - -/* Add a broken brick piece: */ - void add_broken_brick_piece(float x, float y, float xm, float ym) { broken_brick_type new_broken_brick; @@ -118,9 +109,6 @@ broken_bricks.push_back(new_broken_brick); } - -/* Add a bouncy brick piece: */ - void add_bouncy_brick(float x, float y) { bouncy_brick_type new_bouncy_brick; @@ -128,9 +116,6 @@ bouncy_bricks.push_back(new_bouncy_brick); } - -/* Add a bad guy: */ - void add_bad_guy(float x, float y, BadGuyKind kind) { BadGuy new_bad_guy; @@ -138,8 +123,6 @@ bad_guys.push_back(new_bad_guy); } -/* Add an upgrade: */ - void add_upgrade(float x, float y, int dir, int kind) { upgrade_type new_upgrade; @@ -147,8 +130,6 @@ upgrades.push_back(new_upgrade); } -/* Add a bullet: */ - void add_bullet(float x, float y, float xm, int dir) { bullet_type new_bullet; @@ -158,3 +139,5 @@ play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER); } +// EOF // + Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- badguy.h 24 Mar 2004 16:12:51 -0000 1.13 +++ badguy.h 24 Mar 2004 22:01:08 -0000 1.14 @@ -70,11 +70,12 @@ void draw(); void action_bsod(); - void action_laptop(); - void action_money(); - void draw_bsod(); + + void action_laptop(); void draw_laptop(); + + void action_money(); void draw_money(); void collision(void* p_c_object, int c_object); Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- scene.h 24 Mar 2004 17:41:04 -0000 1.12 +++ scene.h 24 Mar 2004 22:01:08 -0000 1.13 @@ -22,6 +22,7 @@ #include "level.h" #define FRAME_RATE 10 // 100 Frames per second (10ms) + extern int score; extern int distros; extern int level; Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- badguy.cpp 24 Mar 2004 17:41:04 -0000 1.10 +++ badguy.cpp 24 Mar 2004 22:01:08 -0000 1.11 @@ -64,9 +64,7 @@ base.x = base.x - base.xm * frame_ratio; } - /* Move vertically: */ - base.y = base.y + base.ym * frame_ratio; if (dying != DYING_FALLING) @@ -89,7 +87,6 @@ } /* Fall if we get off the ground: */ - if (dying != DYING_FALLING) { if (!issolid(base.x+16, base.y + 32)) @@ -124,16 +121,14 @@ base.ym = physic_get_velocity(&physic); } + // BadGuy fall below the ground if (base.y > screen->h) bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); } void BadGuy::action_laptop() { - /* --- LAPTOP MONSTER: --- */ - /* Move left/right: */ - if (mode == NORMAL || mode == KICK) { if (dying == DYING_NOT || @@ -181,7 +176,6 @@ /* Move vertically: */ - if(mode != HELD) base.y = base.y + base.ym * frame_ratio; @@ -218,9 +212,7 @@ } - /* Fall if we get off the ground: */ - if (dying != DYING_FALLING) { if (!issolid(base.x+16, base.y + 32)) @@ -261,11 +253,7 @@ void BadGuy::action_money() { - /* --- MONEY BAGS: --- */ - - /* Move vertically: */ - base.y = base.y + base.ym * frame_ratio; if (dying != DYING_FALLING) |
From: Ingo R. <gr...@us...> - 2004-03-24 21:54:38
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5687 Modified Files: gameloop.cpp leveleditor.cpp menu.cpp player.cpp setup.cpp sound.cpp timer.cpp Log Message: - removed a few redundant "== true"'s Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- menu.cpp 24 Mar 2004 14:03:39 -0000 1.16 +++ menu.cpp 24 Mar 2004 21:43:56 -0000 1.17 @@ -285,7 +285,10 @@ { if(num_items != 0 && item != NULL) { - if((item[active_item].kind == MN_ACTION || item[active_item].kind == MN_TEXTFIELD || item[active_item].kind == MN_NUMFIELD) && item[active_item].toggled == true) + if((item[active_item].kind == MN_ACTION + || item[active_item].kind == MN_TEXTFIELD + || item[active_item].kind == MN_NUMFIELD) + && item[active_item].toggled) { item[active_item].toggled = false; show_menu = 0; @@ -328,7 +331,7 @@ int list_width = strlen(string_list_active(pitem.list)) * font_width; text_type* text_font = &white_text; - if(arrange_left == true) + if (arrange_left) x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2; if(index == active_item) @@ -427,7 +430,7 @@ { text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size); - if(pitem.toggled == true) + if(pitem.toggled) texture_draw(&checkbox_checked, x_pos + (text_width+font_width)/2, y_pos - 8); Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- setup.cpp 24 Mar 2004 14:35:11 -0000 1.16 +++ setup.cpp 24 Mar 2004 21:43:56 -0000 1.17 @@ -439,13 +439,13 @@ default: if(slot != -1) { - if(save == true) + if(save) { savegame(slot - 1); } else { - if(game_started == false) + if (game_started) { gameloop("default",slot - 1,ST_GL_LOAD_GAME); show_menu = true; @@ -479,7 +479,7 @@ case 4: if(use_music != options_menu->item[4].toggled) { - if(use_music == true) + if(use_music) { if(playing_music()) { @@ -603,7 +603,7 @@ { SDL_FreeSurface(screen); - if (use_fullscreen == true) + if (use_fullscreen) { screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ if (screen == NULL) @@ -641,7 +641,7 @@ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (use_fullscreen == true) + if (use_fullscreen) { screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */ if (screen == NULL) @@ -755,7 +755,7 @@ /* Init SDL Audio silently even if --disable-sound : */ - if (audio_device == true) + if (audio_device) { if (SDL_Init(SDL_INIT_AUDIO) < 0) { @@ -782,14 +782,14 @@ /* Open sound silently regarless the value of "use_sound": */ - if (audio_device == true) + if (audio_device) { if (open_audio(44100, AUDIO_S16, 2, 2048) < 0) { /* only print out message if sound or music was not disabled at command-line */ - if ((use_sound == true) || (use_music == true)) + if (use_sound || use_music) { fprintf(stderr, "\nWarning: I could not set up audio for 44100 Hz " Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- leveleditor.cpp 24 Mar 2004 17:41:04 -0000 1.16 +++ leveleditor.cpp 24 Mar 2004 21:43:56 -0000 1.17 @@ -612,7 +612,7 @@ i = true; } - if(i == true) + if(i) { level_free_gfx(); level_load_gfx(le_current_level); @@ -1014,13 +1014,13 @@ cursor_x = ((int)(pos_x + x) / 32) * 32; cursor_y = ((int) y / 32) * 32; - if(le_mouse_pressed[LEFT] == true) + if(le_mouse_pressed[LEFT]) { selection.x2 = x + pos_x; selection.y2 = y; } - if(le_mouse_pressed[RIGHT] == true) + if(le_mouse_pressed[RIGHT]) { pos_x += -1 * event.motion.xrel; } Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- player.cpp 24 Mar 2004 17:41:04 -0000 1.8 +++ player.cpp 24 Mar 2004 21:43:56 -0000 1.9 @@ -209,9 +209,8 @@ score_multiplier = 1; } - if(jumped_in_solid == true) + if(jumped_in_solid) { - if (isbrick(base.x, base.y) || isfullbox(base.x, base.y)) { @@ -285,7 +284,8 @@ } grabdistros(); - if(jumped_in_solid == true) + + if (jumped_in_solid) { ++base.y; ++old_base.y; @@ -460,7 +460,7 @@ } } } - else if(input_.up == UP && jumping == true) + else if(input_.up == UP && jumping) { if (on_ground()) { @@ -523,7 +523,7 @@ /* Jump/jumping? */ - if ( input_.up == DOWN || (input_.up == UP && jumping == true)) + if ( input_.up == DOWN || (input_.up == UP && jumping)) { handle_vertical_input(); } @@ -549,7 +549,7 @@ } else { - if (size == BIG && duck == true) + if (size == BIG && duck) { /* Make sure we're not standing back up into a solid! */ base.height = 64; @@ -978,7 +978,7 @@ base.x= 0; else if(base.x< scroll_x) base.x= scroll_x; - else if (base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == true) + else if (base.x< 160 + scroll_x && scroll_x > 0 && debug_mode) { scroll_x = base.x- 160; /*base.x+= 160;*/ Index: sound.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- sound.cpp 24 Mar 2004 14:35:11 -0000 1.7 +++ sound.cpp 24 Mar 2004 21:43:56 -0000 1.8 @@ -123,7 +123,7 @@ /* this won't call the function if the user has disabled sound * either via menu or via command-line option */ - if ((use_sound == true) && (audio_device == true)) + if (use_sound && audio_device) { Mix_PlayChannel( whichSpeaker, snd, 0); @@ -156,7 +156,7 @@ int playing_music(void) { - if (use_music == true) + if (use_music) { return Mix_PlayingMusic(); } @@ -170,7 +170,7 @@ int halt_music(void) { - if ((use_music == true) && (audio_device == true)) + if (use_music && audio_device) { return Mix_HaltMusic(); } @@ -183,7 +183,7 @@ int play_music(Mix_Music *music, int loops) { - if ((use_music == true) && (audio_device == true)) + if (use_music && audio_device) { DEBUG_MSG(__PRETTY_FUNCTION__); return Mix_PlayMusic(music, loops); Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- timer.cpp 24 Mar 2004 13:52:34 -0000 1.4 +++ timer.cpp 24 Mar 2004 21:43:56 -0000 1.5 @@ -116,11 +116,13 @@ fread(&ptimer->period,sizeof(unsigned int),1,fi); fread(&diff_ticks,sizeof(unsigned int),1,fi); fread(&tick_mode,sizeof(unsigned int),1,fi); - if(tick_mode == true) + + if (tick_mode) ptimer->get_ticks = st_get_ticks; else ptimer->get_ticks = SDL_GetTicks; - if(diff_ticks != 0) + + if (diff_ticks != 0) ptimer->time = ptimer->get_ticks() - diff_ticks; else ptimer->time = 0; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- gameloop.cpp 24 Mar 2004 21:18:08 -0000 1.20 +++ gameloop.cpp 24 Mar 2004 21:43:56 -0000 1.21 @@ -482,13 +482,9 @@ // Draw background: for (int y = 0; y < 15; ++y) - { - for (int x = 0; x < 21; ++x) - { - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - current_level.tiles[(int)y][(int)x + (int)(scroll_x / 32)]); - } - } + for (int x = 0; x < 21; ++x) + drawshape(32*x - fmodf(scroll_x, 32), y * 32, + current_level.tiles[y][x + (int)(scroll_x / 32)]); for (unsigned int i = 0; i < bouncy_bricks.size(); ++i) bouncy_brick_draw(&bouncy_bricks[i]); @@ -692,7 +688,7 @@ SDL_Delay(50); } - if(debug_mode && debug_fps == true) + if(debug_mode && debug_fps) SDL_Delay(60); /*Draw the current scene to the screen */ |
From: Ingo R. <gr...@us...> - 2004-03-24 21:28:52
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32526 Modified Files: gameloop.cpp scene.cpp Log Message: - minor cleanup, removed some evil variable recycling Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- scene.cpp 24 Mar 2004 17:41:04 -0000 1.6 +++ scene.cpp 24 Mar 2004 21:18:08 -0000 1.7 @@ -46,13 +46,13 @@ /* Free memory of 'dynamic' arrays */ void arrays_free(void) { -bad_guys.clear(); -bouncy_distros.clear(); -broken_bricks.clear(); -bouncy_bricks.clear(); -floating_scores.clear(); -upgrades.clear(); -bullets.clear(); + bad_guys.clear(); + bouncy_distros.clear(); + broken_bricks.clear(); + bouncy_bricks.clear(); + floating_scores.clear(); + upgrades.clear(); + bullets.clear(); } void set_defaults(void) Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gameloop.cpp 24 Mar 2004 17:41:04 -0000 1.19 +++ gameloop.cpp 24 Mar 2004 21:18:08 -0000 1.20 @@ -460,11 +460,7 @@ void game_draw(void) { - int y, s; - unsigned int i,x; - /* Draw screen: */ - if (tux.dying && (global_frame_counter % 4) == 0) clearscreen(255, 255, 255); else if(timer_check(&super_bkgd_timer)) @@ -474,7 +470,7 @@ /* Draw the real background */ if(current_level.bkgd_image[0] != '\0') { - s = (int)scroll_x / 30; + int s = (int)scroll_x / 30; texture_draw_part(&img_bkgd,s,0,0,0,img_bkgd.w - s, img_bkgd.h); texture_draw_part(&img_bkgd,0,0,screen->w - s ,0,s,img_bkgd.h); } @@ -484,74 +480,45 @@ } } - /* Draw background: */ - - for (y = 0; y < 15; ++y) + // Draw background: + for (int y = 0; y < 15; ++y) { - for (x = 0; x < 21; ++x) + for (int x = 0; x < 21; ++x) { drawshape(32*x - fmodf(scroll_x, 32), y * 32, current_level.tiles[(int)y][(int)x + (int)(scroll_x / 32)]); } } + for (unsigned int i = 0; i < bouncy_bricks.size(); ++i) + bouncy_brick_draw(&bouncy_bricks[i]); - /* (Bouncy bricks): */ - - for (i = 0; i < bouncy_bricks.size(); ++i) - { - bouncy_brick_draw(&bouncy_bricks[i]); - } - - - /* (Bad guys): */ - for (i = 0; i < bad_guys.size(); ++i) - { - bad_guys[i].draw(); - } + for (unsigned int i = 0; i < bad_guys.size(); ++i) + bad_guys[i].draw(); - /* (Tux): */ tux.draw(); - /* (Bullets): */ - for (i = 0; i < bullets.size(); ++i) - { - bullet_draw(&bullets[i]); - } - - /* (Floating scores): */ - for (i = 0; i < floating_scores.size(); ++i) - { - floating_score_draw(&floating_scores[i]); - } - + for (unsigned int i = 0; i < bullets.size(); ++i) + bullet_draw(&bullets[i]); - /* (Upgrades): */ - for (i = 0; i < upgrades.size(); ++i) - { - upgrade_draw(&upgrades[i]); - } + for (unsigned int i = 0; i < floating_scores.size(); ++i) + floating_score_draw(&floating_scores[i]); + for (unsigned int i = 0; i < upgrades.size(); ++i) + upgrade_draw(&upgrades[i]); - /* (Bouncy distros): */ - for (i = 0; i < bouncy_distros.size(); ++i) - { + for (unsigned int i = 0; i < bouncy_distros.size(); ++i) bouncy_distro_draw(&bouncy_distros[i]); - } - - /* (Broken bricks): */ - for (i = 0; i < broken_bricks.size(); ++i) - { - broken_brick_draw(&broken_bricks[i]); - } + for (unsigned int i = 0; i < broken_bricks.size(); ++i) + broken_brick_draw(&broken_bricks[i]); drawstatus(); if(game_pause) { - x = screen->h / 20; - for(i = 0; i < x; ++i) + int x = screen->h / 20; + for(int i = 0; i < x; ++i) { fillrect(i % 2 ? (pause_menu_frame * i)%screen->w : -((pause_menu_frame * i)%screen->w) ,(i*20+pause_menu_frame)%screen->h,screen->w,10,20,20,20, rand() % 20 + 1); } |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14918 Modified Files: badguy.cpp collision.cpp gameloop.cpp leveleditor.cpp player.cpp player.h scene.cpp scene.h special.cpp Log Message: - converted Player into a class (naming still needs a bit of cleanup Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- scene.cpp 24 Mar 2004 16:12:51 -0000 1.5 +++ scene.cpp 24 Mar 2004 17:41:04 -0000 1.6 @@ -25,7 +25,7 @@ int distro_counter; timer_type super_bkgd_timer; float scroll_x; -int frame; +int global_frame_counter; std::vector<bouncy_distro_type> bouncy_distros; std::vector<broken_brick_type> broken_bricks; std::vector<bouncy_brick_type> bouncy_bricks; @@ -33,7 +33,7 @@ std::vector<floating_score_type> floating_scores; std::vector<upgrade_type> upgrades; std::vector<bullet_type> bullets; -player_type tux; +Player tux; texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; timer_type time_left; double frame_ratio; Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- player.h 23 Mar 2004 17:25:15 -0000 1.16 +++ player.h 24 Mar 2004 17:41:04 -0000 1.17 @@ -58,9 +58,36 @@ void player_input_init(player_input_type* pplayer_input); -struct player_type +extern texture_type tux_life; +extern texture_type tux_right[3]; +extern texture_type tux_left[3]; +extern texture_type bigtux_right[3]; +extern texture_type bigtux_left[3]; +extern texture_type bigtux_right_jump; +extern texture_type bigtux_left_jump; +extern texture_type ducktux_right; +extern texture_type ducktux_left; +extern texture_type skidtux_right; +extern texture_type skidtux_left; +extern texture_type firetux_right[3]; +extern texture_type firetux_left[3]; +extern texture_type bigfiretux_right[3]; +extern texture_type bigfiretux_left[3]; +extern texture_type bigfiretux_right_jump; +extern texture_type bigfiretux_left_jump; +extern texture_type duckfiretux_right; +extern texture_type duckfiretux_left; +extern texture_type skidfiretux_right; +extern texture_type skidfiretux_left; +extern texture_type cape_right[2]; +extern texture_type cape_left[2]; +extern texture_type bigcape_right[2]; +extern texture_type bigcape_left[2]; + +class Player { - player_input_type input; + public: + player_input_type input_; player_keymap_type keymap; int score; int distros; @@ -70,8 +97,8 @@ DyingType dying; int dir; bool jumping; + int frame_; int frame_main; - int frame; int lives; base_type base; base_type old_base; @@ -82,35 +109,26 @@ timer_type frame_timer; physic_type vphysic; physic_type hphysic; -}; - -extern texture_type tux_life, - tux_right[3], tux_left[3], - bigtux_right[3], bigtux_left[3], - bigtux_right_jump, bigtux_left_jump, - ducktux_right, ducktux_left, - skidtux_right, skidtux_left, - firetux_right[3], firetux_left[3], - bigfiretux_right[3], bigfiretux_left[3], - bigfiretux_right_jump, bigfiretux_left_jump, - duckfiretux_right, duckfiretux_left, - skidfiretux_right, skidfiretux_left, - cape_right[2], cape_left[2], - bigcape_right[2], bigcape_left[2]; -void player_init(player_type* pplayer); -int player_key_event(player_type* pplayer, SDLKey key, int state); -void player_level_begin(player_type* pplayer); -void player_action(player_type* pplayer); -void player_input(player_type* pplayer); -void player_grabdistros(player_type *pplayer); -void player_draw(player_type* pplayer); -void player_collision(player_type* pplayer,void* p_c_object, int c_object); -void player_kill(player_type *pplayer, int mode); -void player_dying(player_type *pplayer); -void player_remove_powerups(player_type *pplayer); -void player_keep_in_bounds(player_type *pplayer); -bool player_on_ground(player_type *pplayer); -bool player_under_solid(player_type *pplayer); + public: + void init(); + int key_event(SDLKey key, int state); + void level_begin(); + void action(); + void input(); + void grabdistros(); + void draw(); + void collision(void* p_c_object, int c_object); + void kill(int mode); + void is_dying(); + void player_remove_powerups(); + void keep_in_bounds(); + bool on_ground(); + bool under_solid(); + private: + void handle_horizontal_input(int dir); + void handle_vertical_input(); + void remove_powerups(); +}; #endif /*SUPERTUX_PLAYER_H*/ Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- collision.cpp 24 Mar 2004 16:12:51 -0000 1.5 +++ collision.cpp 24 Mar 2004 17:41:04 -0000 1.6 @@ -261,7 +261,7 @@ } else { - player_collision(&tux, &bad_guys[i], CO_BADGUY); + tux.collision(&bad_guys[i], CO_BADGUY); } } } Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- leveleditor.cpp 24 Mar 2004 16:12:51 -0000 1.15 +++ leveleditor.cpp 24 Mar 2004 17:41:04 -0000 1.16 @@ -854,7 +854,7 @@ case 'x': case 'y': case 'A': - texture_draw(&img_distro[(frame / 5) % 4], x * 32 - ((int)pos_x % 32), y*32); + texture_draw(&img_distro[(global_frame_counter / 5) % 4], x * 32 - ((int)pos_x % 32), y*32); break; default: break; @@ -876,7 +876,7 @@ /* Draw the player: */ /* for now, the position is fixed at (0, 240) */ - texture_draw(&tux_right[(frame / 5) % 3], 0 - pos_x, 240); + texture_draw(&tux_right[(global_frame_counter / 5) % 3], 0 - pos_x, 240); } void le_checkevents() Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- player.cpp 24 Mar 2004 16:12:51 -0000 1.7 +++ player.cpp 24 Mar 2004 17:41:04 -0000 1.8 @@ -17,19 +17,31 @@ #include "scene.h" #include "screen.h" -texture_type tux_life, -tux_right[3], tux_left[3], -bigtux_right[3], bigtux_left[3], -bigtux_right_jump, bigtux_left_jump, -ducktux_right, ducktux_left, -skidtux_right, skidtux_left, -firetux_right[3], firetux_left[3], -bigfiretux_right[3], bigfiretux_left[3], [...1254 lines suppressed...] scroll_x = ((current_level.width * 32) - screen->w); } - else if (pplayer->base.x> 608 + scroll_x) + else if (base.x> 608 + scroll_x) { /* ... unless there's no more to scroll! */ - /*pplayer->base.x= 608 + scroll_x;*/ + /*base.x= 608 + scroll_x;*/ } /* Keep in-bounds, vertically: */ - if (pplayer->base.y > screen->h) + if (base.y > screen->h) { - player_kill(&tux,KILL); + kill(KILL); } } Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- badguy.cpp 24 Mar 2004 16:12:51 -0000 1.9 +++ badguy.cpp 24 Mar 2004 17:41:04 -0000 1.10 @@ -165,7 +165,7 @@ base.y = tux.base.y + tux.base.height/1.5 - base.height; } - if(tux.input.fire != DOWN) /* SHOOT! */ + if(tux.input_.fire != DOWN) /* SHOOT! */ { if(dir == LEFT) base.x -= 24; @@ -377,13 +377,13 @@ /* Alive: */ if (dir == LEFT) { - texture_draw(&img_bsod_left[(frame / 5) % 4], + texture_draw(&img_bsod_left[(global_frame_counter / 5) % 4], base.x - scroll_x, base.y); } else { - texture_draw(&img_bsod_right[(frame / 5) % 4], + texture_draw(&img_bsod_right[(global_frame_counter / 5) % 4], base.x - scroll_x, base.y); } @@ -436,13 +436,13 @@ /* Not flat: */ if (dir == LEFT) { - texture_draw(&img_laptop_left[(frame / 5) % 3], + texture_draw(&img_laptop_left[(global_frame_counter / 5) % 3], base.x - scroll_x, base.y); } else { - texture_draw(&img_laptop_right[(frame / 5) % 3], + texture_draw(&img_laptop_right[(global_frame_counter / 5) % 3], base.x - scroll_x, base.y); } @@ -549,7 +549,7 @@ BadGuy::collision(void *p_c_object, int c_object) { BadGuy* pbad_c = NULL; - player_type* pplayer_c = NULL; + Player* pplayer_c = NULL; switch (c_object) { @@ -600,7 +600,7 @@ break; case CO_PLAYER: - pplayer_c = (player_type*) p_c_object; + pplayer_c = static_cast<Player*>(p_c_object); if(kind != BAD_MONEY) { if (kind == BAD_BSOD) Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- special.cpp 22 Mar 2004 15:47:31 -0000 1.3 +++ special.cpp 24 Mar 2004 17:41:04 -0000 1.4 @@ -221,7 +221,7 @@ void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object) { - player_type* pplayer = NULL; + Player* pplayer = NULL; switch (c_object) { @@ -229,7 +229,7 @@ /* Remove the upgrade: */ /* p_c_object is CO_PLAYER, so assign it to pplayer */ - pplayer = (player_type*) p_c_object; + pplayer = (Player*) p_c_object; upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- scene.h 24 Mar 2004 16:12:51 -0000 1.11 +++ scene.h 24 Mar 2004 17:41:04 -0000 1.12 @@ -35,7 +35,7 @@ extern timer_type super_bkgd_timer; extern float scroll_x; -extern int frame; +extern int global_frame_counter; extern std::vector<bouncy_distro_type> bouncy_distros; extern std::vector<broken_brick_type> broken_bricks; extern std::vector<bouncy_brick_type> bouncy_bricks; @@ -43,7 +43,7 @@ extern std::vector<floating_score_type> floating_scores; extern std::vector<upgrade_type> upgrades; extern std::vector<bullet_type> bullets; -extern player_type tux; +extern Player tux; extern texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; extern timer_type time_left; extern double frame_ratio; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- gameloop.cpp 24 Mar 2004 16:12:51 -0000 1.18 +++ gameloop.cpp 24 Mar 2004 17:41:04 -0000 1.19 @@ -133,7 +133,7 @@ if(show_menu) menu_event(&event.key.keysym); - if(player_key_event(&tux,key,DOWN)) + if(tux.key_event(key,DOWN)) break; switch(key) @@ -164,7 +164,7 @@ case SDL_KEYUP: /* A keyrelease! */ key = event.key.keysym.sym; - if(player_key_event(&tux,key,UP)) + if(tux.key_event(key, UP)) break; switch(key) @@ -236,32 +236,32 @@ case JOY_X: if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) { - tux.input.left = DOWN; - tux.input.right = UP; + tux.input_.left = DOWN; + tux.input_.right = UP; } else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) { - tux.input.left = UP; - tux.input.right = DOWN; + tux.input_.left = UP; + tux.input_.right = DOWN; } else { - tux.input.left = DOWN; - tux.input.right = DOWN; + tux.input_.left = DOWN; + tux.input_.right = DOWN; } break; case JOY_Y: if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - tux.input.down = DOWN; + tux.input_.down = DOWN; else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - tux.input.down = UP; + tux.input_.down = UP; else - tux.input.down = UP; + tux.input_.down = UP; /* Handle joystick for the menu */ if(show_menu) { - if(tux.input.down == DOWN) + if(tux.input_.down == DOWN) menuaction = MENU_ACTION_DOWN; else menuaction = MENU_ACTION_UP; @@ -273,15 +273,15 @@ break; case SDL_JOYBUTTONDOWN: if (event.jbutton.button == JOY_A) - tux.input.up = DOWN; + tux.input_.up = DOWN; else if (event.jbutton.button == JOY_B) - tux.input.fire = DOWN; + tux.input_.fire = DOWN; break; case SDL_JOYBUTTONUP: if (event.jbutton.button == JOY_A) - tux.input.up = UP; + tux.input_.up = UP; else if (event.jbutton.button == JOY_B) - tux.input.fire = UP; + tux.input_.fire = UP; if(show_menu) menuaction = MENU_ACTION_HIT; @@ -327,11 +327,11 @@ arrays_free(); return(0); } - player_level_begin(&tux); + tux.level_begin(); } else { - player_dying(&tux); + tux.is_dying(); /* No more lives!? */ @@ -356,7 +356,7 @@ /* Either way, (re-)load the (next) level... */ - player_level_begin(&tux); + tux.level_begin(); set_defaults(); level_free(¤t_level); @@ -385,10 +385,9 @@ play_current_music(); } - player_action(&tux); + tux.action(); /* Handle bouncy distros: */ - for (i = 0; i < bouncy_distros.size(); i++) { bouncy_distro_action(&bouncy_distros[i]); @@ -396,7 +395,6 @@ /* Handle broken bricks: */ - for (i = 0; i < broken_bricks.size(); i++) { broken_brick_action(&broken_bricks[i]); @@ -467,7 +465,7 @@ /* Draw screen: */ - if (tux.dying && (frame % 4) == 0) + if (tux.dying && (global_frame_counter % 4) == 0) clearscreen(255, 255, 255); else if(timer_check(&super_bkgd_timer)) texture_draw(&img_super_bkgd, 0, 0); @@ -507,25 +505,21 @@ /* (Bad guys): */ - for (i = 0; i < bad_guys.size(); ++i) { bad_guys[i].draw(); } /* (Tux): */ - - player_draw(&tux); + tux.draw(); /* (Bullets): */ - for (i = 0; i < bullets.size(); ++i) { bullet_draw(&bullets[i]); } /* (Floating scores): */ - for (i = 0; i < floating_scores.size(); ++i) { floating_score_draw(&floating_scores[i]); @@ -533,7 +527,6 @@ /* (Upgrades): */ - for (i = 0; i < upgrades.size(); ++i) { upgrade_draw(&upgrades[i]); @@ -541,7 +534,6 @@ /* (Bouncy distros): */ - for (i = 0; i < bouncy_distros.size(); ++i) { bouncy_distro_draw(&bouncy_distros[i]); @@ -549,7 +541,6 @@ /* (Broken bricks): */ - for (i = 0; i < broken_bricks.size(); ++i) { broken_brick_draw(&broken_bricks[i]); @@ -557,7 +548,6 @@ drawstatus(); - if(game_pause) { x = screen->h / 20; @@ -614,7 +604,7 @@ activate_bad_guys(); level_load_song(¤t_level); - player_init(&tux); + tux.init(); if(st_gl_mode != ST_GL_TEST) load_hs(); @@ -636,7 +626,7 @@ jump = false; done = 0; quit = 0; - frame = 0; + global_frame_counter = 0; game_pause = 0; timer_init(&fps_timer,true); timer_init(&frame_timer,true); @@ -667,12 +657,12 @@ if(!timer_check(&frame_timer)) { timer_start(&frame_timer,25); - ++frame; + ++global_frame_counter; } /* Handle events: */ - tux.input.old_fire = tux.input.fire; + tux.input_.old_fire = tux.input_.fire; game_event(); @@ -783,7 +773,7 @@ } else - player_kill(&tux,KILL); + tux.kill(KILL); /* Calculate frames per second */ @@ -1326,7 +1316,7 @@ texture_draw(&img_solid[3], x, y); else if (c == '$') { - z = (frame / 2) % 6; + z = (global_frame_counter / 2) % 6; if (z < 4) texture_draw(&img_distro[z], x, y); @@ -1337,7 +1327,7 @@ } else if (c == '^') { - z = (frame / 3) % 3; + z = (global_frame_counter / 3) % 3; texture_draw(&img_waves[z], x, y); } @@ -1350,7 +1340,7 @@ } else if (c == '\\') { - z = (frame / 3) % 2; + z = (global_frame_counter / 3) % 2; texture_draw(&img_flag[z], x + 16, y); } @@ -1601,7 +1591,7 @@ text_draw(&white_text,"Press ESC To Return",0,20,1); } - if (timer_get_left(&time_left) > TIME_WARNING || (frame % 10) < 5) + if (timer_get_left(&time_left) > TIME_WARNING || (global_frame_counter % 10) < 5) { sprintf(str, "%d", timer_get_left(&time_left) / 1000 ); text_draw(&white_text, "TIME", 224, 0, 1); @@ -1687,7 +1677,7 @@ fwrite(&score,sizeof(int),1,fi); fwrite(&distros,sizeof(int),1,fi); fwrite(&scroll_x,sizeof(float),1,fi); - fwrite(&tux,sizeof(player_type),1,fi); + fwrite(&tux,sizeof(Player),1,fi); timer_fwrite(&tux.invincible_timer,fi); timer_fwrite(&tux.skidding_timer,fi); timer_fwrite(&tux.safe_timer,fi); @@ -1740,7 +1730,7 @@ fread(&score,sizeof(int),1,fi); fread(&distros,sizeof(int),1,fi); fread(&scroll_x,sizeof(float),1,fi); - fread(&tux,sizeof(player_type),1,fi); + fread(&tux, sizeof(Player), 1, fi); timer_fread(&tux.invincible_timer,fi); timer_fread(&tux.skidding_timer,fi); timer_fread(&tux.safe_timer,fi); |
From: Ingo R. <gr...@us...> - 2004-03-24 16:24:06
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29165 Added Files: configfile.cpp configfile.h Log Message: - commited Michael George's config-file patch --- NEW FILE: configfile.h --- #ifndef SUPERTUX_CONFIGFILE_H #define SUPERTUX_CONFIGFILE_H void loadconfig (void); void saveconfig (void); #endif --- NEW FILE: configfile.cpp --- // $Id: configfile.cpp,v 1.1 2004/03/24 16:13:27 grumbel Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Michael George <mi...@ge...> // // 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 <stdlib.h> #include <string> #include "configfile.h" #include "setup.h" #include "globals.h" #include "lispreader.h" #ifdef WIN32 const char * config_filename = "/st_config.dat"; #else const char * config_filename = "/config"; #endif static void defaults () { /* Set defaults: */ debug_mode = false; audio_device = true; use_fullscreen = false; show_fps = false; use_gl = false; use_sound = true; use_music = true; } void loadconfig(void) { FILE * file = NULL; defaults(); /* override defaults from config file */ file = opendata(config_filename, "r"); if (file == NULL) return; /* read config file */ lisp_stream_t stream; lisp_object_t * root_obj = NULL; lisp_stream_init_file (&stream, file); root_obj = lisp_read (&stream); if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) return; if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-config") != 0) return; LispReader reader(lisp_cdr(root_obj)); reader.read_bool("fullscreen", &use_fullscreen); reader.read_bool("sound", &use_sound); reader.read_bool("music", &use_music); reader.read_bool("show_fps", &show_fps); std::string video; reader.read_string ("video", &video); if (video == "opengl") use_gl = true; else use_gl = false; reader.read_int ("joystick", &joystick_num); if (!(joystick_num >= 0)) use_joystick = false; else use_joystick = true; } void saveconfig (void) { /* write settings to config file */ FILE * config = opendata(config_filename, "w"); if(config) { fprintf(config, "(supertux-config\n"); fprintf(config, "\t;; the following options can be set to #t or #f:\n"); fprintf(config, "\t(fullscreen %s)\n", use_fullscreen ? "#t" : "#f"); fprintf(config, "\t(sound %s)\n", use_sound ? "#t" : "#f"); fprintf(config, "\t(music %s)\n", use_music ? "#t" : "#f"); fprintf(config, "\t(show_fps %s)\n", show_fps ? "#t" : "#f"); fprintf(config, "\n\t;; either \"opengl\" or \"sdl\"\n"); fprintf(config, "\t(video \"%s\")\n", use_gl ? "opengl" : "sdl"); fprintf(config, "\n\t;; joystick number (-1 means no joystick):\n"); fprintf(config, "\t(joystick %d)\n", use_joystick ? joystick_num : -1); fprintf(config, ")\n"); } } /* EOF */ |
From: Ingo R. <gr...@us...> - 2004-03-24 16:23:32
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28956 Modified Files: badguy.cpp badguy.h collision.cpp gameloop.cpp level.cpp leveleditor.cpp player.cpp scene.cpp scene.h texture.cpp worldmap.cpp Log Message: - coverted badguy type into an object Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- scene.cpp 24 Mar 2004 15:24:07 -0000 1.4 +++ scene.cpp 24 Mar 2004 16:12:51 -0000 1.5 @@ -29,7 +29,7 @@ std::vector<bouncy_distro_type> bouncy_distros; std::vector<broken_brick_type> broken_bricks; std::vector<bouncy_brick_type> bouncy_bricks; -std::vector<bad_guy_type> bad_guys; +std::vector<BadGuy> bad_guys; std::vector<floating_score_type> floating_scores; std::vector<upgrade_type> upgrades; std::vector<bullet_type> bullets; @@ -133,8 +133,8 @@ void add_bad_guy(float x, float y, BadGuyKind kind) { - bad_guy_type new_bad_guy; - badguy_init(&new_bad_guy,x,y,kind); + BadGuy new_bad_guy; + new_bad_guy.init(x,y,kind); bad_guys.push_back(new_bad_guy); } Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- worldmap.cpp 24 Mar 2004 14:35:11 -0000 1.14 +++ worldmap.cpp 24 Mar 2004 16:12:51 -0000 1.15 @@ -34,11 +34,11 @@ TileManager::TileManager() { - std::string filename = datadir + "images/worldmap/antarctica.scm"; - lisp_object_t* root_obj = lisp_read_from_file(filename); + std::string stwt_filename = datadir + "images/worldmap/antarctica.scm"; + lisp_object_t* root_obj = lisp_read_from_file(stwt_filename); if (!root_obj) - st_abort("Couldn't load file", filename); + st_abort("Couldn't load file", stwt_filename); if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap-tiles") == 0) { Index: texture.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/texture.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- texture.cpp 24 Mar 2004 13:52:34 -0000 1.6 +++ texture.cpp 24 Mar 2004 16:12:51 -0000 1.7 @@ -73,13 +73,12 @@ /* Quick utility function for texture creation */ static int power_of_two(int input) { - int value = 1; - int a; + int value = 1; - while ( value < input ) { - value <<= 1; - } - return value; + while ( value < input ) { + value <<= 1; + } + return value; } void texture_create_gl(SDL_Surface * surf, GLuint * tex) Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- scene.h 24 Mar 2004 15:24:07 -0000 1.10 +++ scene.h 24 Mar 2004 16:12:51 -0000 1.11 @@ -39,7 +39,7 @@ extern std::vector<bouncy_distro_type> bouncy_distros; extern std::vector<broken_brick_type> broken_bricks; extern std::vector<bouncy_brick_type> bouncy_bricks; -extern std::vector<bad_guy_type> bad_guys; +extern std::vector<BadGuy> bad_guys; extern std::vector<floating_score_type> floating_scores; extern std::vector<upgrade_type> upgrades; extern std::vector<bullet_type> bullets; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- gameloop.cpp 24 Mar 2004 15:24:05 -0000 1.17 +++ gameloop.cpp 24 Mar 2004 16:12:51 -0000 1.18 @@ -51,7 +51,6 @@ static SDL_Event event; static SDLKey key; static char level_subset[100]; -static char str[60]; static float fps_fps; static int st_gl_mode; static unsigned int last_update_time; @@ -70,8 +69,8 @@ void levelintro(void) { + char str[60]; /* Level Intro: */ - clearscreen(0, 0, 0); sprintf(str, "LEVEL %d", level); @@ -450,7 +449,7 @@ for (i = 0; i < bad_guys.size(); i++) { - badguy_action(&bad_guys[i]); + bad_guys[i].action(); } /* Handle all possible collisions. */ @@ -511,7 +510,7 @@ for (i = 0; i < bad_guys.size(); ++i) { - badguy_draw(&bad_guys[i]); + bad_guys[i].draw(); } /* (Tux): */ @@ -1585,7 +1584,7 @@ /* (Status): */ void drawstatus(void) { - int i; + char str[60]; sprintf(str, "%d", score); text_draw(&white_text, "SCORE", 0, 0, 1); @@ -1622,7 +1621,7 @@ text_draw(&gold_text, str, screen->h + 60, 40, 1); } - for(i=0; i < tux.lives; ++i) + for(int i=0; i < tux.lives; ++i) { texture_draw(&tux_life,565+(18*i),20); } Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- player.cpp 23 Mar 2004 01:30:16 -0000 1.6 +++ player.cpp 24 Mar 2004 16:12:51 -0000 1.7 @@ -803,12 +803,12 @@ void player_collision(player_type* pplayer, void* p_c_object, int c_object) { - bad_guy_type* pbad_c = NULL; + BadGuy* pbad_c = NULL; switch (c_object) { case CO_BADGUY: - pbad_c = (bad_guy_type*) p_c_object; + pbad_c = (BadGuy*) p_c_object; /* Hurt the player if he just touched it: */ if (!pbad_c->dying && !pplayer->dying && Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- collision.cpp 22 Mar 2004 15:47:31 -0000 1.4 +++ collision.cpp 24 Mar 2004 16:12:51 -0000 1.5 @@ -219,7 +219,7 @@ { /* We have detected a collision and now call the collision functions of the collided objects. */ bullet_collision(&bullets[i], CO_BADGUY); - badguy_collision(&bad_guys[j], &bullets[i], CO_BULLET); + bad_guys[j].collision(&bullets[i], CO_BULLET); } } } @@ -237,8 +237,8 @@ if(rectcollision(&bad_guys[i].base, &bad_guys[j].base)) { /* We have detected a collision and now call the collision functions of the collided objects. */ - badguy_collision(&bad_guys[j], &bad_guys[i], CO_BADGUY); - badguy_collision(&bad_guys[i], &bad_guys[j], CO_BADGUY); + bad_guys[j].collision(&bad_guys[i], CO_BADGUY); + bad_guys[i].collision(&bad_guys[j], CO_BADGUY); } } } @@ -257,7 +257,7 @@ tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 && bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD) { - badguy_collision(&bad_guys[i], &tux, CO_PLAYER); + bad_guys[i].collision(&tux, CO_PLAYER); } else { Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- leveleditor.cpp 24 Mar 2004 15:24:05 -0000 1.14 +++ leveleditor.cpp 24 Mar 2004 16:12:51 -0000 1.15 @@ -1332,7 +1332,7 @@ /* if there is a bad guy over there, remove it */ for(i = 0; i < bad_guys.size(); ++i) if(xx == bad_guys[i].base.x/32 && yy == bad_guys[i].base.y/32) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(&bad_guys[i])); + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&bad_guys[i])); if(c == '0') /* if it's a bad guy */ add_bad_guy(xx*32, yy*32, BAD_BSOD); @@ -1373,7 +1373,7 @@ for(i = 0; i < bad_guys.size(); ++i) if(bad_guys[i].base.x/32 >= x1 && bad_guys[i].base.x/32 <= x2 && bad_guys[i].base.y/32 >= y1 && bad_guys[i].base.y/32 <= y2) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(&bad_guys[i])); + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&bad_guys[i])); for(xx = x1; xx <= x2; xx++) for(yy = y1; yy <= y2; yy++) Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- badguy.h 24 Mar 2004 15:24:05 -0000 1.12 +++ badguy.h 24 Mar 2004 16:12:51 -0000 1.13 @@ -27,6 +27,21 @@ #define KICK 2 #define HELD 3 +extern texture_type img_bsod_squished_left; +extern texture_type img_bsod_squished_right; +extern texture_type img_bsod_falling_left; +extern texture_type img_bsod_falling_right; +extern texture_type img_laptop_flat_left; +extern texture_type img_laptop_flat_right; +extern texture_type img_laptop_falling_left; +extern texture_type img_laptop_falling_right; +extern texture_type img_bsod_left[4]; +extern texture_type img_bsod_right[4]; +extern texture_type img_laptop_left[3]; +extern texture_type img_laptop_right[3]; +extern texture_type img_money_left[2]; +extern texture_type img_money_right[2]; + /* Bad guy kinds: */ enum BadGuyKind { BAD_BSOD, @@ -35,53 +50,35 @@ }; /* Badguy type: */ -struct bad_guy_type +class BadGuy { + public: int mode; DyingType dying; BadGuyKind kind; bool seen; int dir; - int frame; base_type base; base_type old_base; timer_type timer; physic_type physic; -}; -extern texture_type img_bsod_squished_left; -extern texture_type img_bsod_squished_right; -extern texture_type img_bsod_falling_left; -extern texture_type img_bsod_falling_right; -extern texture_type img_laptop_flat_left; -extern texture_type img_laptop_flat_right; -extern texture_type img_laptop_falling_left; -extern texture_type img_laptop_falling_right; -extern texture_type img_bsod_left[4]; -extern texture_type img_bsod_right[4]; -extern texture_type img_laptop_left[3]; -extern texture_type img_laptop_right[3]; -extern texture_type img_money_left[2]; -extern texture_type img_money_right[2]; - -extern bitmask *bm_bsod; - -void badguy_create_bitmasks(); - -void badguy_init(bad_guy_type* pbad, float x, float y, BadGuyKind kind); + public: + void init(float x, float y, BadGuyKind kind); -void badguy_action(bad_guy_type* pbad); -void badguy_draw(bad_guy_type* pbad); + void action(); + void draw(); -void badguy_action_bsod(bad_guy_type* pbad); -void badguy_action_laptop(bad_guy_type* pbad); -void badguy_action_money(bad_guy_type* pbad); + void action_bsod(); + void action_laptop(); + void action_money(); -void badguy_draw_bsod(bad_guy_type* pbad); -void badguy_draw_laptop(bad_guy_type* pbad); -void badguy_draw_money(bad_guy_type* pbad); + void draw_bsod(); + void draw_laptop(); + void draw_money(); -void badguy_collision(bad_guy_type* pbad, void* p_c_object, int c_object); + void collision(void* p_c_object, int c_object); +}; #endif /*SUPERTUX_BADGUY_H*/ Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- badguy.cpp 24 Mar 2004 15:24:04 -0000 1.8 +++ badguy.cpp 24 Mar 2004 16:12:51 -0000 1.9 @@ -31,156 +31,150 @@ texture_type img_money_left[2]; texture_type img_money_right[2]; -bitmask *bm_bsod; - -void badguy_create_bitmasks() -{ - /*bm_bsod = img_bsod_left[0];*/ -} - -void badguy_init(bad_guy_type* pbad, float x, float y, BadGuyKind kind) +void +BadGuy::init(float x, float y, BadGuyKind kind_) { - pbad->base.width = 32; - pbad->base.height = 32; - pbad->mode = NORMAL; - pbad->dying = DYING_NOT; - pbad->kind = kind; - pbad->base.x = x; - pbad->base.y = y; - pbad->base.xm = 1.3; - pbad->base.ym = 4.8; - pbad->old_base = pbad->base; - pbad->dir = LEFT; - pbad->seen = false; - timer_init(&pbad->timer, true); - physic_init(&pbad->physic); + base.width = 32; + base.height = 32; + mode = NORMAL; + dying = DYING_NOT; + kind = kind_; + base.x = x; + base.y = y; + base.xm = 1.3; + base.ym = 4.8; + old_base = base; + dir = LEFT; + seen = false; + timer_init(&timer, true); + physic_init(&physic); } -void badguy_action_bsod(bad_guy_type* pbad) +void BadGuy::action_bsod() { /* --- BLUE SCREEN OF DEATH MONSTER: --- */ /* Move left/right: */ - if (pbad->dying == DYING_NOT || - pbad->dying == DYING_FALLING) + if (dying == DYING_NOT || + dying == DYING_FALLING) { - if (pbad->dir == RIGHT) - pbad->base.x = pbad->base.x + pbad->base.xm * frame_ratio; - else if (pbad->dir == LEFT) - pbad->base.x = pbad->base.x - pbad->base.xm * frame_ratio; + if (dir == RIGHT) + base.x = base.x + base.xm * frame_ratio; + else if (dir == LEFT) + base.x = base.x - base.xm * frame_ratio; } /* Move vertically: */ - pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - if (pbad->dying != DYING_FALLING) - collision_swept_object_map(&pbad->old_base,&pbad->base); - if (pbad->base.y > screen->h) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + if (dying != DYING_FALLING) + collision_swept_object_map(&old_base,&base); + if (base.y > screen->h) + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); /* Bump into things horizontally: */ - if (!pbad->dying) + if (!dying) { - if (issolid( pbad->base.x, (int) pbad->base.y + 16)) + if (issolid( base.x, (int) base.y + 16)) { - pbad->dir = RIGHT; + dir = RIGHT; } - else if (issolid( pbad->base.x + pbad->base.width, (int) pbad->base.y + 16)) + else if (issolid( base.x + base.width, (int) base.y + 16)) { - pbad->dir = LEFT; + dir = LEFT; } } /* Fall if we get off the ground: */ - if (pbad->dying != DYING_FALLING) + if (dying != DYING_FALLING) { - if (!issolid(pbad->base.x+16, pbad->base.y + 32)) + if (!issolid(base.x+16, base.y + 32)) { - if(!physic_is_set(&pbad->physic)) + if(!physic_is_set(&physic)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,2.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,2.); } - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } else { /* Land: */ - if (pbad->base.ym > 0) + if (base.ym > 0) { - pbad->base.y = (int)(pbad->base.y / 32) * 32; - pbad->base.ym = 0; + base.y = (int)(base.y / 32) * 32; + base.ym = 0; } - physic_init(&pbad->physic); + physic_init(&physic); } } else { - if(!physic_is_set(&pbad->physic)) + if(!physic_is_set(&physic)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,2.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,2.); } - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } - if (pbad->base.y > screen->h) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + if (base.y > screen->h) + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); } -void badguy_action_laptop(bad_guy_type* pbad) +void BadGuy::action_laptop() { /* --- LAPTOP MONSTER: --- */ /* Move left/right: */ - if (pbad->mode == NORMAL || pbad->mode == KICK) + if (mode == NORMAL || mode == KICK) { - if (pbad->dying == DYING_NOT || - pbad->dying == DYING_FALLING) + if (dying == DYING_NOT || + dying == DYING_FALLING) { - if (pbad->dir == RIGHT) - pbad->base.x = pbad->base.x + pbad->base.xm * frame_ratio; - else if (pbad->dir == LEFT) - pbad->base.x = pbad->base.x - pbad->base.xm * frame_ratio; + if (dir == RIGHT) + base.x = base.x + base.xm * frame_ratio; + else if (dir == LEFT) + base.x = base.x - base.xm * frame_ratio; } } - else if (pbad->mode == HELD) + else if (mode == HELD) { /* FIXME: The pbad object shouldn't know about pplayer objects. */ /* If we're holding the laptop */ - pbad->dir=tux.dir; - if(pbad->dir==RIGHT) + dir=tux.dir; + if(dir==RIGHT) { - pbad->base.x = tux.base.x + 16; - pbad->base.y = tux.base.y + tux.base.height/1.5 - pbad->base.height; + base.x = tux.base.x + 16; + base.y = tux.base.y + tux.base.height/1.5 - base.height; } else /* facing left */ { - pbad->base.x = tux.base.x - 16; - pbad->base.y = tux.base.y + tux.base.height/1.5 - pbad->base.height; + base.x = tux.base.x - 16; + base.y = tux.base.y + tux.base.height/1.5 - base.height; } - if(collision_object_map(&pbad->base)) + if(collision_object_map(&base)) { - pbad->base.x = tux.base.x; - pbad->base.y = tux.base.y + tux.base.height/1.5 - pbad->base.height; + base.x = tux.base.x; + base.y = tux.base.y + tux.base.height/1.5 - base.height; } if(tux.input.fire != DOWN) /* SHOOT! */ { - if(pbad->dir == LEFT) - pbad->base.x -= 24; + if(dir == LEFT) + base.x -= 24; else - pbad->base.x += 24; + base.x += 24; - pbad->mode=KICK; - pbad->base.xm = 8; - pbad->base.ym = 8; + mode=KICK; + base.xm = 8; + base.ym = 8; play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER); } } @@ -188,35 +182,35 @@ /* Move vertically: */ - if(pbad->mode != HELD) - pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio; + if(mode != HELD) + base.y = base.y + base.ym * frame_ratio; - if (pbad->dying != DYING_FALLING) - collision_swept_object_map(&pbad->old_base,&pbad->base); - if (pbad->base.y > screen->h) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + if (dying != DYING_FALLING) + collision_swept_object_map(&old_base,&base); + if (base.y > screen->h) + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); /* Bump into things horizontally: */ /* Bump into things horizontally: */ - if (!pbad->dying) + if (!dying) { - int changed = pbad->dir; - if (issolid( pbad->base.x, (int) pbad->base.y + 16)) + int changed = dir; + if (issolid( base.x, (int) base.y + 16)) { - pbad->dir = RIGHT; + dir = RIGHT; } - else if (issolid( pbad->base.x + pbad->base.width, (int) pbad->base.y + 16)) + else if (issolid( base.x + base.width, (int) base.y + 16)) { - pbad->dir = LEFT; + dir = LEFT; } - if(pbad->mode == KICK && changed != pbad->dir) + if(mode == KICK && changed != dir) { /* handle stereo sound */ /* FIXME: In theory a badguy object doesn't know anything about player objects */ - if (tux.base.x > pbad->base.x) + if (tux.base.x > base.x) play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER); - else if (tux.base.x < pbad->base.x) + else if (tux.base.x < base.x) play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER); else play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER); @@ -227,321 +221,321 @@ /* Fall if we get off the ground: */ - if (pbad->dying != DYING_FALLING) + if (dying != DYING_FALLING) { - if (!issolid(pbad->base.x+16, pbad->base.y + 32)) + if (!issolid(base.x+16, base.y + 32)) { - if(!physic_is_set(&pbad->physic)) + if(!physic_is_set(&physic)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,0.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,0.); } - if(pbad->mode != HELD) + if(mode != HELD) { - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } } else { /* Land: */ - if (pbad->base.ym > 0) + if (base.ym > 0) { - pbad->base.y = (int)(pbad->base.y / 32) * 32; - pbad->base.ym = 0; + base.y = (int)(base.y / 32) * 32; + base.ym = 0; } - physic_init(&pbad->physic); + physic_init(&physic); } } else { - if(!physic_is_set(&pbad->physic)) + if(!physic_is_set(&physic)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,0.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,0.); } - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } } -void badguy_action_money(bad_guy_type* pbad) +void BadGuy::action_money() { /* --- MONEY BAGS: --- */ /* Move vertically: */ - pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - if (pbad->dying != DYING_FALLING) - collision_swept_object_map(&pbad->old_base,&pbad->base); + if (dying != DYING_FALLING) + collision_swept_object_map(&old_base,&base); - if (pbad->base.y > screen->h) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + if (base.y > screen->h) + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); - if(physic_get_state(&pbad->physic) == -1) + if(physic_get_state(&physic) == -1) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,0.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,0.); } - if (pbad->dying != DYING_FALLING) + if (dying != DYING_FALLING) { - if(issolid(pbad->base.x, pbad->base.y + 32)) + if(issolid(base.x, base.y + 32)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,6.); - pbad->base.ym = physic_get_velocity(&pbad->physic); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,6.); + base.ym = physic_get_velocity(&physic); } - else if(issolid(pbad->base.x, pbad->base.y)) + else if(issolid(base.x, base.y)) { /* This works, but isn't the best solution imagineable */ - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,0.); - pbad->base.ym = physic_get_velocity(&pbad->physic); - ++pbad->base.y; + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,0.); + base.ym = physic_get_velocity(&physic); + ++base.y; } else { - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } } else { - if(!physic_is_set(&pbad->physic)) + if(!physic_is_set(&physic)) { - physic_set_state(&pbad->physic,PH_VT); - physic_set_start_vy(&pbad->physic,0.); + physic_set_state(&physic,PH_VT); + physic_set_start_vy(&physic,0.); } - pbad->base.ym = physic_get_velocity(&pbad->physic); + base.ym = physic_get_velocity(&physic); } } -void badguy_action(bad_guy_type* pbad) +void +BadGuy::action() { - if (pbad->seen) + if (seen) { - switch (pbad->kind) + switch (kind) { case BAD_BSOD: - badguy_action_bsod(pbad); + action_bsod(); break; case BAD_LAPTOP: - badguy_action_bsod(pbad); + action_bsod(); break; case BAD_MONEY: - badguy_action_money(pbad); + action_money(); break; } } /* Handle mode timer: */ - if (pbad->mode == FLAT && pbad->mode != HELD) + if (mode == FLAT && mode != HELD) { - if(!timer_check(&pbad->timer)) + if(!timer_check(&timer)) { - pbad->mode = NORMAL; - pbad->base.xm = 4; + mode = NORMAL; + base.xm = 4; } } - else if (pbad->mode == KICK) + else if (mode == KICK) { - timer_check(&pbad->timer); + timer_check(&timer); } // Handle dying timer: - if (pbad->dying == DYING_SQUISHED) + if (dying == DYING_SQUISHED) { /* Remove it if time's up: */ - if(!timer_check(&pbad->timer)) - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + if(!timer_check(&timer)) + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); } // Remove if it's far off the screen: - if (pbad->base.x < scroll_x - OFFSCREEN_DISTANCE) + if (base.x < scroll_x - OFFSCREEN_DISTANCE) { - bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad)); + bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(this)); return; } else /* !seen */ { // Once it's on screen, it's activated! - if (pbad->base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE) - pbad->seen = true; + if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE) + seen = true; } } -void badguy_draw_bsod(bad_guy_type* pbad) +void +BadGuy::draw_bsod() { /* --- BLUE SCREEN OF DEATH MONSTER: --- */ - if (pbad->dying == DYING_NOT) + if (dying == DYING_NOT) { /* Alive: */ - - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_bsod_left[(frame / 5) % 4], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_bsod_right[(frame / 5) % 4], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } - else if (pbad->dying == DYING_FALLING) + else if (dying == DYING_FALLING) { /* Falling: */ - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_bsod_falling_left, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_bsod_falling_right, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } - else if (pbad->dying == DYING_SQUISHED) + else if (dying == DYING_SQUISHED) { /* Dying - Squished: */ - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_bsod_squished_left, - pbad->base.x - scroll_x, - pbad->base.y + 24); + base.x - scroll_x, + base.y + 24); } else { texture_draw(&img_bsod_squished_right, - pbad->base.x - scroll_x, - pbad->base.y + 24); + base.x - scroll_x, + base.y + 24); } } } -void badguy_draw_laptop(bad_guy_type* pbad) +void BadGuy::draw_laptop() { /* --- LAPTOP MONSTER: --- */ - if (pbad->dying == DYING_NOT) + if (dying == DYING_NOT) { /* Alive: */ - if (pbad->mode == NORMAL) + if (mode == NORMAL) { /* Not flat: */ - - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_laptop_left[(frame / 5) % 3], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_laptop_right[(frame / 5) % 3], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } else { /* Flat: */ - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_laptop_flat_left, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_laptop_flat_right, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } } - else if (pbad->dying == DYING_FALLING) + else if (dying == DYING_FALLING) { /* Falling: */ - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_laptop_falling_left, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_laptop_falling_right, - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } } -void badguy_draw_money(bad_guy_type* pbad) +void BadGuy::draw_money() { - if (pbad->base.ym != 300 /* > -16*/) + if (base.ym != 300 /* > -16*/) { - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_money_left[0], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_money_right[0], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } else { - if (pbad->dir == LEFT) + if (dir == LEFT) { texture_draw(&img_money_left[1], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } else { texture_draw(&img_money_right[1], - pbad->base.x - scroll_x, - pbad->base.y); + base.x - scroll_x, + base.y); } } } -void badguy_draw(bad_guy_type* pbad) +void BadGuy::draw() { // Don't try to draw stuff that is outside of the screen - if (pbad->base.x > scroll_x - 32 && - pbad->base.x < scroll_x + screen->w) + if (base.x > scroll_x - 32 && + base.x < scroll_x + screen->w) { - switch (pbad->kind) + switch (kind) { case BAD_BSOD: - badguy_draw_bsod(pbad); + draw_bsod(); break; case BAD_LAPTOP: - badguy_draw_laptop(pbad); + draw_laptop(); break; case BAD_MONEY: - badguy_draw_money(pbad); + draw_money(); break; default: @@ -551,27 +545,27 @@ } } -void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object) +void +BadGuy::collision(void *p_c_object, int c_object) { - bad_guy_type* pbad_c = NULL; - player_type* pplayer_c = NULL; + BadGuy* pbad_c = NULL; + player_type* pplayer_c = NULL; switch (c_object) { case CO_BULLET: - pbad->dying = DYING_FALLING; - pbad->base.ym = -8; + dying = DYING_FALLING; + base.ym = -8; /* Gain some points: */ - - if (pbad->kind == BAD_BSOD) - add_score(pbad->base.x - scroll_x, pbad->base.y, + if (kind == BAD_BSOD) + add_score(base.x - scroll_x, base.y, 50 * score_multiplier); - else if (pbad->kind == BAD_LAPTOP) - add_score(pbad->base.x - scroll_x, pbad->base.y, + else if (kind == BAD_LAPTOP) + add_score(base.x - scroll_x, base.y, 25 * score_multiplier); - else if (pbad->kind == BAD_MONEY) - add_score(pbad->base.x - scroll_x, pbad->base.y, + else if (kind == BAD_MONEY) + add_score(base.x - scroll_x, base.y, 50 * score_multiplier); /* Play death sound: */ @@ -579,12 +573,12 @@ break; case CO_BADGUY: - pbad_c = (bad_guy_type*) p_c_object; - if (pbad->mode == NORMAL) + pbad_c = (BadGuy*) p_c_object; + if (mode == NORMAL) { /* do nothing */ } - else if(pbad->mode == KICK) + else if(mode == KICK) { /* We're in kick mode, kill the other guy and yourself(wuahaha) : */ @@ -593,12 +587,12 @@ pbad_c->base.ym = -8; play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); - add_score(pbad->base.x - scroll_x, - pbad->base.y, 100); + add_score(base.x - scroll_x, + base.y, 100); pbad_c->dying = DYING_FALLING; - pbad->dying = DYING_FALLING; - pbad->base.ym = -8; + dying = DYING_FALLING; + base.ym = -8; add_score(pbad_c->base.x - scroll_x, pbad_c->base.y, 100); @@ -607,60 +601,60 @@ case CO_PLAYER: pplayer_c = (player_type*) p_c_object; - if(pbad->kind != BAD_MONEY) + if(kind != BAD_MONEY) { - if (pbad->kind == BAD_BSOD) + if (kind == BAD_BSOD) { - pbad->dying = DYING_SQUISHED; - timer_start(&pbad->timer,4000); + dying = DYING_SQUISHED; + timer_start(&timer,4000); physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); - pplayer_c->base.y = pbad->base.y - pplayer_c->base.height - 1; + pplayer_c->base.y = base.y - pplayer_c->base.height - 1; - add_score(pbad->base.x - scroll_x, pbad->base.y, + add_score(base.x - scroll_x, base.y, 50 * score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); } - else if (pbad->kind == BAD_LAPTOP) + else if (kind == BAD_LAPTOP) { - if (pbad->mode == NORMAL || pbad->mode == KICK) + if (mode == NORMAL || mode == KICK) { /* Flatten! */ play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER); - pbad->mode = FLAT; - pbad->base.xm = 4; + mode = FLAT; + base.xm = 4; - timer_start(&pbad->timer,10000); + timer_start(&timer,10000); physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); - pplayer_c->base.y = pbad->base.y - pplayer_c->base.height - 1; + pplayer_c->base.y = base.y - pplayer_c->base.height - 1; } - else if (pbad->mode == FLAT) + else if (mode == FLAT) { /* Kick! */ play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER); - if (pplayer_c->base.x < pbad->base.x + (pbad->base.width/2)) - pbad->dir = RIGHT; + if (pplayer_c->base.x < base.x + (base.width/2)) + dir = RIGHT; else - pbad->dir = LEFT; + dir = LEFT; - pbad->base.xm = 5; - pbad->mode = KICK; + base.xm = 5; + mode = KICK; - timer_start(&pbad->timer,5000); + timer_start(&timer,5000); } physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); - pplayer_c->base.y = pbad->base.y - pplayer_c->base.height - 1; + pplayer_c->base.y = base.y - pplayer_c->base.height - 1; - add_score(pbad->base.x - scroll_x, - pbad->base.y, + add_score(base.x - scroll_x, + base.y, 25 * score_multiplier); /* play_sound(sounds[SND_SQUISH]); */ @@ -671,3 +665,5 @@ } } + +// EOF // Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- level.cpp 21 Mar 2004 15:41:08 -0000 1.9 +++ level.cpp 24 Mar 2004 16:12:51 -0000 1.10 @@ -216,7 +216,7 @@ /* Load data for this level: */ /* Returns -1, if the loading of the level failed. */ -int level_load(st_level* plevel,const char *subset, int level) +int level_load(st_level* plevel, const char *subset, int level) { char filename[1024]; |