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/clisp.cpp

    r656 r657  
    906906    case 49 :
    907907    {
    908       int32_t x=lnumber_value(CAR(args)->Eval()); args=CDR(args);
    909       int32_t y=lnumber_value(CAR(args)->Eval()); args=CDR(args);
    910 
    911       int32_t rx,ry;
    912       the_game->mouse_to_game(x,y,rx,ry);
    913       void *ret=NULL;
    914       {
    915     PtrRef r1(ret);
    916     push_onto_list(LNumber::Create(ry),ret);
    917     push_onto_list(LNumber::Create(rx),ret);
     908      int x = lnumber_value(CAR(args)->Eval()); args = CDR(args);
     909      int y = lnumber_value(CAR(args)->Eval()); args = CDR(args);
     910
     911      vec2i pos = the_game->MouseToGame(vec2i(x, y));
     912      void *ret = NULL;
     913      {
     914          PtrRef r1(ret);
     915          push_onto_list(LNumber::Create(pos.y), ret);
     916          push_onto_list(LNumber::Create(pos.x), ret);
    918917      }
    919918      return ret;
     
    921920    case 50 :
    922921    {
    923       int32_t x=lnumber_value(CAR(args)->Eval()); args=CDR(args);
    924       int32_t y=lnumber_value(CAR(args)->Eval()); args=CDR(args);
    925 
    926       int32_t rx,ry;
    927       the_game->game_to_mouse(x,y,current_view,rx,ry);
    928       void *ret=NULL;
    929       {
    930     PtrRef r1(ret);
    931     push_onto_list(LNumber::Create(ry),ret);
    932     push_onto_list(LNumber::Create(rx),ret);
     922      int x = lnumber_value(CAR(args)->Eval()); args=CDR(args);
     923      int y = lnumber_value(CAR(args)->Eval()); args=CDR(args);
     924
     925      vec2i pos = the_game->GameToMouse(vec2i(x, y), current_view);
     926      void *ret = NULL;
     927      {
     928        PtrRef r1(ret);
     929        push_onto_list(LNumber::Create(pos.y), ret);
     930        push_onto_list(LNumber::Create(pos.x), ret);
    933931      }
    934932      return ret;
     
    12871285    case 92 :
    12881286    {
    1289       int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);
    1290       int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);
    1291       int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);
    1292       int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);
    1293       int32_t c=lnumber_value(CAR(args));
    1294       the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);
    1295       the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);
    1296       main_screen->Line(vec2i(cx1, cy1), vec2i(cx2, cy2), c);
     1287      int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args);
     1288      int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args);
     1289      int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args);
     1290      int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args);
     1291      int32_t c = lnumber_value(CAR(args));
     1292      vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view);
     1293      vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view);
     1294      main_screen->Line(pos1, pos2, c);
    12971295      return 1;
    12981296    } break;
     
    19641962    case 234 :
    19651963    {
    1966       int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);
    1967       int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);
    1968       int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);
    1969       int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);
    1970       int32_t c=lnumber_value(CAR(args)); args=lcdr(args);
    1971       int32_t s=lnumber_value(CAR(args));
    1972       the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);
    1973       the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);
    1974       scatter_line(cx1,cy1,cx2,cy2,c,s);
     1964      int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args);
     1965      int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args);
     1966      int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args);
     1967      int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args);
     1968      int32_t c = lnumber_value(CAR(args)); args = lcdr(args);
     1969      int32_t s = lnumber_value(CAR(args));
     1970      vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view);
     1971      vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view);
     1972      scatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c, s);
    19751973      return 1;
    19761974
     
    20162014    case 244 :
    20172015    {
    2018       int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);
    2019       int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);
    2020       int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);
    2021       int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);
    2022       int32_t c1=lnumber_value(CAR(args)); args=lcdr(args);
    2023       int32_t c2=lnumber_value(CAR(args)); args=lcdr(args);
    2024       int32_t s=lnumber_value(CAR(args));
    2025       the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);
    2026       the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);
    2027       ascatter_line(cx1,cy1,cx2,cy2,c1,c2,s);
     2016      int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args);
     2017      int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args);
     2018      int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args);
     2019      int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args);
     2020      int32_t c1 = lnumber_value(CAR(args)); args = lcdr(args);
     2021      int32_t c2 = lnumber_value(CAR(args)); args = lcdr(args);
     2022      int32_t s = lnumber_value(CAR(args));
     2023      vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view);
     2024      vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view);
     2025      ascatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c1, c2, s);
    20282026      return 1;
    20292027
Note: See TracChangeset for help on using the changeset viewer.