Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.26 KB | None | 0 0
  1.     void Starflash2::update_points(int selected_star) {
  2.         page::ColorComponent *color_comp_selected =
  3.                 dynamic_cast<page::ColorComponent*>(page::EntitySystem::instance()->get_component(selected_star, page::ComponentFamily::kCFColorComponent));
  4.         page::RenderComponent *render_comp_selected =
  5.                 dynamic_cast<page::RenderComponent*>(page::EntitySystem::instance()->get_component(selected_star, page::ComponentFamily::kCFRenderable));
  6.  
  7.         page::ColorComponent *color_comp_active =
  8.                 dynamic_cast<page::ColorComponent*>(page::EntitySystem::instance()->get_component(active_star_, page::ComponentFamily::kCFColorComponent));
  9.         page::RenderComponent *render_comp_active =
  10.                 dynamic_cast<page::RenderComponent*>(page::EntitySystem::instance()->get_component(active_star_, page::ComponentFamily::kCFRenderable));
  11.  
  12.         // Star touched is the currently active star.
  13.         if(selected_star == active_star_) {
  14.             if(point_modifier_ < 1) {
  15.                 point_modifier_ = 1;
  16.             }
  17.  
  18.             int speed_mod = (1/(float)points_)*100;
  19.             page::Log::debug("Speedmod: %f", speed_mod);
  20.             if (speed_mod < delay_) {
  21.                 delay_ = speed_mod;
  22.                 if (delay_ < 0.1f) {
  23.                     delay_ = 0.1f;
  24.                 }
  25.                 /*
  26.                 // TODO: Crazy background color effect
  27.                 ccColor3B bgColor = background.color;
  28.                 bgColor.r = 255.0f * (1.0f-delay);
  29.                 bgColor.g = 255.0f * (delay);
  30.                 bgColor.b = 255.0f * (delay);
  31.                 [background stopAllActions];
  32.                 [background runAction: [TintTo actionWithDuration:.2f red:bgColor.r green:bgColor.g blue:bgColor.g]];
  33.                 */
  34.             }
  35.  
  36.         } else if((color_comp_selected->color == color_comp_active->color) &&
  37.                   (render_comp_selected->texture_->id == render_comp_active->texture_->id)) {
  38.             points_ += 1;
  39.             point_modifier_ = point_modifier_ < 0? 1: point_modifier_ + 1;
  40.         } else {
  41.             points -= point_modifier_*point_modifier_;
  42.             point_modifier_ -= 1;
  43.             /*
  44.             // TODO: Hard mode
  45.             if ([@"hard" isEqualToString:[settings.settings objectForKey:@"difficulty"]]) {
  46.                 [self updatePointLabel];
  47.                 [self gameOver];
  48.             }
  49.             */
  50.         }
  51.  
  52.         /*
  53.          // TODO: Update Labels
  54.         [self updateMultiplierLabel];
  55.         [self updatePointLabel];
  56.          */
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement