From: Ricardo Cruz Date: Thu, 1 Jul 2004 13:39:26 +0000 (+0000) Subject: Changes: X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d7d4bfc600fe6455bdb1d9f249b48f67baef2596;p=supertux.git Changes: - testing for existing sector in badguy; - made flying object and trampoline's gfx accessible; - added sprite and badguys surface pointer return func. SVN-Revision: 1525 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index b9e9c25b7..28d151b60 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -206,6 +206,7 @@ BadGuy::init() timer.init(true); // if we're in a solid tile at start correct that now + if(Sector::current()) { if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(base)) { std::cout << "Warning: badguy started in wall: kind: " << badguykind_to_string(kind) @@ -214,7 +215,7 @@ BadGuy::init() --base.y; } - if(Sector::current() && Sector::current()->camera) { + if(Sector::current()->camera) { Vector scroll = Sector::current()->camera->get_translation(); if(start_position.x > scroll.x - X_OFFSCREEN_DISTANCE && @@ -223,7 +224,7 @@ BadGuy::init() start_position.y < scroll.y + screen->h + Y_OFFSCREEN_DISTANCE) { activate(LEFT); } - } else { + } } else { if(start_position.x > 0 && start_position.x <= screen->w && start_position.y > 0 && start_position.y <= screen->h) activate(LEFT); diff --git a/src/badguy.h b/src/badguy.h index 99dcc3f60..fa26832d9 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -139,6 +139,9 @@ public: /** initializes the badguy (when he appears on screen) */ void activate(Direction direction); // should only be used by BadGuy's objects + Surface* get_image() + { return sprite_left->get_frame(0); } + private: void init(); diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 674c89aa8..0841dac70 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -137,7 +137,6 @@ FloatingScore::draw(DrawingContext& context) /* Trampoline */ -#define TRAMPOLINE_FRAMES 4 Sprite *img_trampoline[TRAMPOLINE_FRAMES]; Trampoline::Trampoline(LispReader& reader) @@ -154,6 +153,19 @@ Trampoline::Trampoline(LispReader& reader) physic.reset(); } +Trampoline::Trampoline(float x, float y) +{ + base.x = x; + base.y = y; + base.width = 32; + base.height = 32; + power = 7.5; + + frame = 0; + mode = M_NORMAL; + physic.reset(); +} + void Trampoline::write(LispWriter& writer) { @@ -301,6 +313,14 @@ FlyingPlatform::FlyingPlatform(LispReader& reader) frame = 0; } +FlyingPlatform::FlyingPlatform(int x, int y) +{ +base.x = x; +base.y = y; +point = 0; +move = false; +} + void FlyingPlatform::write(LispWriter& writer) { diff --git a/src/gameobjs.h b/src/gameobjs.h index c19a72468..6061cbd8f 100644 --- a/src/gameobjs.h +++ b/src/gameobjs.h @@ -37,6 +37,8 @@ #define NO_BOUNCE 0 #define BOUNCE 1 +class Sprite; + struct TileId; class BouncyDistro : public GameObject @@ -101,10 +103,14 @@ private: Timer timer; }; +#define TRAMPOLINE_FRAMES 4 +extern Sprite *img_trampoline[TRAMPOLINE_FRAMES]; + class Trampoline : public MovingObject, public Serializable { public: Trampoline(LispReader& reader); + Trampoline(float x, float y); virtual void write(LispWriter& writer); virtual void action(float frame_ratio); @@ -121,10 +127,13 @@ public: unsigned int frame; }; +extern Sprite *img_flying_platform; + class FlyingPlatform : public MovingObject, public Serializable { public: FlyingPlatform(LispReader& reader); + FlyingPlatform(int x, int y); virtual void write(LispWriter& writer); virtual void action(float frame_ratio); diff --git a/src/menu.cpp b/src/menu.cpp index 2a2bce2da..720793614 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -553,7 +553,7 @@ Menu::draw_item(DrawingContext& context, { context.draw_text_center(gray_text, pitem.text, Vector(0, y_pos - int(blue_text->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; } @@ -564,16 +564,16 @@ Menu::draw_item(DrawingContext& context, int y = y_pos - 12 - effect_offset; /* Draw a horizontal line with a little 3d effect */ context.draw_filled_rect(Vector(x, y + 6), - Vector(menu_width, 4), Color(150,200,255,225), LAYER_FOREGROUND1); + Vector(menu_width, 4), Color(150,200,255,225), LAYER_GUI); context.draw_filled_rect(Vector(x, y + 6), - Vector(menu_width, 2), Color(255,255,255,255), LAYER_FOREGROUND1); + Vector(menu_width, 2), Color(255,255,255,255), LAYER_GUI); break; } case MN_LABEL: { context.draw_text_center(white_big_text, pitem.text, Vector(0, y_pos - int(white_big_text->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; } case MN_TEXTFIELD: @@ -588,11 +588,11 @@ Menu::draw_item(DrawingContext& context, context.draw_filled_rect( Vector(input_pos - 5, y_pos - 10), Vector(input_width + 10, 20), - Color(255,255,255,255), LAYER_FOREGROUND1-5); + Color(255,255,255,255), LAYER_GUI-5); context.draw_filled_rect( Vector(input_pos - 4, y_pos - 9), Vector(input_width + 8, 18), - Color(0,0,0,128), LAYER_FOREGROUND1-4); + Color(0,0,0,128), LAYER_GUI-4); if(pitem.kind == MN_CONTROLFIELD_KB) get_controlfield_key_into_input(&pitem); @@ -605,21 +605,21 @@ Menu::draw_item(DrawingContext& context, context.draw_text(gold_text, pitem.get_input_with_symbol(true), Vector(input_pos, y_pos - int(gold_text->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); else context.draw_text(gold_text, pitem.get_input_with_symbol(false), Vector(input_pos, y_pos - int(gold_text->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); } else context.draw_text(gold_text, pitem.input, Vector(input_pos, y_pos - int(gold_text->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); context.draw_text(text_font, pitem.text, Vector(text_pos, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; } case MN_STRINGSELECT: @@ -631,37 +631,37 @@ Menu::draw_item(DrawingContext& context, /* Draw arrows */ context.draw_surface(arrow_left, Vector(x_pos - list_pos + text_pos - 17, y_pos - 8), - LAYER_FOREGROUND1); + LAYER_GUI); context.draw_surface(arrow_right, Vector(x_pos - list_pos + text_pos - 1 + list_pos_2, y_pos - 8), - LAYER_FOREGROUND1); + LAYER_GUI); /* Draw input background */ context.draw_filled_rect( Vector(x_pos - list_pos + text_pos - 1, y_pos - 10), Vector(list_pos_2 + 2, 20), - Color(255,255,255,255), LAYER_FOREGROUND1 - 4); + Color(255,255,255,255), LAYER_GUI - 4); context.draw_filled_rect( Vector(x_pos - list_pos + text_pos, y_pos - 9), Vector(list_pos_2, 18), - Color(0,0,0,128), LAYER_FOREGROUND1 - 5); + Color(0,0,0,128), LAYER_GUI - 5); context.draw_text_center(text_font, string_list_active(pitem.list), Vector(text_pos, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); context.draw_text_center(text_font, pitem.text, Vector(list_pos_2/2, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; } case MN_BACK: { context.draw_text_center(text_font, pitem.text, Vector(0, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); context.draw_surface(back, Vector(x_pos + text_width/2 + 16, y_pos - 8), - LAYER_FOREGROUND1); + LAYER_GUI); break; } @@ -669,28 +669,28 @@ Menu::draw_item(DrawingContext& context, { context.draw_text_center(text_font, pitem.text, Vector(0, y_pos - (text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); if(pitem.toggled) context.draw_surface(checkbox_checked, Vector(x_pos + (text_width+16)/2, y_pos - 8), - LAYER_FOREGROUND1 + 1); + LAYER_GUI + 1); else context.draw_surface(checkbox, Vector(x_pos + (text_width+16)/2, y_pos - 8), - LAYER_FOREGROUND1 + 1); + LAYER_GUI + 1); break; } case MN_ACTION: context.draw_text_center(text_font, pitem.text, Vector(0, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; case MN_GOTO: context.draw_text_center(text_font, pitem.text, Vector(0, y_pos - int(text_font->get_height()/2)), - LAYER_FOREGROUND1); + LAYER_GUI); break; } } @@ -730,7 +730,7 @@ Menu::draw(DrawingContext& context) context.draw_filled_rect( Vector(pos_x - menu_width/2, pos_y - 24*item.size()/2 - 10), Vector(menu_width,menu_height + 20), - Color(150,180,200,125), LAYER_FOREGROUND1-10); + Color(150,180,200,125), LAYER_GUI-10); for(unsigned int i = 0; i < item.size(); ++i) { diff --git a/src/sprite.h b/src/sprite.h index 47ab31afa..12b1a4c6d 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -67,6 +67,10 @@ class Sprite std::string get_name() const { return name; } int get_width() const; int get_height() const; + + Surface* get_frame(unsigned int frame) + { if(frame < surfaces.size()) return surfaces[frame]; + else return surfaces[0]; } }; #endif /*SUPERTUX_SPRITE_H*/