cBall :: cBall( float x, float y, const cSprite *origin_object /* = NULL */, ball_effect btype /* = FIREBALL_DEFAULT */ ) : cMovingSprite( NULL, x, y ) { m_sprite_array = ARRAY_ACTIVE; m_type = TYPE_BALL; m_pos_z = 0.095f; m_spawned = 1; m_player_range = 2000; m_massive_type = MASS_MASSIVE; m_glim_mod = 1; m_glim_counter = 0.0f; m_fire_counter = 0.0f; m_life_left = 0; if( btype == FIREBALL_DEFAULT || btype == FIREBALL_EXPLOSION ) { Set_Image( pVideo->Get_Surface( "animation/fireball/1.png" ) ); m_ball_type = FIREBALL_DEFAULT; } else if( btype == ICEBALL_DEFAULT || btype == ICEBALL_EXPLOSION ) { Set_Image( pVideo->Get_Surface( "animation/iceball/1.png" ) ); m_ball_type = ICEBALL_DEFAULT; } else { printf( "Warning : Ball unknown type %d\n", btype ); cMovingSprite::Destroy(); return; } if( origin_object ) { m_origin_array = origin_object->m_sprite_array; m_origin_type = origin_object->m_type; if( m_origin_type == TYPE_PLAYER ) { if( m_ball_type == FIREBALL_DEFAULT || m_ball_type == ICEBALL_DEFAULT ) { pPlayer->shoot_counter = speedfactor_fps; } } } // if origin not set else { printf( "Warning : Ball origin not set\n" ); m_origin_array = ARRAY_UNDEFINED; m_origin_type = TYPE_UNDEFINED; } }
void cTimeDisplay::Update(void) { if (editor_enabled || Game_Mode == MODE_OVERWORLD || Game_Mode == MODE_MENU) { return; } m_milliseconds += pFramerate->m_elapsed_ticks; if (m_milliseconds == 0) { return; } const Uint32 seconds = m_milliseconds / 1000; if (seconds == m_last_update_seconds) { return; } m_last_update_seconds = seconds; const Uint32 minutes = seconds / 60; sprintf(m_text, "Time %02d:%02d", minutes, seconds - (minutes * 60)); Set_Image(pFont->Render_Text(pFont->m_font_normal, m_text, white), 0, 1); }
void cLiveDisplay::Set_Lives(int lives) { pPlayer->lives = lives; if (lives < 0) { return; } std::string text; if (Game_Mode != MODE_OVERWORLD) { text = int_to_string(pPlayer->lives) + "x"; } else { text = "Lives : " + int_to_string(pPlayer->lives); } Set_Image(pFont->Render_Text(pFont->m_font_normal, text, green), 0, 1); int w, h; if (TTF_SizeText(pFont->m_font_normal, text.c_str(), &w, &h) == 0) { Set_Pos_X((game_res_w * 0.94f) - w); } }
void cBackground::Load_From_Attributes(XmlAttributes& attributes) { Set_Type(static_cast<BackgroundType>(string_to_int(attributes["type"]))); if (m_type == BG_GR_HOR || m_type == BG_GR_VER) { int r, g, b; r = string_to_int(attributes["bg_color_1_red"]); g = string_to_int(attributes["bg_color_1_green"]); b = string_to_int(attributes["bg_color_1_blue"]); Set_Color_1(Color(static_cast<Uint8>(r), static_cast<Uint8>(g), static_cast<Uint8>(b))); r = string_to_int(attributes["bg_color_2_red"]); g = string_to_int(attributes["bg_color_2_green"]); b = string_to_int(attributes["bg_color_2_blue"]); Set_Color_2(Color(static_cast<Uint8>(r), static_cast<Uint8>(g), static_cast<Uint8>(b))); } else if (m_type == BG_IMG_BOTTOM || m_type == BG_IMG_TOP || m_type == BG_IMG_ALL) { Set_Start_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"])); Set_Pos_Z(string_to_float(attributes["posz"])); Set_Image(utf8_to_path(attributes["image"])); Set_Scroll_Speed(string_to_float(attributes["speedx"]), string_to_float(attributes["speedy"])); Set_Const_Velocity_X(string_to_float(attributes["const_velx"])); Set_Const_Velocity_Y(string_to_float(attributes["const_vely"])); } }
void cWaypoint::Init(void) { m_sprite_array = ARRAY_PASSIVE; m_type = TYPE_OW_WAYPOINT; m_massive_type = MASS_PASSIVE; m_pos_z = 0.08f; m_player_range = 0; waypoint_type = WAYPOINT_NORMAL; m_name = "Waypoint"; gcolor = Get_Random_Float(0, 100); glim = 1; access = 0; access_default = 0; direction_backward = DIR_UNDEFINED; direction_forward = DIR_UNDEFINED; Set_Image(pVideo->Get_Surface("world/waypoint/default_1.png")); arrow_blue_l = pVideo->Get_Surface("game/arrow/small/blue/left.png"); arrow_blue_r = pVideo->Get_Surface("game/arrow/small/blue/right.png"); arrow_blue_u = pVideo->Get_Surface("game/arrow/small/blue/up.png"); arrow_blue_d = pVideo->Get_Surface("game/arrow/small/blue/down.png"); arrow_white_l = pVideo->Get_Surface("game/arrow/small/white/left.png"); arrow_white_r = pVideo->Get_Surface("game/arrow/small/white/right.png"); arrow_white_u = pVideo->Get_Surface("game/arrow/small/white/up.png"); arrow_white_d = pVideo->Get_Surface("game/arrow/small/white/down.png"); }
void cPlayerPoints::Set_Points(long points) { pPlayer->points = points; char text[70]; sprintf(text, ("Points %08d"), static_cast<int>(pPlayer->points)); Set_Image(pFont->Render_Text(pFont->m_font_normal, text, white), 0, 1); }
cLiveDisplay::cLiveDisplay(float x, float y) : cStatusText(x, y) { m_sprite_array = ARRAY_HUD; m_type = TYPE_LIFEDISPLAY; m_name = "HUD Lives"; Set_Lives(pPlayer->lives); Set_Image(NULL); }
void cGoldDisplay::Set_Gold(int gold) { if (gold >= 100) { gold -= 100; pAudio->Play_Sound("item/live_up_2.ogg", RID_1UP_MUSHROOM); pHud_Lives->Add_Lives(1); pHud_Points->Add_Points(0, pPlayer->m_pos_x + pPlayer->m_image->m_w / 3, pPlayer->m_pos_y + 5, "1UP", lightred); } pPlayer->goldpieces = gold; std::string text = int_to_string(pPlayer->goldpieces); Color color = Color(static_cast<Uint8>(255), 255, 255 - (gold * 2)); Set_Image(pFont->Render_Text(pFont->m_font_normal, text, color), 0, 1); }
cItemBox::cItemBox(float x, float y) : cStatusText(x, y) { m_sprite_array = ARRAY_HUD; m_type = TYPE_ITEMBOXDISPLAY; m_name = "HUD Itembox"; Set_Image(pVideo->Get_Surface("game/itembox.png")); Set_Shadow_Pos(0); m_box_color = white; m_item_counter = 0; m_item_counter_mod = 0; m_item_id = TYPE_UNDEFINED; m_item = new cMovingSprite(); m_item->Set_Ignore_Camera(1); m_item->m_player_range = 0; m_item->Set_Massive_Type(MASS_MASSIVE); m_item->m_pos_z = 0.1299f; }