From fcf9a94afe527884758b66ffc314dbb5b8b20c09 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 25 Apr 2004 16:46:55 +0000 Subject: [PATCH] - rewrote tux drawing code, added firetux SVN-Revision: 710 --- data/supertux.strf | 162 ++++++++++++++++++++++++++++++++------------ src/player.cpp | 192 +++++++++++++++-------------------------------------- src/player.h | 12 +--- src/resources.cpp | 62 ++++------------- src/setup.cpp | 2 - 5 files changed, 188 insertions(+), 242 deletions(-) diff --git a/data/supertux.strf b/data/supertux.strf index 8c3a633ca..41181452f 100644 --- a/data/supertux.strf +++ b/data/supertux.strf @@ -30,14 +30,14 @@ (sprite (name "smalltux-stand-left") (fps 15.0) (x-hotspot 0) - (y-hotspot 0) + (y-hotspot 9) (images "shared/smalltux-left-6.png" )) (sprite (name "smalltux-stand-right") (fps 15.0) (x-hotspot 0) - (y-hotspot 0) + (y-hotspot 9) (images "shared/smalltux-right-6.png")) ;; Small Tux Jump @@ -89,6 +89,14 @@ (y-hotspot 9) (images "shared/smalltux-grab-right-0.png")) + (sprite (name "smalltux-star") + (x-hotspot 5) + (y-hotspot 15) + (images "shared/smalltux-star-0.png" + "shared/smalltux-star-1.png" + "shared/smalltux-star-2.png" + )) + ;; Large Tux Walk (sprite (name "largetux-walk-left") (x-hotspot 6) @@ -111,12 +119,12 @@ "shared/largetux-walk-right-5.png")) (sprite (name "largetux-skid-right") - (x-hotspot 2) + (x-hotspot 8) (y-hotspot 3) (images "shared/largetux-skid-right.png")) (sprite (name "largetux-skid-left") - (x-hotspot 2) + (x-hotspot 8) (y-hotspot 3) (images "shared/largetux-skid-left.png")) @@ -148,6 +156,115 @@ (y-hotspot 6) (images "shared/tux-duck-right.png")) + + (sprite (name "largetux-kick-left") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/largetux-kick-left-0.png")) + + (sprite (name "largetux-kick-right") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/largetux-kick-right-0.png")) + + (sprite (name "largetux-grab-left") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/largetux-grab-left-0.png")) + + (sprite (name "largetux-grab-right") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/largetux-grab-right-0.png")) + + (sprite (name "largetux-star") + (x-hotspot 8) + (y-hotspot 8) + (images "shared/largetux-star-0.png" + "shared/largetux-star-1.png" + "shared/largetux-star-2.png" + )) + + ;; Firetux + (sprite (name "firetux-walk-left") + (x-hotspot 6) + (y-hotspot 2) + (images "shared/firetux-walk-left-0.png" + "shared/firetux-walk-left-1.png" + "shared/firetux-walk-left-2.png" + "shared/firetux-walk-left-3.png" + "shared/firetux-walk-left-4.png" + "shared/firetux-walk-left-5.png")) + + (sprite (name "firetux-walk-right") + (x-hotspot 6) + (y-hotspot 2) + (images "shared/firetux-walk-right-0.png" + "shared/firetux-walk-right-1.png" + "shared/firetux-walk-right-2.png" + "shared/firetux-walk-right-3.png" + "shared/firetux-walk-right-4.png" + "shared/firetux-walk-right-5.png")) + + (sprite (name "firetux-skid-right") + (x-hotspot 8) + (y-hotspot 3) + (images "shared/firetux-skid-right.png")) + + (sprite (name "firetux-skid-left") + (x-hotspot 8) + (y-hotspot 3) + (images "shared/firetux-skid-left.png")) + + (sprite (name "firetux-stand-left") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-stand-left.png")) + + (sprite (name "firetux-stand-right") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-stand-right.png")) + + (sprite (name "firetux-jump-left") + (x-hotspot 9) + (y-hotspot 2) + (images "shared/firetux-jump-left-0.png")) + (sprite (name "firetux-jump-right") + (x-hotspot 9) + (y-hotspot 2) + (images "shared/firetux-jump-right-0.png")) + + (sprite (name "firetux-duck-left") + (x-hotspot 6) + (y-hotspot 2) + (images "shared/tux-duck-left.png")) + (sprite (name "firetux-duck-right") + (x-hotspot 6) + (y-hotspot 6) + (images "shared/tux-duck-right.png")) + + + (sprite (name "firetux-kick-left") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-kick-left-0.png")) + + (sprite (name "firetux-kick-right") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-kick-right-0.png")) + + (sprite (name "firetux-grab-left") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-grab-left-0.png")) + + (sprite (name "firetux-grab-right") + (x-hotspot 5) + (y-hotspot 1) + (images "shared/firetux-grab-right-0.png")) + ;; Laptop (sprite (name "laptop-left") (x-hotspot 2) @@ -354,43 +471,6 @@ "shared/iceflower-3.png" "shared/iceflower-2.png" "shared/iceflower-1.png")) - - (sprite (name "largetux-kick-left") - (x-hotspot 5) - (y-hotspot 1) - (images "shared/largetux-kick-left-0.png")) - - (sprite (name "largetux-kick-right") - (x-hotspot 5) - (y-hotspot 1) - (images "shared/largetux-kick-right-0.png")) - - (sprite (name "largetux-grab-left") - (x-hotspot 5) - (y-hotspot 1) - (images "shared/largetux-grab-left-0.png")) - - (sprite (name "largetux-grab-right") - (x-hotspot 5) - (y-hotspot 1) - (images "shared/largetux-grab-right-0.png")) - - (sprite (name "largetux-star") - (x-hotspot 8) - (y-hotspot 8) - (images "shared/largetux-star-0.png" - "shared/largetux-star-1.png" - "shared/largetux-star-2.png" - )) - - (sprite (name "smalltux-star") - (x-hotspot 5) - (y-hotspot 15) - (images "shared/smalltux-star-0.png" - "shared/smalltux-star-1.png" - "shared/smalltux-star-2.png" - )) - ) ;; EOF ;; diff --git a/src/player.cpp b/src/player.cpp index 479c5ca40..8e50c7e4f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -36,17 +36,7 @@ Sprite* largetux_star; PlayerSprite smalltux; PlayerSprite largetux; - -Surface* firetux_right[3]; -Surface* firetux_left[3]; -Surface* bigfiretux_right[3]; -Surface* bigfiretux_left[3]; -Surface* bigfiretux_right_jump; -Surface* bigfiretux_left_jump; -Surface* duckfiretux_right; -Surface* duckfiretux_left; -Surface* skidfiretux_right; -Surface* skidfiretux_left; +PlayerSprite firetux; PlayerKeymap keymap; @@ -506,158 +496,80 @@ Player::draw() } else { + PlayerSprite* sprite; + if (size == SMALL) + sprite = &smalltux; + else if (got_coffee) + sprite = &firetux; + else + sprite = &largetux; + + if (skidding_timer.started()) { - if (!skidding_timer.started()) - { - if (physic.get_velocity_y() != 0) - { - if (dir == RIGHT) - smalltux.jump_right->draw(base.x - scroll_x, base.y); - else - smalltux.jump_left->draw(base.x - scroll_x, base.y); - } - else - { - if (fabsf(physic.get_velocity_x()) < 1.0f) // standing - { - if (dir == RIGHT) - smalltux.stand_right->draw( base.x - scroll_x, base.y - 9); - else - smalltux.stand_left->draw( base.x - scroll_x, base.y - 9); - } - else // moving - { - if (dir == RIGHT) - smalltux.walk_right->draw(base.x - scroll_x, base.y); - else - smalltux.walk_left->draw(base.x - scroll_x, base.y); - } - } - } + if (dir == RIGHT) + sprite->skid_right->draw(base.x - scroll_x, base.y); else + sprite->skid_left->draw(base.x - scroll_x, base.y); + } + else + { + if (duck) { if (dir == RIGHT) - smalltux.skid_right->draw(base.x - scroll_x, base.y); - else - smalltux.skid_left->draw(base.x - scroll_x, base.y); - } - - if (holding_something && physic.get_velocity_y() == 0) + sprite->duck_right->draw(base.x - scroll_x, base.y); + else + sprite->duck_left->draw(base.x - scroll_x, base.y); + } + else if (physic.get_velocity_y() != 0) { if (dir == RIGHT) - smalltux.grab_right->draw(base.x - scroll_x, base.y); - else - smalltux.grab_left->draw(base.x - scroll_x, base.y); - } - - if (invincible_timer.started()) - smalltux_star->draw(base.x - scroll_x, base.y); - } - else // Large Tux - { - if (!got_coffee) - { - if (!duck) - { - if (!skidding_timer.started()) - { - if (physic.get_velocity_y() == 0) - { - if (fabsf(physic.get_velocity_x()) < 1.0f) // standing - { - if (dir == RIGHT) - largetux.stand_right->draw(base.x - scroll_x, base.y); - else - largetux.stand_left->draw(base.x - scroll_x, base.y); - } - else // walking - { - if (dir == RIGHT) - largetux.walk_right->draw(base.x - scroll_x, base.y); - else - largetux.walk_left->draw(base.x - scroll_x, base.y); - } - } - else - { - if (dir == RIGHT) - largetux.jump_right->draw(base.x - scroll_x, base.y); - else - largetux.jump_left->draw(base.x - scroll_x, base.y); - } - } - else - { - if (dir == RIGHT) - largetux.skid_right->draw(base.x - scroll_x - 8, base.y); - else - largetux.skid_left->draw(base.x - scroll_x - 8, base.y); - } - } + sprite->jump_right->draw(base.x - scroll_x, base.y); else - { - if (dir == RIGHT) - largetux.duck_right->draw(base.x - scroll_x, base.y); - else - largetux.duck_left->draw(base.x - scroll_x, base.y); - } + sprite->jump_left->draw(base.x - scroll_x, base.y); } else { - /* Tux has coffee! */ - if (!duck) + if (fabsf(physic.get_velocity_x()) < 1.0f) // standing { - if (!skidding_timer.started()) - { - if (!jumping || physic.get_velocity_y() > 0) - { - if (dir == RIGHT) - bigfiretux_right[frame_]->draw(base.x- scroll_x - 8, base.y); - else - 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); - else - bigfiretux_left_jump->draw(base.x- scroll_x - 8, base.y); - } - } + if (dir == RIGHT) + sprite->stand_right->draw( base.x - scroll_x, base.y); else - { - if (dir == RIGHT) - skidfiretux_right->draw(base.x- scroll_x - 8, base.y); - else - skidfiretux_left->draw(base.x- scroll_x - 8, base.y); - } + sprite->stand_left->draw( base.x - scroll_x, base.y); } - else + else // moving { if (dir == RIGHT) - duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16); + sprite->walk_right->draw(base.x - scroll_x, base.y); else - duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16); + sprite->walk_left->draw(base.x - scroll_x, base.y); } } + } + + // Draw arm overlay graphics when Tux is holding something + if (holding_something && physic.get_velocity_y() == 0) + { + if (dir == RIGHT) + sprite->grab_right->draw(base.x - scroll_x, base.y); + else + sprite->grab_left->draw(base.x - scroll_x, base.y); + } - if (holding_something && !duck && physic.get_velocity_y() == 0) - { - if (dir == RIGHT) - largetux.grab_right->draw(base.x - scroll_x, base.y); - else - largetux.grab_left->draw(base.x - scroll_x, base.y); - } - - if (invincible_timer.started()) + // Draw blinking star overlay + if (invincible_timer.started()) + { + if (size == SMALL || duck) + smalltux_star->draw(base.x - scroll_x, base.y); + else largetux_star->draw(base.x - scroll_x, base.y); } - } - } - + } + } + if (debug_mode) - fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150); + fillrect(base.x - scroll_x, base.y, + base.width, base.height, 75,75,75, 150); } void diff --git a/src/player.h b/src/player.h index 07e4fc9aa..4271c4ffd 100644 --- a/src/player.h +++ b/src/player.h @@ -100,17 +100,7 @@ struct PlayerSprite extern PlayerSprite smalltux; extern PlayerSprite largetux; - -extern Surface* firetux_right[3]; -extern Surface* firetux_left[3]; -extern Surface* bigfiretux_right[3]; -extern Surface* bigfiretux_left[3]; -extern Surface* bigfiretux_right_jump; -extern Surface* bigfiretux_left_jump; -extern Surface* duckfiretux_right; -extern Surface* duckfiretux_left; -extern Surface* skidfiretux_right; -extern Surface* skidfiretux_left; +extern PlayerSprite firetux; class Player { diff --git a/src/resources.cpp b/src/resources.cpp index 103568ca4..64370ed28 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -83,56 +83,22 @@ void loadshared() largetux.duck_left = sprite_manager->load("largetux-duck-left"); largetux.duck_right = sprite_manager->load("largetux-duck-right"); - duckfiretux_right = new Surface(datadir + - "/images/shared/duckfiretux-right.png", - USE_ALPHA); - - duckfiretux_left = new Surface(datadir + - "/images/shared/duckfiretux-left.png", - USE_ALPHA); - - firetux_right[0] = new Surface(datadir + "/images/shared/firetux-right-0.png", USE_ALPHA); - firetux_right[1] = new Surface(datadir + "/images/shared/firetux-right-1.png", USE_ALPHA); - firetux_right[2] = new Surface(datadir + "/images/shared/firetux-right-2.png", USE_ALPHA); - - firetux_left[0] = new Surface(datadir + "/images/shared/firetux-left-0.png", USE_ALPHA); - firetux_left[1] = new Surface(datadir + "/images/shared/firetux-left-1.png", USE_ALPHA); - firetux_left[2] = new Surface(datadir + "/images/shared/firetux-left-2.png", USE_ALPHA); - - bigfiretux_right[0] = new Surface(datadir + "/images/shared/bigfiretux-right-0.png", - USE_ALPHA); - - bigfiretux_right[1] = new Surface(datadir + "/images/shared/bigfiretux-right-1.png", - USE_ALPHA); - - bigfiretux_right[2] = new Surface(datadir + "/images/shared/bigfiretux-right-2.png", - USE_ALPHA); - - bigfiretux_right_jump = new Surface(datadir + "/images/shared/bigfiretux-right-jump.png", USE_ALPHA); - - bigfiretux_left[0] = new Surface(datadir + "/images/shared/bigfiretux-left-0.png", - USE_ALPHA); - - bigfiretux_left[1] = new Surface(datadir + "/images/shared/bigfiretux-left-1.png", - USE_ALPHA); - - bigfiretux_left[2] = new Surface(datadir + "/images/shared/bigfiretux-left-2.png", - USE_ALPHA); - - bigfiretux_left_jump = new Surface(datadir + "/images/shared/bigfiretux-left-jump.png", USE_ALPHA); - - skidfiretux_right = new Surface(datadir + - "/images/shared/skidfiretux-right.png", - USE_ALPHA); - - skidfiretux_left = new Surface(datadir + - "/images/shared/skidfiretux-left.png", - USE_ALPHA); - + firetux.stand_left = sprite_manager->load("firetux-stand-left"); + firetux.stand_right = sprite_manager->load("firetux-stand-right"); + firetux.walk_left = sprite_manager->load("firetux-walk-left"); + firetux.walk_right = sprite_manager->load("firetux-walk-right"); + firetux.jump_left = sprite_manager->load("firetux-jump-left"); + firetux.jump_right = sprite_manager->load("firetux-jump-right"); + firetux.kick_left = sprite_manager->load("firetux-kick-left"); + firetux.kick_right = sprite_manager->load("firetux-kick-right"); + firetux.skid_right = sprite_manager->load("firetux-skid-right"); + firetux.skid_left = sprite_manager->load("firetux-skid-left"); + firetux.grab_left = sprite_manager->load("firetux-grab-left"); + firetux.grab_right = sprite_manager->load("firetux-grab-right"); + firetux.duck_left = sprite_manager->load("firetux-duck-left"); + firetux.duck_right = sprite_manager->load("firetux-duck-right"); /* Water: */ - - img_water = new Surface(datadir + "/images/shared/water.png", IGNORE_ALPHA); img_waves[0] = new Surface(datadir + "/images/shared/waves-0.png", diff --git a/src/setup.cpp b/src/setup.cpp index f22631b3b..0580ac601 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -496,10 +496,8 @@ bool process_load_game_menu() if (access(slotfile, F_OK) != 0) { - std::cout << "Draw intro" << std::endl; draw_intro(); } - std::cout << "XXXDraw intro" << std::endl; WorldMapNS::WorldMap worldmap; -- 2.11.0