/minild29

To get this branch, use:
bzr branch http://9ix.org/bzr/minild29

« back to all changes in this revision

Viewing changes to Dark.cpp

  • Committer: Josh C
  • Date: 2011-09-18 16:59:41 UTC
  • Revision ID: josh@9ix.org-20110918165941-waswg2xidvf0v04x
player and creature spawners in level editor

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
    Level::LoadProject("project.xml");
332
332
    Level::Load("level.xml", this);
333
333
 
 
334
    HideSpawners();
 
335
    Spawn();
 
336
 
334
337
    std::list<Entity*> *walls = GetAllTag("wall");
335
338
    for (std::list<Entity*>::iterator i = walls->begin(); i != walls->end(); ++i)
336
339
      {
339
342
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
340
343
      }
341
344
   
 
345
    Graphics::SetBackgroundColor(Color::green * 0.2f);
 
346
 
 
347
  }
 
348
 
 
349
  void DarkScene::HideSpawners()
 
350
  {
 
351
    std::list<Entity*> *spawners = GetAllTag("spawner");
 
352
    if (spawners == NULL) {printf("NO SPAWNERS!!!\n");}
 
353
    for (std::list<Entity*>::iterator i = spawners->begin(); i != spawners->end(); ++i)
 
354
      (*i)->isVisible = false;
 
355
  }
 
356
 
 
357
  void DarkScene::ShowSpawners()
 
358
  {
 
359
    std::list<Entity*> *spawners = GetAllTag("spawner");
 
360
    for (std::list<Entity*>::iterator i = spawners->begin(); i != spawners->end(); ++i)
 
361
      (*i)->isVisible = true;
 
362
  }
 
363
  
 
364
  void DarkScene::Spawn()
 
365
  {
 
366
    Entity* playersp = GetFirstEntityWithTag("playerspawner");
342
367
    player = new Player();
343
 
    player->position = Graphics::GetScreenCenter();
 
368
    player->position = playersp->position;;
344
369
    Add(player);
345
370
    Add(player->dark);
346
371
 
347
 
    Creature *creature = new Creature;
348
 
    creature->position = Graphics::GetScreenCenter();
349
 
    Add(creature);
350
 
 
351
 
    Creature *creature2 = new Creature;
352
 
    creature2->position = Graphics::GetScreenCenter();
353
 
    Add(creature2);
354
 
 
355
 
    Graphics::SetBackgroundColor(Color::green * 0.2f);
356
 
 
 
372
    std::list<Entity*> *spawners = GetAllTag("creaturespawner");
 
373
    // Ugh, monocle is double-entering all the tags...
 
374
    spawners->sort();
 
375
    spawners->unique();
 
376
    for (std::list<Entity*>::iterator i = spawners->begin(); i != spawners->end(); ++i)
 
377
      {
 
378
        Creature *creature = new Creature();
 
379
        creature->position = (*i)->position;
 
380
        Add(creature);
 
381
      }
357
382
  }
358
383
 
359
384
  void DarkScene::Update()
384
409
            
385
410
            if (isPaused) {
386
411
              player->dark->isVisible = false;
 
412
              ShowSpawners();
387
413
              levelEditor->Enable();
388
414
            } else {
 
415
              HideSpawners();
389
416
              levelEditor->Disable();
390
417
              player->dark->isVisible = true;
391
418
            }