void
Bomb::draw(SceneContext& sc)
{
  if (state == EXPLODE)
  {
    sc.color().draw(explo, pos);
    sc.light().draw(explolight, pos, 0);

    explolight.set_alpha(0.5);
    explolight.set_scale(0.5);

    sc.highlight().draw(explolight, pos, 0);

    explolight.set_alpha(1.0);
    explolight.set_scale(1.0);
  }
  else
  {
    sc.color().draw(sprite, pos);
    if (sprite.is_finished()) {
      sc.light().draw(light, pos, 0);
      sc.highlight().draw(highlight, pos, 0);
    }
  }
}
void
SnowParticleHolder::draw (SceneContext& gc)
{
  for (std::vector<SnowParticle>::iterator it=particles.begin(); it != particles.end(); ++it)
  {
    if (!it->alive)
      continue;

    switch (it->type)
    {
      case Snow1:
        gc.color().draw(snow1, it->pos);
        break;
      case Snow2:
        gc.color().draw(snow2, it->pos);
        break;
      case Snow3:
        gc.color().draw(snow3, it->pos);
        break;
      case Snow4:
        gc.color().draw(snow4, it->pos);
        break;
      case Snow5:
        gc.color().draw(snow5, it->pos);
        break;
      default:
        assert(!"Invalid Snow-Type");
    }
  }
}
void
CaptureRectangle::draw(SceneContext& sc)
{
  if (pingu && pingu->catchable())
  {
    // Draw the capture rectangle
    if (session && pingu->change_allowed(session->get_action_name()))
    {
      sc.color().draw(good, pingu->get_center_pos() + Vector3f(0, 0, 1000));
    }
    else
    {
      sc.color().draw(bad, pingu->get_center_pos() + Vector3f(0, 0, 1000));
    }
      
    // Paint the direction arrow
    if (pingu->direction.is_left())
    {
      sc.color().draw(arrow_left, pingu->get_center_pos() + Vector3f(0, 2, 1000));
    }
    else
    {
      sc.color().draw(arrow_right, pingu->get_center_pos() + Vector3f(0, 2, 1000));
    }

    sc.color().print_center(font, 
                            Vector2i(static_cast<int>(pingu->get_center_pos().x),
                                     static_cast<int>(pingu->get_center_pos().y - 46)),
                            action_str,
                            1000);
  }
}
void
WoodThing::draw (SceneContext& gc)
{
	gc.color().draw(surface2, pos);
	// Only draw the animation if a pingu is coming out.
	if (last_release > 0)
		gc.color().draw(surface, pos);
}
Exemple #5
0
void
Walker::draw (SceneContext& gc)
{
  gc.color().draw(walker[pingu->direction], pingu->get_pos());

  if (pingu->get_fall_action() && pingu->get_fall_action()->get_type() == ActionName::FLOATER)
  {
    gc.color().draw(floaterlayer[pingu->direction], pingu->get_pos());
  }
}
Exemple #6
0
void
Guillotine::draw (SceneContext& gc)
{
  if (killing) {
    if (direction.is_left())
      gc.color().draw (sprite_kill_left, pos);
    else
      gc.color().draw (sprite_kill_right, pos);
  } else {
    gc.color().draw (sprite_idle, pos);
  }
}
void
TileMap::draw (SceneContext& sc)
{
    Rect clip_rect = Rect(View::current()->get_clip_rect());

    Rect rect(std::max(0, clip_rect.left/TILE_SIZE),
              std::max(0, clip_rect.top/TILE_SIZE),
              std::min(field.get_width(),  clip_rect.right/TILE_SIZE + 1),
              std::min(field.get_height(), clip_rect.bottom/TILE_SIZE + 1));

    std::vector<VertexArrayDrawingRequest*> requests;
    for (int y = rect.top;   y < rect.bottom; ++y)
        for (int x = rect.left; x < rect.right; ++x)
        {
            Tile* tile = field(x, y);

            if (!(tile == 0 || tile->packer < 0))
            {
                int packer = tile->packer;

                if(packer >= int(requests.size()))
                    requests.resize(packer+1);

                VertexArrayDrawingRequest*& request = requests[packer];
                if (!request)
                {
                    request = new VertexArrayDrawingRequest(Vector(0, 0), z_pos,
                                                            sc.color().get_modelview());
                    request->set_mode(GL_QUADS);
                    request->set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                    request->set_texture(tile->texture);
                }

                request->texcoord(tile->uv.left, tile->uv.top);
                request->vertex(x * TILE_SIZE, y * TILE_SIZE);

                request->texcoord(tile->uv.right, tile->uv.top);
                request->vertex(x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE);

                request->texcoord(tile->uv.right, tile->uv.bottom);
                request->vertex(x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE + TILE_SIZE);

                request->texcoord(tile->uv.left, tile->uv.bottom);
                request->vertex(x * TILE_SIZE, y * TILE_SIZE + TILE_SIZE);
            }
        }

    for(std::vector<VertexArrayDrawingRequest*>::iterator i = requests.begin(); i != requests.end(); ++i)
    {
        if (*i)
            sc.color().draw(*i);
    }
}
Exemple #8
0
void
ConveyorBelt::draw (SceneContext& gc)
{
  gc.color().draw(left_sur, pos);
  for (int i=0; i < width; ++i)
    gc.color().draw(middle_sur,
                    Vector3f(static_cast<float>(pos.x + static_cast<float>(left_sur.get_width() + i * middle_sur.get_width())),
                             static_cast<float>(pos.y)));

  gc.color().draw(right_sur,
                  Vector3f(static_cast<float>(pos.x + static_cast<float>(left_sur.get_width() + width * middle_sur.get_width())),
                           static_cast<float>(pos.y)));
}
void
SmokeParticleHolder::draw (SceneContext& gc)
{
  for (std::vector<SmokeParticle>::iterator it=particles.begin(); it != particles.end(); ++it)
  {
    if (!it->livetime)
      continue;

    if (!it->use_surf2)
      gc.color().draw(surf1, it->pos);
    else
      gc.color().draw(surf2, it->pos);
  }
}
void
SurfaceBackground::draw (SceneContext& gc)
{
  if (!bg_surface)
    return;

  if (fast_mode)
    {
      Display::clear();
    }
  else
    {
      if (render_preview)
        {
#if 0 // FIXME:
          for(int y = 0; y < gc.get_height();  y += bg_surface.get_height())
            for(int x = 0; x < gc.get_width(); x += bg_surface.get_width())
              gc.color().draw(bg_surface, Vector3f(x, y));
#endif
        }
      else
        {
          Vector3f offset = gc.color().world_to_screen(Vector3f(0,0));

          int start_x = static_cast<int>((offset.x * para_x) + scroll_ox);
          int start_y = static_cast<int>((offset.y * para_y) + scroll_oy);

          if (start_x > 0)
            start_x = (start_x % bg_surface.get_width()) - bg_surface.get_width();

          if (start_y > 0)
            start_y = (start_y % bg_surface.get_height()) - bg_surface.get_height();

          for(int y = start_y;
              y < world->get_height();
              y += bg_surface.get_height())
            {
              for(int x = start_x;
                  x < world->get_width();
                  x += bg_surface.get_width())
                {
                  gc.color().draw(bg_surface, Vector3f(x - offset.x, 
                                                       y - offset.y, pos.z));
                }
            }
        }
    }
}
Exemple #11
0
void
Spike::draw (SceneContext& gc)
{
  if (killing) {
    gc.color().draw (surface, pos);
  } else {
    // do nothing
  }
}
Exemple #12
0
void
IceBlock::draw (SceneContext& gc)
{
  if (is_finished)
    return;

  gc.color().draw(block_sur,
                  pos);
  //, static_cast<int>((1.0 - thickness) * (block_sur.get_frame_count() - 1)));
}
Exemple #13
0
void
Liquid::draw (SceneContext& gc)
{
  for(int x = static_cast<int>(pos.x);
      x < pos.x + width;
      x += sur.get_width())
    {
      gc.color().draw(sur, Vector3f((float)x, pos.y));
    }
}
void
PinguParticleHolder::draw (SceneContext& gc)
{
  for (std::vector<PinguParticle>::iterator it=particles.begin(); it != particles.end(); ++it)
    {
      // skip dead particles
      if (!it->livetime)
        continue;

      gc.color().draw(surface, it->pos);
    }
}
Exemple #15
0
void
RainGenerator::draw (SceneContext& gc)
{
  if (do_thunder)
  {
    if (thunder_count < 0.0f) {
      do_thunder = false;
      thunder_count = 0.0f;
      waiter_count = 1.0f;
    }

    gc.color().fill_screen(Color(255, 255, 255, static_cast<uint8_t>(thunder_count*255)));
  }
}
Exemple #16
0
// Draws the map with a offset, needed for scrolling
void
GroundMap::draw(SceneContext& gc)
{
  const Rect& display = gc.color().get_world_clip_rect();

  if (globals::draw_collision_map)
    draw_colmap(gc);

  // Trying to calc which parts of the tilemap needs to be drawn
  int start_x = Math::max(0, display.left / globals::tile_size);
  int start_y = Math::max(0, display.top  / globals::tile_size);
  int tilemap_width  = display.get_width()  / globals::tile_size + 1;
  int tilemap_height = display.get_height() / globals::tile_size + 1;

  // drawing the stuff
  for (int x = start_x; x <= (start_x + tilemap_width) && x < tile_width; ++x)
    for (int y = start_y; y <= start_y + tilemap_height && y < tile_height; ++y)
    {
      if (get_tile(x, y)->get_sprite())
      {
        gc.color().draw(get_tile(x, y)->get_sprite(),
                        Vector2i(x * globals::tile_size, y * globals::tile_size));
      }
      else
      {
        if (false)
        {
          gc.color().draw_fillrect(Rect(x * globals::tile_size,
                                        y * globals::tile_size,
                                        x * globals::tile_size + globals::tile_size,
                                        y * globals::tile_size + globals::tile_size),
                                   Color(255, 0, 0, 75));
        }
      }
    }
}
Exemple #17
0
// Draws the pingu on the screen with the given offset
void
Pingu::draw(SceneContext& gc)
{
  char str[16];

  action->draw(gc);

  if (action_time != -1)
  {
    // FIXME: some people preffer a 5-0 or a 9-0 countdown, not sure
    // FIXME: about that got used to the 50-0 countdown [counting is
    // FIXME: in ticks, should probally be in seconds]
    snprintf(str, 16, "%d", action_time/3);

    gc.color().print_center(Fonts::chalk_normal, Vector2i(static_cast<int>(pos_x), static_cast<int>(pos_y) - 48), str);
  }
}
void
Hedgehog::draw(SceneContext& gc)
{
  Sprite* s;

  if (state == DYING)
    s = &die_sprite;
  else
    s = &sprite;

  if (direction_left)
    s->set_vflip(true);
  else
    s->set_vflip(false);

  gc.color().draw(*s, pos, 2);
  //s->draw(int(pos.x), int(pos.y));
  gc.light().draw(light, pos, 0);
  gc.highlight().draw(highlight, pos, 0);
}
void
Player::draw (SceneContext& sc)
{
  //light.set_blend_func(GL_SRC_ALPHA, GL_ONE);
  //light.set_scale(4.0f);

  flashlight.set_blend_func(GL_SRC_ALPHA, GL_ONE);
  flashlight.set_scale(2.0f);

  flashlighthighlight.set_blend_func(GL_SRC_ALPHA, GL_ONE);
  flashlighthighlight.set_scale(2.0f);

  if (1)
    { // draw the 'stand-on' tile
      sc.highlight().fill_rect(Rect(Point(int(pos.x)/32 * 32, (int(pos.y)/32 + 1) * 32),
                                    Size(32, 32)),
                               Color(1.0f, 0.0f, 0.0f, 0.5f), 10000.0f);
    }

  //sc.highlight().draw(flashlighthighlight, pos - Vector(40, 80), 100.0f);
  //sc.light().draw(flashlight, pos - Vector(40, 80), 100.0f);
  sprite.draw(sc.color(), pos, z_pos);

  Entity* obj = find_useable_entity();
  if (obj)
    {
      std::string use_str = "[" + obj->get_use_verb() + "]";
      sc.highlight().draw(use_str, obj->get_pos().x, obj->get_pos().y - 150, 1000);
    }
  
  // Draw weapon at the 'Weapon' attachment point
  Sprite3D::PointID id = sprite.get_attachment_point_id("Weapon");
  sc.push_modelview();
  sc.translate(pos.x, pos.y);
  sc.mult_modelview(sprite.get_attachment_point_matrix(id));
  weapon->draw(sc);
  sc.pop_modelview();
}
void
BasicCompositorImpl::render(SceneContext& sc, SceneGraph* sg, const GraphicContextState& gc_state)
{
  // Resize Lightmap, only needed in the editor, FIXME: move this into a 'set_size()' call
  if (m_lightmap->get_width()  != m_window.width /LIGHTMAP_DIV ||
      m_lightmap->get_height() != m_window.height/LIGHTMAP_DIV)
  {
    m_lightmap = Surface::create(m_window.width / LIGHTMAP_DIV, m_window.height / LIGHTMAP_DIV);
  }

  if (sc.get_render_mask() & SceneContext::LIGHTMAPSCREEN)
  {
    // Render the lightmap to the framebuffers->lightmap
    glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glScalef(1.0f / LIGHTMAP_DIV, 1.0f / LIGHTMAP_DIV, 1.0f);
    sc.light().render();
    glPopMatrix();

    if (sg)
    {
      glPushMatrix();
      glScalef(1.0f / LIGHTMAP_DIV, 1.0f / LIGHTMAP_DIV, 1.0f);
      glMultMatrixf(gc_state.get_matrix().matrix);
      sg->render(SceneContext::LIGHTMAP);
      glPopMatrix();
    }

    { // Copy lightmap to a texture
      OpenGLState state;
        
      state.bind_texture(m_lightmap->get_texture());
      state.activate();

      glCopyTexSubImage2D(GL_TEXTURE_2D, 
                          0,    // mipmap level
                          0, 0, // xoffset, yoffset
                          0, // x
                          m_window.height - static_cast<GLsizei>(m_lightmap->get_height()), // y (OpenGL is upside down)
                          static_cast<GLsizei>(m_lightmap->get_width()), 
                          static_cast<GLsizei>(m_lightmap->get_height()));
    }
  }

  if (sc.get_render_mask() & SceneContext::COLORMAP)
  {
    // Render the colormap to the framebuffers->screen
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    sc.color().render();

    if (sg)
    {
      glPushMatrix();
      glMultMatrixf(gc_state.get_matrix().matrix);
      sg->render(SceneContext::COLORMAP);
      glPopMatrix();
    }
  }

  if (sc.get_render_mask() & SceneContext::LIGHTMAP)
  { // Renders the lightmap to the screen     
    OpenGLState state;

    state.bind_texture(m_lightmap->get_texture());

    state.enable(GL_BLEND);
    state.set_blend_func(GL_DST_COLOR, GL_ZERO);
    state.activate();

    glBegin(GL_QUADS);

    glTexCoord2f(m_lightmap->get_uv().left, m_lightmap->get_uv().bottom);
    glVertex2i(0, 0);

    glTexCoord2f(m_lightmap->get_uv().right, m_lightmap->get_uv().bottom);
    glVertex2i(m_viewport.width, 0);

    glTexCoord2f(m_lightmap->get_uv().right, m_lightmap->get_uv().top);
    glVertex2i(m_viewport.width, m_viewport.height);

    glTexCoord2f(m_lightmap->get_uv().left, m_lightmap->get_uv().top);
    glVertex2i(0, m_viewport.height);

    glEnd();
  }

  if (sc.get_render_mask() & SceneContext::HIGHLIGHTMAP)
  {
    sc.highlight().render();

    if (sg)
    {
      glPushMatrix();
      glMultMatrixf(gc_state.get_matrix().matrix);
      sg->render(SceneContext::HIGHLIGHTMAP);
      glPopMatrix();
    }
  }

  if (sc.get_render_mask() & SceneContext::CONTROLMAP)
  {
    sc.control().render();

    if (sg)
    {
      glPushMatrix();
      glMultMatrixf(gc_state.get_matrix().matrix);
      sg->render(SceneContext::CONTROLMAP);
      glPopMatrix();
    }
  }
  
  // Clear all DrawingContexts
  sc.color().clear();
  sc.light().clear();
  sc.highlight().clear();
  sc.control().clear(); 
}
Exemple #21
0
void
Slider::draw (SceneContext& gc)
{
  gc.color().draw(sprite[pingu->direction], pingu->get_pos() + Vector3f(0, -2));
}
Exemple #22
0
void
Blocker::draw (SceneContext& gc)
{
  gc.color().draw(sprite[pingu->direction], pingu->get_pos());
}
void
StarfieldBackgroundStars::draw (SceneContext& gc)
{
  gc.color().draw(sur, Vector3f (x_pos, y_pos));
}
Exemple #24
0
void
Digger::draw (SceneContext& gc)
{
  gc.color().draw(sprite, pingu->get_pos ());
}
Exemple #25
0
void
Exit::draw (SceneContext& gc)
{
  gc.color().draw(sprite, pos);
  gc.color().draw(flag, pos + Vector3f(40, 0));
}
Exemple #26
0
void
GroundMap::draw_colmap(SceneContext& gc)
{
  colmap->draw(gc.color());
}
Exemple #27
0
void
Smashed::draw (SceneContext& gc)
{
  gc.color().draw(sprite, pingu->get_pos ());
}
Exemple #28
0
void
Superman::draw (SceneContext& gc)
{
  gc.color().draw(sprite, pingu->get_pos ());
}
void
FramebufferCompositorImpl::render(SceneContext& sc, SceneGraph* sg, const GraphicContextState& gc_state)
{
  if (sc.get_render_mask() & SceneContext::LIGHTMAPSCREEN)
  {
    // Render the lightmap to framebuffers->lightmap
    Display::push_framebuffer(m_lightmap);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glTranslatef(0.0f, static_cast<float>(m_viewport.height - (m_viewport.height / LIGHTMAP_DIV)), 0.0f);
    glScalef(1.0f / LIGHTMAP_DIV, 1.0f / LIGHTMAP_DIV, 1.0f / LIGHTMAP_DIV);

    sc.light().render();

    if (sg)
    {
      glPushMatrix();
      glMultMatrixf(gc_state.get_matrix().matrix);
      sg->render(SceneContext::LIGHTMAP);
      glPopMatrix();
    }

    glPopMatrix();
    
    Display::pop_framebuffer();
  }

  { // Render the main screen
    Display::push_framebuffer(m_screen);

    if (sc.get_render_mask() & SceneContext::COLORMAP)
    {
      // Render the colormap to framebuffers->screen
      glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      sc.color().render();

      if (sg)
      {
        glPushMatrix();
        glMultMatrixf(gc_state.get_matrix().matrix);
        sg->render(SceneContext::COLORMAP);
        glPopMatrix();
      }
    }

    if (sc.get_render_mask() & SceneContext::LIGHTMAP)
    { // Renders the lightmap to the screen
      render_lightmap(sc, sg);
    }

    if (sc.get_render_mask() & SceneContext::HIGHLIGHTMAP)
    {
      sc.highlight().render();

      if (sg)
      {
        glPushMatrix();
        glMultMatrixf(gc_state.get_matrix().matrix);
        sg->render(SceneContext::HIGHLIGHTMAP);
        glPopMatrix();
      }
    }

    if (sc.get_render_mask() & SceneContext::CONTROLMAP)
    {
      sc.control().render();

      if (sg)
      {
        glPushMatrix();
        glMultMatrixf(gc_state.get_matrix().matrix);
        sg->render(SceneContext::CONTROLMAP);
        glPopMatrix();
      }
    }

    Display::pop_framebuffer();
  }

  if (1) 
  {
    // Render the screen framebuffer to the actual screen 
    OpenGLState state;

    state.bind_texture(m_screen->get_texture(), 0);

    state.activate();

    glBegin(GL_QUADS);
    {
      glTexCoord2i(0, 1);
      glVertex2i(0, 0);

      glTexCoord2i(1, 1);
      glVertex2i(m_viewport.width, 0);

      glTexCoord2i(1, 0);
      glVertex2i(m_viewport.width, m_viewport.height);

      glTexCoord2i(0, 0);
      glVertex2i(0.0f, m_viewport.height);
    }
    glEnd();
  }

  // Clear all DrawingContexts
  sc.color().clear();
  sc.light().clear();
  sc.highlight().clear();
  sc.control().clear();
}
Exemple #30
0
void
Smasher::draw (SceneContext& gc)
{
  gc.color().draw (surface, pos);
}