/[enigma]/enigma/src/display.cc
ViewVC logotype

Diff of /enigma/src/display.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by dheck, Fri Feb 28 15:02:52 2003 UTC revision 1.14 by dheck, Wed Mar 5 22:05:02 2003 UTC
# Line 67  static int TileWidth = 32; Line 67  static int TileWidth = 32;
67  static int TileHeight = 32;  static int TileHeight = 32;
68    
69  static GameDisplay   *gamedpy = 0;  static GameDisplay   *gamedpy = 0;
70  static DisplayEngine *engine  = 0;  // static DisplayEngine *engine  = 0;
71    
72  static DL_Lines   *line_layer    = 0;  static DL_Lines   *line_layer    = 0;
73  static DL_Sprites *sprite_layer  = 0;  static DL_Sprites *sprite_layer  = 0;
# Line 75  static DL_Shadows *shadow_layer  = 0; Line 75  static DL_Shadows *shadow_layer  = 0;
75    
76  namespace  namespace
77  {  {
78      const SpriteId  magic_spriteid = 1000000;      const SpriteId  MAGIC_SPRITEID = 1000000;
79    
80      // Do not change the order of the following two variables!      // Do not change the order of the following two variables!
     ModelList       active_models;  
81      FieldArray      fields(0,0);      FieldArray      fields(0,0);
82    
83      // Screen layout      // Screen layout
     ScreenArea gamearea(0,0,640, 480-64);  
84  }  }
85    
86    
# Line 90  namespace Line 88  namespace
88  // HELPER FUNCTIONS  // HELPER FUNCTIONS
89  //----------------------------------------------------------------------  //----------------------------------------------------------------------
90    
91  namespace display  void
92  {  ModelLayer::maybe_redraw_model(Model *m)
     void  
     add_active_model(Model *m)  
     {  
         list<Model*> &am = ::active_models;  
         if (find(am.begin(), am.end(), m) ==am.end()) {  
             // if not already in the list...  
             am.push_back(m);  
         }  
     }  
   
     void remove_active_model(Model *m)  
     {  
         ::active_models.remove(m);  
     }  
 }  
   
 void maybe_redraw_model(Model *m)  
93  {  {
94      WorldArea wa;      WorldArea wa;
95      if (m->has_changed(wa)) {      if (m->has_changed(wa)) {
96          engine->mark_update_area(wa);          get_engine()->mark_update_area(wa);
97      }      }
98  }  }
99    
# Line 125  ModelLayer::activate (Model *m) Line 106  ModelLayer::activate (Model *m)
106  }  }
107    
108  void  void
109    ModelLayer::new_world (int, int)
110    {
111        m_active_models.clear();
112    }
113    
114    void
115  ModelLayer::deactivate (Model *m)  ModelLayer::deactivate (Model *m)
116  {  {
117      m_active_models.remove(m);      m_active_models.remove(m);
# Line 144  ModelLayer::tick (double dtime) Line 131  ModelLayer::tick (double dtime)
131          (*i)->tick(dtime);          (*i)->tick(dtime);
132          i=n;          i=n;
133      }      }
134      for_each(am.begin(), am.end(), &maybe_redraw_model);      for (ModelList::iterator i=am.begin(); i!=am.end(); ++i) {
135            maybe_redraw_model (*i);
136        }
137  }  }
138    
   
   
139    
140  //======================================================================  //======================================================================
141  // DISPLAY ENGINE  // DISPLAY ENGINE
# Line 189  DisplayEngine::move_offset (const px::V2 Line 176  DisplayEngine::move_offset (const px::V2
176      int newx = int(off[0] * m_tilew);      int newx = int(off[0] * m_tilew);
177      int newy = int(off[1] * m_tileh);      int newy = int(off[1] * m_tileh);
178    
   
   
179      if (newx != oldx || newy != oldy)      if (newx != oldx || newy != oldy)
180      {      {
181          Rect newarea(newx, newy, m_area.w, m_area.h);          Rect newarea(newx, newy, m_area.w, m_area.h);
# Line 241  DisplayEngine::new_world (int w, int h) Line 226  DisplayEngine::new_world (int w, int h)
226            
227      for (unsigned i=0; i<m_layers.size(); ++i)      for (unsigned i=0; i<m_layers.size(); ++i)
228          m_layers[i]->new_world(w,h);          m_layers[i]->new_world(w,h);
229    
230        mark_update_world();
231  }  }
232    
233    
# Line 323  DisplayEngine::mark_redraw_screen() Line 310  DisplayEngine::mark_redraw_screen()
310      mark_redraw_area(screen_to_world(m_area));      mark_redraw_area(screen_to_world(m_area));
311  }  }
312    
   
313  void  void
314  DisplayEngine::draw_field (GC &gc, int x, int y)  DisplayEngine::draw_field (GC &gc, int x, int y)
315  {  {
# Line 414  DL_Sprites::~DL_Sprites() Line 400  DL_Sprites::~DL_Sprites()
400    
401    
402  void  void
403  DL_Sprites::new_world (int, int)  DL_Sprites::new_world (int w, int h)
404  {  {
405      delete_sequence (sprites.begin(), sprites.end());      delete_sequence (sprites.begin(), sprites.end());
406      sprites.clear();      sprites.clear();
407      numsprites = 0;      numsprites = 0;
408        ModelLayer::new_world (w,h);
409  }  }
410    
411  void  void
412  DL_Sprites::move_sprite (SpriteId id, const px::V3& newpos)  DL_Sprites::move_sprite (SpriteId id, const px::V3& newpos)
413  {  {
414      if (id == magic_spriteid)      if (id == MAGIC_SPRITEID)
415          return;          return;
416      Sprite *sprite = sprites[id];      Sprite *sprite = sprites[id];
417    
418      int oldx, oldy;      int oldx, oldy;
419      int newx, newy;      int newx, newy;
420      engine->world_to_screen (newpos, &newx, &newy);      get_engine()->world_to_screen (newpos, &newx, &newy);
421      engine->world_to_screen (sprite->pos, &oldx, &oldy);      get_engine()->world_to_screen (sprite->pos, &oldx, &oldy);
422    
423      if (oldx != newx || oldy != newy) {      if (oldx != newx || oldy != newy) {
424          redraw_sprite_region(id);          redraw_sprite_region(id);
# Line 446  DL_Sprites::add_sprite (Sprite *sprite) Line 433  DL_Sprites::add_sprite (Sprite *sprite)
433  {  {
434      if (numsprites >= maxsprites) {      if (numsprites >= maxsprites) {
435          delete sprite;          delete sprite;
436          return magic_spriteid;          return MAGIC_SPRITEID;
437      }      }
438    
439      SpriteList &sl = sprites;      SpriteList &sl = sprites;
440      SpriteId id = magic_spriteid;      SpriteId id = MAGIC_SPRITEID;
441    
442      // Find the first empty slot      // Find the first empty slot
443      SpriteList::iterator i = find(sl.begin(), sl.end(), (Sprite*)0);      SpriteList::iterator i = find(sl.begin(), sl.end(), (Sprite*)0);
# Line 462  DL_Sprites::add_sprite (Sprite *sprite) Line 449  DL_Sprites::add_sprite (Sprite *sprite)
449          id = distance(sl.begin(), i);          id = distance(sl.begin(), i);
450          *i = sprite;          *i = sprite;
451      }      }
452      if (sprite->model)      if (Model *m = sprite->model) {
453          sprite->model->activate(sprite->pos[0], sprite->pos[1], true);          m->expose (this, V2 (sprite->pos[0], sprite->pos[1]));
454        }
455      redraw_sprite_region(id);      redraw_sprite_region(id);
456      numsprites += 1;      numsprites += 1;
457      return id;      return id;
# Line 472  DL_Sprites::add_sprite (Sprite *sprite) Line 460  DL_Sprites::add_sprite (Sprite *sprite)
460  void  void
461  DL_Sprites::replace_sprite (SpriteId id, Model *m)  DL_Sprites::replace_sprite (SpriteId id, Model *m)
462  {  {
463      if (id == magic_spriteid) {      if (id == MAGIC_SPRITEID) {
464          delete m;          delete m;
465          return;          return;
466      }      }
467    
468      Sprite *sprite = sprites[id];      Sprite *sprite = sprites[id];
469      delete sprite->model;  
470        if (Model *m = sprite->model) {
471            m->remove (this);
472            delete m;
473        }
474      sprite->model = m;      sprite->model = m;
475      if (sprite->model)      if (Model *m = sprite->model) {
476          sprite->model->activate(sprite->pos[0], sprite->pos[1], true);          m->expose (this, V2 (sprite->pos[0], sprite->pos[1]));
477        }
478      redraw_sprite_region(id);      redraw_sprite_region(id);
479  }  }
480    
481  void  void
482  DL_Sprites::kill_sprite (SpriteId id)  DL_Sprites::kill_sprite (SpriteId id)
483  {  {
484      if (id == magic_spriteid)      if (id == MAGIC_SPRITEID)
485          return;          return;
486      if (Sprite *sprite = sprites[id]) {      if (Sprite *sprite = sprites[id]) {
487            if (Model *m = sprite->model) {
488                m->remove (this);
489            }
490          sprites[id] = 0;          sprites[id] = 0;
491          numsprites -= 1;          numsprites -= 1;
492          delete sprite;          delete sprite;
# Line 522  DL_Sprites::draw_sprites (bool shades, G Line 518  DL_Sprites::draw_sprites (bool shades, G
518          }          }
519          else {          else {
520              int sx, sy;              int sx, sy;
521              engine->world_to_screen(s->pos, &sx, &sy);              get_engine()->world_to_screen(s->pos, &sx, &sy);
522              if (shades)              if (shades)
523                  s->model->draw_shade(gc, sx, sy);                  s->model->draw_shade(gc, sx, sy);
524              else              else
# Line 553  void Line 549  void
549  DL_Grid::new_world (int w, int h)  DL_Grid::new_world (int w, int h)
550  {  {
551      m_models = ModelArray (w, h);      m_models = ModelArray (w, h);
552        ModelLayer::new_world (w, h);
553  }  }
554    
555  void  void
# Line 565  void Line 562  void
562  DL_Grid::set_model (int x, int y, Model *m)  DL_Grid::set_model (int x, int y, Model *m)
563  {  {
564      if (m_models(x,y) != m) {      if (m_models(x,y) != m) {
565          delete m_models(x,y);          if (Model *mm = m_models(x,y)) {
566                mm->remove(this);
567                delete mm;
568            }
569          m_models(x,y) = m;          m_models(x,y) = m;
570          mark_update(x,y);          mark_update(x,y);
571            if (m)
572                m->expose (this, V2(x, y));
573      }      }
574  }  }
575    
# Line 619  DL_Lines::draw_lines (GC &gc) Line 621  DL_Lines::draw_lines (GC &gc)
621  {  {
622      SDL_Surface *surf = video::GetScreen()->get_surface();      SDL_Surface *surf = video::GetScreen()->get_surface();
623    
624      Rect r = gamearea; //gc.get_cliprect();      Rect r = get_engine()->get_area();
625      SDL_Rect s;      SDL_Rect s;
626      sdl::copy_rect(s, r);      sdl::copy_rect(s, r);
627      SDL_SetClipRect (surf, &s);      SDL_SetClipRect (surf, &s);
628    
     DisplayEngine *engine = get_engine();  
   
629      for (LineMap::iterator i=m_rubbers.begin(); i!= m_rubbers.end(); ++i)      for (LineMap::iterator i=m_rubbers.begin(); i!= m_rubbers.end(); ++i)
630      {      {
631          int x1, y1, x2, y2;          int x1, y1, x2, y2;
632          engine->world_to_screen (i->second.start, &x1, &y1);          get_engine()->world_to_screen (i->second.start, &x1, &y1);
633          engine->world_to_screen (i->second.end, &x2, &y2);          get_engine()->world_to_screen (i->second.end, &x2, &y2);
634          aalineRGBA(surf, x1, y1, x2, y2, 240,140,20,255);          aalineRGBA(surf, x1, y1, x2, y2, 240,140,20,255);
635      }      }
636      SDL_SetClipRect (surf, NULL);      SDL_SetClipRect (surf, NULL);
# Line 679  DL_Lines::mark_redraw_line (const Line & Line 679  DL_Lines::mark_redraw_line (const Line &
679  //         else  //         else
680  //             wa.w = wa.h = 1;  //             wa.w = wa.h = 1;
681    
682          engine->mark_redraw_area (wa);          get_engine()->mark_redraw_area (wa);
683    
684          x += w;          x += w;
685          y += h;          y += h;
# Line 907  DL_Shadows::draw(GC &gc, int xpos, int y Line 907  DL_Shadows::draw(GC &gc, int xpos, int y
907    
908  void  void
909  DL_Shadows::shadow_blit (px::Surface *scr, int x, int y,  DL_Shadows::shadow_blit (px::Surface *scr, int x, int y,
910                                  px::Surface *shadows, px::Rect r)                           px::Surface *shadows, px::Rect r)
911  {  {
912      r.intersect(scr->size());      r.intersect(scr->size());
913      x=r.x;      x=r.x;
# Line 952  DL_Shadows::shadow_blit (px::Surface *sc Line 952  DL_Shadows::shadow_blit (px::Surface *sc
952      SDL_UnlockSurface(d);      SDL_UnlockSurface(d);
953  }  }
954    
955    Model *
956    DL_Shadows::get_shadow_model (Model *stone_models[4])
957    {
958        return 0;
959    }
960    
961    
962    
963  //----------------------------------------------------------------------  //----------------------------------------------------------------------
964  // GLOBAL FUNCTIONS  // GLOBAL FUNCTIONS
# Line 961  void Line 968  void
968  display::Init()  display::Init()
969  {  {
970      InitModels();      InitModels();
971      gamedpy = new GameDisplay;  
972        ScreenArea gamearea(0,0,640, 480-64);
973        gamedpy = new GameDisplay (gamearea);
974  }  }
975    
976  void  void
977  display::Shutdown()  display::Shutdown()
978  {  {
     active_models.clear();  
979      delete gamedpy;      delete gamedpy;
   
980      ShutdownModels();      ShutdownModels();
981  }  }
982    
# Line 1001  Follower_Screen::center(const px::V2 &po Line 1008  Follower_Screen::center(const px::V2 &po
1008  void  void
1009  Follower_Screen::tick(double, const px::V2 &point)  Follower_Screen::tick(double, const px::V2 &point)
1010  {  {
1011        DisplayEngine *engine = get_engine();
1012        ScreenArea gamearea = engine->get_area();
1013    
1014      for (;;) {      for (;;) {
1015          int sx, sy;          int sx, sy;
1016          engine->world_to_screen(point, &sx, &sy);          engine->world_to_screen(point, &sx, &sy);
# Line 1043  Follower_Scrolling::center(const px::V2 Line 1053  Follower_Scrolling::center(const px::V2
1053  void  void
1054  Follower_Scrolling::tick(double dtime, const px::V2 &point)  Follower_Scrolling::tick(double dtime, const px::V2 &point)
1055  {  {
1056        DisplayEngine *engine = get_engine();
1057        ScreenArea gamearea = engine->get_area();
1058    
1059      int sx, sy;      int sx, sy;
1060      engine->world_to_screen(point, &sx, &sy);      engine->world_to_screen(point, &sx, &sy);
1061    
# Line 1095  FollowMode display::SetFollowMode(Follow Line 1108  FollowMode display::SetFollowMode(Follow
1108      return gamedpy->set_follow_mode(m);      return gamedpy->set_follow_mode(m);
1109  }  }
1110    
 //----------------------------------------  
 // Handling active models  
 //----------------------------------------  
   
 Model *  
 CommonDisplay::set_model (const GridLoc &l, Model *m)  
 {  
     int x = l.pos.x, y=l.pos.y;  
   
     switch (l.layer) {  
     case GRID_FLOOR: floor_layer->set_model (x, y, m); break;  
     case GRID_ITEMS: item_layer->set_model (x, y, m); break;  
     case GRID_STONES:  
         stone_layer->set_model (x, y, m);  
 //        shadow_layer->set_model (x, y, m);  
         break;  
     case GRID_COUNT: break;  
     }  
     Field& f = fields(x, y);  
     f.layers[l.layer] = m;  
     if (m)  
         m->activate(double(x), double(y), false);  
 //    mark_change(l);  
     return m;  
 }  
   
 Model *  
 CommonDisplay::get_model (const GridLoc &l)  
 {  
     int x = l.pos.x, y=l.pos.y;  
     switch (l.layer) {  
     case GRID_FLOOR: return floor_layer->get_model (x, y);  
     case GRID_ITEMS: return item_layer->get_model (x, y);  
     case GRID_STONES: return stone_layer->get_model (x, y);  
     case GRID_COUNT: return 0;  
     }  
     return 0;  
 }  
   
 Model *  
 CommonDisplay::yield_model (const GridLoc &l)  
 {  
     int x = l.pos.x, y=l.pos.y;  
     fields(x, y).layers[l.layer] = 0;  
     switch (l.layer) {  
     case GRID_FLOOR: return floor_layer->yield_model (x, y);  
     case GRID_ITEMS: return item_layer->yield_model (x, y);  
     case GRID_STONES: return stone_layer->yield_model (x, y);  
     case GRID_COUNT: return 0;  
     }  
     return 0;  
 }  
   
1111  Model *display::SetModel (const GridLoc &l, Model *m) {  Model *display::SetModel (const GridLoc &l, Model *m) {
1112      return gamedpy->set_model (l, m);      return gamedpy->set_model (l, m);
1113  }  }
# Line 1168  Model *display::YieldModel(const GridLoc Line 1128  Model *display::YieldModel(const GridLoc
1128      return gamedpy->yield_model (l);      return gamedpy->yield_model (l);
1129  }  }
1130    
1131  void  void display::AddEffect (const V3& pos, const char *modelname) {
 display::AddEffect (const V3& pos, const char *modelname)  
 {  
1132      gamedpy->add_effect (pos, MakeModel(modelname));      gamedpy->add_effect (pos, MakeModel(modelname));
1133  }  }
1134    
# Line 1209  display::SetCallback(SpriteId id, ModelC Line 1167  display::SetCallback(SpriteId id, ModelC
1167  Model *  Model *
1168  display::GetModel(SpriteId id)  display::GetModel(SpriteId id)
1169  {  {
1170      if (id == magic_spriteid)      if (id == MAGIC_SPRITEID)
1171          return 0;          return 0;
1172      return sprite_layer->sprites[id]->model;      return sprite_layer->sprites[id]->model;
1173  }  }
# Line 1219  display::SetTileSize(int w, int h) Line 1177  display::SetTileSize(int w, int h)
1177  {  {
1178      TileWidth = w;      TileWidth = w;
1179      TileHeight = h;      TileHeight = h;
1180      engine->set_tilesize(w,h);  //    engine->set_tilesize(w,h);
1181  }  }
1182    
1183  void  void
# Line 1240  void display::Redraw(Screen *screen) { Line 1198  void display::Redraw(Screen *screen) {
1198      gamedpy->redraw(screen);      gamedpy->redraw(screen);
1199  }  }
1200    
   
1201    
1202  //----------------------------------------------------------------------  //----------------------------------------------------------------------
1203  // Game Display Engine  // Editor / game display engine
1204  //----------------------------------------------------------------------  //----------------------------------------------------------------------
1205    CommonDisplay::CommonDisplay (const ScreenArea &a)
 GameDisplay::GameDisplay()  
 : last_frame_time (0),  
   redraw_everything(false),  
   follow_sprite (magic_spriteid),  
   follow_mode (FOLLOW_NONE),  
   follower (0),  
   inventoryarea(0, 480-64, 640, 64)  
1206  {  {
1207      status_bar = new StatusBarImpl (inventoryarea);      DisplayEngine *engine = new DisplayEngine (video::GetScreen());
1208        engine->set_screen_area (a);
     // Initialize display engine  
     engine = new DisplayEngine (video::GetScreen());  
     engine->set_screen_area (gamearea);  
1209    
1210      engine->add_layer (floor_layer = new DL_Grid);      engine->add_layer (floor_layer = new DL_Grid);
1211      engine->add_layer (item_layer = new DL_Grid);      engine->add_layer (item_layer = new DL_Grid);
# Line 1268  GameDisplay::GameDisplay() Line 1215  GameDisplay::GameDisplay()
1215      engine->add_layer (line_layer = new DL_Lines);      engine->add_layer (line_layer = new DL_Lines);
1216      engine->add_layer (effects_layer = new DL_Sprites);      engine->add_layer (effects_layer = new DL_Sprites);
1217      effects_layer->set_maxsprites(10);      effects_layer->set_maxsprites(10);
1218    
1219        m_engine = engine;
1220    }
1221    
1222    CommonDisplay::~CommonDisplay()
1223    {
1224        delete m_engine;
1225    }
1226    
1227    
1228    Model *
1229    CommonDisplay::set_model (const GridLoc &l, Model *m)
1230    {
1231        int x = l.pos.x, y=l.pos.y;
1232    
1233        switch (l.layer) {
1234        case GRID_FLOOR: floor_layer->set_model (x, y, m); break;
1235        case GRID_ITEMS: item_layer->set_model (x, y, m); break;
1236        case GRID_STONES:
1237            stone_layer->set_model (x, y, m);
1238    //        shadow_layer->set_model (x, y, m);
1239            break;
1240        case GRID_COUNT: break;
1241        }
1242        Field& f = fields(x, y);
1243        f.layers[l.layer] = m;
1244        return m;
1245    }
1246    
1247    Model *
1248    CommonDisplay::get_model (const GridLoc &l)
1249    {
1250        int x = l.pos.x, y=l.pos.y;
1251        switch (l.layer) {
1252        case GRID_FLOOR: return floor_layer->get_model (x, y);
1253        case GRID_ITEMS: return item_layer->get_model (x, y);
1254        case GRID_STONES: return stone_layer->get_model (x, y);
1255        case GRID_COUNT: return 0;
1256        }
1257        return 0;
1258    }
1259    
1260    Model *
1261    CommonDisplay::yield_model (const GridLoc &l)
1262    {
1263        int x = l.pos.x, y=l.pos.y;
1264        fields(x, y).layers[l.layer] = 0;
1265        switch (l.layer) {
1266        case GRID_FLOOR: return floor_layer->yield_model (x, y);
1267        case GRID_ITEMS: return item_layer->yield_model (x, y);
1268        case GRID_STONES: return stone_layer->yield_model (x, y);
1269        case GRID_COUNT: return 0;
1270        }
1271        return 0;
1272    }
1273    
1274    SpriteHandle
1275    CommonDisplay::add_effect (const V3& pos, Model *m)
1276    {
1277        Sprite *spr = new Sprite (pos, SPRITE_EFFECT, m);
1278        return SpriteHandle (effects_layer, effects_layer->add_sprite(spr));
1279    }
1280    
1281    void
1282    CommonDisplay::new_world (int w, int h)
1283    {
1284        fields = FieldArray(w, h);
1285        get_engine()->new_world (w, h);
1286    }
1287    
1288    void
1289    CommonDisplay::redraw()
1290    {
1291        get_engine()->update_screen();
1292    }
1293    
1294    
1295    void
1296    CommonDisplay::set_floor (int x, int y, Model *m)
1297    {
1298        floor_layer->set_model (x, y, m);
1299    }
1300    
1301    
1302    
1303    //----------------------------------------------------------------------
1304    // Game Display Engine
1305    //----------------------------------------------------------------------
1306    
1307    GameDisplay::GameDisplay(const ScreenArea &a)
1308    : CommonDisplay(a),
1309      last_frame_time (0),
1310      redraw_everything(false),
1311      follow_sprite (MAGIC_SPRITEID),
1312      follow_mode (FOLLOW_NONE),
1313      follower (0),
1314      inventoryarea(0, 480-64, 640, 64)
1315    {
1316        status_bar = new StatusBarImpl (inventoryarea);
1317  }  }
1318    
1319  GameDisplay::~GameDisplay()  GameDisplay::~GameDisplay()
1320  {  {
1321      delete status_bar;      delete status_bar;
     delete engine;  
1322  }  }
1323    
1324  void  void
1325  GameDisplay::tick(double dtime)  GameDisplay::tick(double dtime)
1326  {  {
1327      engine->tick (dtime);      get_engine()->tick (dtime);
1328      status_bar->tick (dtime);      status_bar->tick (dtime);
1329    
1330      ModelList &am = active_models;      if (follow_sprite != MAGIC_SPRITEID) {
     am.remove_if(mem_fun(&Model::is_garbage));  
   
     /* for_each does not work; animation may remove itself during  
        tick() */  
     for (ModelList::iterator i=am.begin(); i!=am.end(); ) {  
         ModelList::iterator n=next(i);  
         (*i)->tick(dtime);  
         i=n;  
     }  
     for_each(am.begin(), am.end(), &maybe_redraw_model);  
   
   
     if (follow_sprite != magic_spriteid) {  
1331          V3 point = sprite_layer->sprites[follow_sprite]->pos;          V3 point = sprite_layer->sprites[follow_sprite]->pos;
1332          follower->tick(dtime, V2(point[0], point[1]));          follower->tick(dtime, V2(point[0], point[1]));
1333      }      }
# Line 1304  GameDisplay::tick(double dtime) Line 1336  GameDisplay::tick(double dtime)
1336  void  void
1337  GameDisplay::new_world (int w, int h)  GameDisplay::new_world (int w, int h)
1338  {  {
1339      active_models.clear();      CommonDisplay::new_world (w, h);
   
1340      status_bar->new_world();      status_bar->new_world();
1341      SetFollowMode(FOLLOW_NONE);      SetFollowMode(FOLLOW_NONE);
1342    
1343      fields = FieldArray(w, h);  //     shadow_layer->new_world(w,h);
     engine->new_world (w, h);  
     shadow_layer->new_world(w,h);  
     engine->mark_update_world();  
   
   
1344      ScrollX = ScrollY = 0;      ScrollX = ScrollY = 0;
1345  }  }
1346    
# Line 1356  GameDisplay::set_follower (Follower *f) Line 1382  GameDisplay::set_follower (Follower *f)
1382  {  {
1383      delete follower;      delete follower;
1384      follower = f;      follower = f;
1385        if (follower) {
1386            follower->set_engine (get_engine());
1387        }
1388  }  }
1389    
1390  void  void
# Line 1363  GameDisplay::follow_center() Line 1392  GameDisplay::follow_center()
1392  {  {
1393      if (follow_mode == FOLLOW_NONE)      if (follow_mode == FOLLOW_NONE)
1394          set_follow_mode (FOLLOW_SCREEN);          set_follow_mode (FOLLOW_SCREEN);
1395      if (follow_sprite != magic_spriteid) {      if (follow_sprite != MAGIC_SPRITEID) {
1396          V3 point = sprite_layer->sprites[follow_sprite]->pos;          V3 point = sprite_layer->sprites[follow_sprite]->pos;
1397          follower->center (V2(point[0], point[1]));          follower->center (V2(point[0], point[1]));
1398      }      }
# Line 1383  GameDisplay::set_follow_sprite(SpriteId Line 1412  GameDisplay::set_follow_sprite(SpriteId
1412  void  void
1413  GameDisplay::redraw_all(Screen *scr)  GameDisplay::redraw_all(Screen *scr)
1414  {  {
1415      engine->mark_redraw_screen();      get_engine()->mark_redraw_screen();
1416      redraw_everything = true;      redraw_everything = true;
1417      redraw (scr);      redraw (scr);
1418  }  }
# Line 1392  void Line 1421  void
1421  GameDisplay::redraw(px::Screen *screen)  GameDisplay::redraw(px::Screen *screen)
1422  {  {
1423      GC gc(screen);      GC gc(screen);
1424        CommonDisplay::redraw();
     engine->update_screen();  
1425      if (status_bar->has_changed() || redraw_everything) {      if (status_bar->has_changed() || redraw_everything) {
1426          status_bar->redraw (gc, inventoryarea);          status_bar->redraw (gc, inventoryarea);
1427          screen->update_rect(inventoryarea);          screen->update_rect(inventoryarea);
# Line 1419  GameDisplay::redraw(px::Screen *screen) Line 1447  GameDisplay::redraw(px::Screen *screen)
1447  void  void
1448  GameDisplay::draw_all (GC &gc)  GameDisplay::draw_all (GC &gc)
1449  {  {
1450      engine->draw_all(gc);      get_engine()->draw_all(gc);
1451      status_bar->redraw (gc, inventoryarea);      status_bar->redraw (gc, inventoryarea);
1452  }  }
1453    

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26