Esempio n. 1
0
Mirror::~Mirror()
{
  volatile u16* mirrorMapPtr = (volatile u16*)bgGetMapPtr(mirrorBgHandle);
  //clear the 4 base tiles on the map
  mirrorMapPtr[pos2idx(xPos*2, yPos*2)] = 0;
  mirrorMapPtr[pos2idx(xPos*2+1, yPos*2)] = 0;
  mirrorMapPtr[pos2idx(xPos*2, yPos*2+1)] = 0;
  mirrorMapPtr[pos2idx(xPos*2+1, yPos*2+1)] = 0;
}
Esempio n. 2
0
 void ParticleGrid::shift(Particle *p, const Point_t& pos, const Point_t& dir)
 {
   size_t gidx0 = pos2idx(p->getPosition());
   size_t gidx1 = pos2idx(pos);
   std::remove (grid[gidx0].begin(), grid[gidx0].end(), p);
   p->setPosition(pos);
   p->setDirection(dir);
   grid[gidx1].push_back(p);
 }
Esempio n. 3
0
void Target::drawUpdate()
{
  volatile u16* mapPtr = (volatile u16*)bgGetMapPtr(bgHandle);
  if(state < 5)
  {
    mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | (tileBase+state*4));
    mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (tileBase+1+state*4));
    mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (tileBase+2+state*4));
    mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (tileBase+3+state*4));
    if(state > 0)
    {
      if(frameCounter > 4)
      {
        state++;
        frameCounter = 0;
      }
      else
      {
        ++frameCounter;
      }
    }
  }
  else if(state == 5)
  {
    mapPtr[pos2idx(xPos*2, yPos*2)] = 0;
    mapPtr[pos2idx(xPos*2+1, yPos*2)] = 0;
    mapPtr[pos2idx(xPos*2, yPos*2+1)] = 0;
    mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = 0;
    state++;
    //Notify the level that a target was destroyed
    level->targetDestroyed(this);
  }
}
Esempio n. 4
0
void SpinBlocker::drawUpdate()
{
  volatile u16* mapPtr = (volatile u16*)bgGetMapPtr(bgHandle);
  mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | (tileBase+angle*4));
  mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (tileBase+1+angle*4));
  mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (tileBase+2+angle*4));
  mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (tileBase+3+angle*4));
  if(frameCounter > ANIMATION_DELAY)
  {
    angle++;
    if(angle & 8) angle = 0; 
    frameCounter = 0;
  }
  else
  {
    ++frameCounter;
  }
}
Esempio n. 5
0
void Mirror::drawUpdate()
{
  if(needsUpdate)
  {
    volatile u16* mapPtr = (volatile u16*)bgGetMapPtr(bgHandle);
    volatile u16* mirrorMapPtr = (volatile u16*)bgGetMapPtr(mirrorBgHandle);
    //fill in the 4 base tiles on the map
    mirrorMapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | mirrorTileBase);
    mirrorMapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (mirrorTileBase+1));
    mirrorMapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (mirrorTileBase+2));
    mirrorMapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (mirrorTileBase+3));
    
    //fill in the 4 mirror-position tiles
    int angleTileIdx = 4+(4*angle);
    mapPtr[pos2idx(xPos*2,yPos*2)] = ((paletteIndex << 12) | (mirrorTileBase+angleTileIdx));
    mapPtr[pos2idx(xPos*2+1,yPos*2)] = ((paletteIndex << 12) | (mirrorTileBase+angleTileIdx+1));
    mapPtr[pos2idx(xPos*2,yPos*2+1)] = ((paletteIndex << 12) | (mirrorTileBase+angleTileIdx+2));
    mapPtr[pos2idx(xPos*2+1,yPos*2+1)] = ((paletteIndex << 12) | (mirrorTileBase+angleTileIdx+3));
    
    needsUpdate = false;
  }
}
Esempio n. 6
0
 void ParticleGrid::remove(Particle* p)
 {
   size_t gidx0 = pos2idx(p->getPosition());
   std::remove (grid[gidx0].begin(), grid[gidx0].end(), p);
   pool.destroy(p);
 }
Esempio n. 7
0
 void ParticleGrid::add(const Point_t &pos, const Point_t &dir)
 {
   Particle* p = pool.create(pos, dir);
   size_t gidx = pos2idx(pos);
   grid[gidx].push_back(p);
 }
Esempio n. 8
0
void Laser::drawUpdate()
{
  volatile u16* mapPtr = (volatile u16*)bgGetMapPtr(bgHandle);
  switch (dir) {
    case UP:
      //facing up
      mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | laserTileBase);
      mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+1));
      mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+2));
      mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+3));
      break;
    case RIGHT:
      //facing right
      mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+4));
      mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+5));
      mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+6));
      mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+7));
      break;
    case DOWN:
      //facing down - facing up mirrored
      mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+2) | BIT(11));
      mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+3) | BIT(11));
      mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | laserTileBase | BIT(11));
      mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+1) | BIT(11));
      break;
    case LEFT:
      //facing left - facing right mirrored
      mapPtr[pos2idx(xPos*2, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+5) | BIT(10));
      mapPtr[pos2idx(xPos*2+1, yPos*2)] = ((paletteIndex << 12) | (laserTileBase+4) | BIT(10));
      mapPtr[pos2idx(xPos*2, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+7) | BIT(10));
      mapPtr[pos2idx(xPos*2+1, yPos*2+1)] = ((paletteIndex << 12) | (laserTileBase+6) | BIT(10));
      break;
    default:
      break;
  }
}