Changeset 672


Ignore:
Timestamp:
May 16, 2011, 2:37:35 AM (10 years ago)
Author:
Sam Hocevar
Message:

game: make the scattered line functions use vec2i.

Location:
abuse/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/TODO

    r670 r672  
    6363Jwindow::_x1 _x2
    6464
    65 console::draw_char : vec2i
    6665VolumeWindow::draw_vol plus grand !!
    6766
    6867x, y in game_object?
    6968snap_x() snap_y()
    70 scatter_line, ascatter_line
    7169xstart() / xend() etc.
    7270jwindow::area
  • abuse/trunk/src/clisp.cpp

    r668 r672  
    8686uint8_t chatting_enabled=0;
    8787
    88 extern void scatter_line(int x1, int y1, int x2, int y2, int c, int s);
    89 extern void ascatter_line(int x1, int y1, int x2, int y2, int c1, int c2, int s);
    9088extern void show_end();
    9189
     
    19701968      vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view);
    19711969      vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view);
    1972       scatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c, s);
     1970      ScatterLine(pos1, pos2, c, s);
    19731971      return 1;
    19741972
     
    20232021      vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view);
    20242022      vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view);
    2025       ascatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c1, c2, s);
     2023      AScatterLine(pos1, pos2, c1, c2, s);
    20262024      return 1;
    20272025
  • abuse/trunk/src/console.cpp

    r671 r672  
    103103
    104104
    105 void console::draw_char(int x, int y, char ch)
     105void console::DrawChar(vec2i pos, char ch)
    106106{
    107107    if (!con_win)
     
    109109
    110110    vec2i fs = fnt->Size();
    111     vec2i pos = vec2i(wx(), wy()) + vec2i(x, y) * fs;
     111    pos = vec2i(wx(), wy()) + pos * fs;
    112112    con_win->m_surf->Bar(pos, pos + fs - vec2i(1), wm->black());
    113113    fnt->PutChar(con_win->m_surf, pos, ch);
     
    116116void console::do_cr()
    117117{
    118   if (cx<w && cy<h)  draw_char(cx,cy,screen[cy*w+cx]);
     118  if (cx<w && cy<h) DrawChar(vec2i(cx, cy), screen[cy*w+cx]);
    119119  cx=0;
    120120  cy++;
     
    143143      {
    144144    if (con_win)
    145       draw_char(cx,cy,screen[cy*w+cx]);
     145      DrawChar(vec2i(cx, cy), screen[cy*w+cx]);
    146146    cx--;
    147147    if (con_win)
     
    158158      screen[cy*w+cx]=ch;
    159159      if (con_win)
    160         draw_char(cx,cy,ch);
     160        DrawChar(vec2i(cx, cy), ch);
    161161      cx++;
    162162      if (cx>=w) do_cr(); else
  • abuse/trunk/src/console.h

    r668 r672  
    3636  void draw_cursor();
    3737  void put_string(char const *st);
    38   void draw_char(int x, int y, char ch);
     38  void DrawChar(vec2i pos, char ch);
    3939  void toggle() { if (con_win) hide(); else show(); }
    4040  void print_f(char const *format, ...);
  • abuse/trunk/src/particle.cpp

    r665 r672  
    209209}
    210210
    211 void scatter_line(int x1, int y1, int x2, int y2, int c, int s)
     211void ScatterLine(vec2i p1, vec2i p2, int c, int s)
    212212{
    213213    vec2i caa, cbb;
    214214    main_screen->GetClip(caa, cbb);
    215215
    216     int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1;
    217     long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) << 16 ) / t, x, y;
    218 
    219     int xm = ( 1 << s );
    220     int ym = ( 1 << s );
    221     s = ( 15 - s );
     216    int t = 1 + Max(abs(p2.x - p1.x), abs(p2.y - p1.y));
     217    int xo = p1.x << 16,
     218        yo = p1.y << 16,
     219        dx = ((p2.x - p1.x) << 16) / t,
     220        dy = ((p2.y - p1.y) << 16) / t;
     221
     222    int xm = (1 << s);
     223    int ym = (1 << s);
     224    s = (15 - s);
    222225
    223226    main_screen->Lock();
    224     while( t-- )
    225     {
    226         x = ( xo >> 16 ) + ( jrand() >> s ) - xm;
    227         y = ( yo >> 16 ) + ( jrand() >> s ) - ym;
    228         if( !( x < caa.x || y < caa.y || x >= cbb.x || y >= cbb.y ) )
     227    while(t--)
     228    {
     229        int x = (xo >> 16) + (jrand() >> s) - xm;
     230        int y = (yo >> 16) + (jrand() >> s) - ym;
     231        if(!(x < caa.x || y < caa.y || x >= cbb.x || y >= cbb.y))
    229232        {
    230             *(main_screen->scan_line( y ) + x ) = c;
     233            *(main_screen->scan_line(y) + x) = c;
    231234        }
    232235        xo += dx;
     
    236239}
    237240
    238 
    239 
    240 void ascatter_line(int x1, int y1, int x2, int y2, int c1, int c2, int s)
     241void AScatterLine(vec2i p1, vec2i p2, int c1, int c2, int s)
    241242{
    242243    vec2i caa, cbb;
    243244    main_screen->GetClip(caa, cbb);
    244245
    245     int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1;
    246     long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) <<16 ) / t, x, y;
    247 
    248     int xm = ( 1 << s );
    249     int ym = ( 1 << s );
    250     s = ( 15 - s );
     246    int t = 1 + Max(abs(p2.x - p1.x), abs(p2.y - p1.y));
     247    int xo = p1.x << 16,
     248        yo = p1.y << 16,
     249        dx = ((p2.x - p1.x) << 16) / t,
     250        dy = ((p2.y - p1.y) << 16) / t;
     251
     252    int xm = (1 << s);
     253    int ym = (1 << s);
     254    s = (15 - s);
    251255
    252256    main_screen->Lock();
     
    255259    uint8_t *addr;
    256260
    257     while( t-- )
    258     {
    259         x = ( xo >> 16 ) + ( jrand() >> s ) - xm;
    260         y = ( yo >> 16 ) + ( jrand() >> s ) - ym;
     261    while(t--)
     262    {
     263        int x = (xo >> 16) + (jrand() >> s) - xm;
     264        int y = (yo >> 16) + (jrand() >> s) - ym;
    261265        // FIXME: these clip values seemed wrong to me before the GetClip
    262266        // refactoring.
    263         if( !( x <= caa.x || y <= caa.y || x >= cbb.x - 1 || y >= cbb.y - 1) )
     267        if(!(x <= caa.x || y <= caa.y || x >= cbb.x - 1 || y >= cbb.y - 1))
    264268        {
    265             addr = main_screen->scan_line( y ) + x;
     269            addr = main_screen->scan_line(y) + x;
    266270            *addr = c1;
    267271            *(addr + w) = c2;
  • abuse/trunk/src/particle.h

    r555 r672  
    2323void tick_panims();
    2424void free_pframes();
     25void ScatterLine(vec2i p1, vec2i p2, int c, int s);
     26void AScatterLine(vec2i p1, vec2i p2, int c1, int c2, int s);
    2527
    2628struct part
     
    6062} ;
    6163
    62 
    6364#endif
    6465
    65 
Note: See TracChangeset for help on using the changeset viewer.