Ignore:
Timestamp:
May 15, 2011, 6:22:17 AM (11 years ago)
Author:
Sam Hocevar
Message:

game: refactor the mouse/game coordinate conversion logic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/objects.cpp

    r643 r657  
    378378void game_object::draw_above(view *v)
    379379{
    380   int32_t x1,y1,x2,y2,sy1,sy2,sx,i;
     380  int32_t x1, y1, x2, y2;
    381381  picture_space(x1,y1,x2,y2);
    382382
    383   the_game->game_to_mouse(x1,y1,v,sx,sy2);
    384   if (sy2>=v->cy1)
    385   {
    386     int32_t draw_to=y1-(sy2-v->cy1),tmp=x;
    387     current_level->foreground_intersect(x,y1,tmp,draw_to);
    388     the_game->game_to_mouse(x1,draw_to,v,i,sy1);     // calculate sy1
    389 
    390     sy1 = Max(v->cy1, sy1);
    391     sy2 = Min(v->cy2, sy2);
    392     TransImage *p=picture();
    393 
    394     for (i=sy1; i<=sy2; i++)
    395       p->PutScanLine(main_screen,vec2i(sx,i),0);
     383  vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), v);
     384  if (pos1.y >= v->cy1)
     385  {
     386    int32_t draw_to = y1 - (pos1.y - v->cy1), tmp = x;
     387    current_level->foreground_intersect(x, y1, tmp, draw_to);
     388    // calculate pos2.y
     389    vec2i pos2 = the_game->GameToMouse(vec2i(x1, draw_to), v);
     390
     391    pos2.y = Max(v->cy1, pos2.y);
     392    pos1.y = Min(v->cy2, pos1.y);
     393    TransImage *p = picture();
     394
     395    for (int i = pos2.y; i <= pos1.y; i++)
     396      p->PutScanLine(main_screen, vec2i(pos1.x, i), 0);
    396397  }
    397398}
Note: See TracChangeset for help on using the changeset viewer.