From: Ingo Ruhnke Date: Sun, 18 Apr 2004 21:16:53 +0000 (+0000) Subject: - fixed some align problems with tux X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c09f7145be9014f0e276c9b5421f7bc198aa1242;p=supertux.git - fixed some align problems with tux - fixed bug in tilemap resize SVN-Revision: 562 --- diff --git a/data/supertux.strf b/data/supertux.strf index 56414cd28..0805cdabb 100644 --- a/data/supertux.strf +++ b/data/supertux.strf @@ -160,6 +160,8 @@ (sprite (name "largetux-walk-left") + (x-hotspot 6) + (y-hotspot 2) (images "shared/largetux-walk-left-0.png" "shared/largetux-walk-left-1.png" "shared/largetux-walk-left-2.png" @@ -168,6 +170,8 @@ "shared/largetux-walk-left-5.png")) (sprite (name "largetux-walk-right") + (x-hotspot 6) + (y-hotspot 2) (images "shared/largetux-walk-right-0.png" "shared/largetux-walk-right-1.png" "shared/largetux-walk-right-2.png" @@ -176,11 +180,23 @@ "shared/largetux-walk-right-5.png")) (sprite (name "largetux-jump-left") + (x-hotspot 9) + (y-hotspot 2) (images "shared/largetux-jump-left-0.png")) - (sprite (name "largetux-jump-right") + (x-hotspot 9) + (y-hotspot 2) (images "shared/largetux-jump-right-0.png")) + + (sprite (name "largetux-duck-left") + (x-hotspot 6) + (y-hotspot 2) + (images "shared/tux-duck-left.png")) + (sprite (name "largetux-duck-right") + (x-hotspot 6) + (y-hotspot 6) + (images "shared/tux-duck-right.png")) ) ;; EOF ;; diff --git a/src/level.cpp b/src/level.cpp index 970c7b0a2..b83bdb4c9 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -289,12 +289,15 @@ Level::load(const std::string& filename) reader.read_int("version", &version); reader.read_int("width", &width); reader.read_int("time", &time_left); + reader.read_int("bkgd_top_red", &bkgd_top.red); reader.read_int("bkgd_top_green", &bkgd_top.green); reader.read_int("bkgd_top_blue", &bkgd_top.blue); + reader.read_int("bkgd_bottom_red", &bkgd_bottom.red); reader.read_int("bkgd_bottom_green", &bkgd_bottom.green); reader.read_int("bkgd_bottom_blue", &bkgd_bottom.blue); + reader.read_float("gravity", &gravity); reader.read_string("name", &name); reader.read_string("author", &author); @@ -597,19 +600,6 @@ Level::load_image(Surface** ptexture, string theme,const char * file, int use_a *ptexture = new Surface(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 (int new_width) @@ -617,9 +607,12 @@ Level::change_size (int new_width) if(new_width < 21) new_width = 21; - tilemap_change_size((unsigned int***)&ia_tiles, new_width, width); - tilemap_change_size((unsigned int***)&bg_tiles, new_width, width); - tilemap_change_size((unsigned int***)&fg_tiles, new_width, width); + for(int y = 0; y < 15; ++y) + { + ia_tiles[y].resize(new_width, 0); + bg_tiles[y].resize(new_width, 0); + fg_tiles[y].resize(new_width, 0); + } width = new_width; } diff --git a/src/player.cpp b/src/player.cpp index d45be289c..cc50bdd82 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -32,8 +32,8 @@ Sprite* bigtux_right; Sprite* bigtux_left; Sprite* bigtux_right_jump; Sprite* bigtux_left_jump; -Surface* ducktux_right; -Surface* ducktux_left; +Sprite* ducktux_right; +Sprite* ducktux_left; Surface* skidtux_right; Surface* skidtux_left; Surface* firetux_right[3]; @@ -517,14 +517,9 @@ Player::draw() /* Draw cape: */ if (dir == RIGHT) - { - cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); - } + cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); else - { - cape_left[global_frame_counter % 2]->draw( - base.x- scroll_x, base.y); - } + cape_left[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); } @@ -549,11 +544,9 @@ Player::draw() else // moving { if (dir == RIGHT) - tux_right[(global_frame_counter/2) % tux_right.size()]->draw( - base.x - scroll_x, base.y - 9); + tux_right[(global_frame_counter/2) % tux_right.size()]->draw(base.x - scroll_x, base.y - 9); else - tux_left[(global_frame_counter/2) % tux_left.size()]->draw( - base.x - scroll_x, base.y - 9); + tux_left[(global_frame_counter/2) % tux_left.size()]->draw(base.x - scroll_x, base.y - 9); } } } @@ -581,15 +574,9 @@ Player::draw() /* Draw cape (just not in ducked mode since that looks silly): */ if (dir == RIGHT) - { - bigcape_right[global_frame_counter % 2]->draw( - capex, capey); - } + bigcape_right[global_frame_counter % 2]->draw(capex, capey); else - { - bigcape_left[global_frame_counter % 2]->draw( - capex, capey); - } + bigcape_left[global_frame_counter % 2]->draw(capex, capey); } if (!got_coffee) @@ -601,36 +588,32 @@ Player::draw() if (physic.get_velocity_y() == 0) { if (dir == RIGHT) - bigtux_right->draw(base.x- scroll_x - 8, base.y); + bigtux_right->draw(base.x - scroll_x, base.y); else - bigtux_left->draw(base.x- scroll_x - 8, base.y); + bigtux_left->draw(base.x - scroll_x, base.y); } else { if (dir == RIGHT) - bigtux_right_jump->draw(base.x- scroll_x - 8, base.y); + bigtux_right_jump->draw(base.x - scroll_x, base.y); else - bigtux_left_jump->draw(base.x- scroll_x - 8, base.y); + bigtux_left_jump->draw(base.x - scroll_x, base.y); } } else { if (dir == RIGHT) - skidtux_right->draw(base.x- scroll_x - 8, base.y); + skidtux_right->draw(base.x - scroll_x - 8, base.y); else - skidtux_left->draw(base.x- scroll_x - 8, base.y); + skidtux_left->draw(base.x - scroll_x - 8, base.y); } } else { if (dir == RIGHT) - { - ducktux_right->draw( base.x- scroll_x - 8, base.y - 16); - } + ducktux_right->draw(base.x - scroll_x, base.y); else - { - ducktux_left->draw( base.x- scroll_x - 8, base.y - 16); - } + ducktux_left->draw(base.x - scroll_x, base.y); } } else @@ -643,54 +626,32 @@ Player::draw() if (!jumping || physic.get_velocity_y() > 0) { if (dir == RIGHT) - { - bigfiretux_right[frame_]->draw( - base.x- scroll_x - 8, base.y); - } + bigfiretux_right[frame_]->draw(base.x- scroll_x - 8, base.y); else - { - bigfiretux_left[frame_]->draw( - base.x- scroll_x - 8, base.y); - } + bigfiretux_left[frame_]->draw(base.x- scroll_x - 8, base.y); } else { if (dir == RIGHT) - { - bigfiretux_right_jump->draw( - base.x- scroll_x - 8, base.y); - } + bigfiretux_right_jump->draw(base.x- scroll_x - 8, base.y); else - { - bigfiretux_left_jump->draw( - base.x- scroll_x - 8, base.y); - } + bigfiretux_left_jump->draw(base.x- scroll_x - 8, base.y); } } else { if (dir == RIGHT) - { - skidfiretux_right->draw( - base.x- scroll_x - 8, base.y); - } + skidfiretux_right->draw(base.x- scroll_x - 8, base.y); else - { - skidfiretux_left->draw( - base.x- scroll_x - 8, base.y); - } + skidfiretux_left->draw(base.x- scroll_x - 8, base.y); } } else { if (dir == RIGHT) - { - duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16); - } + duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16); else - { - duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16); - } + duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16); } } } diff --git a/src/player.h b/src/player.h index c13442774..49e7ec1f7 100644 --- a/src/player.h +++ b/src/player.h @@ -73,8 +73,8 @@ extern Sprite* bigtux_right; extern Sprite* bigtux_left; extern Sprite* bigtux_right_jump; extern Sprite* bigtux_left_jump; -extern Surface* ducktux_right; -extern Surface* ducktux_left; +extern Sprite* ducktux_right; +extern Sprite* ducktux_left; extern Surface* skidtux_right; extern Surface* skidtux_left; extern Surface* firetux_right[3]; diff --git a/src/resources.cpp b/src/resources.cpp index 397b74b18..9581d3698 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -128,13 +128,8 @@ void loadshared() USE_ALPHA); - ducktux_right = new Surface(datadir + - "/images/shared/tux-duck-right.png", - USE_ALPHA); - - ducktux_left = new Surface(datadir + - "/images/shared/tux-duck-left.png", - USE_ALPHA); + ducktux_left = sprite_manager->load("largetux-duck-left"); + ducktux_right = sprite_manager->load("largetux-duck-right"); skidtux_right = new Surface(datadir + "/images/shared/skidtux-right.png",