Ejemplo n.º 1
0
RoomElement hitMonster(RoomElement element)
{
  //erase the old monster image (using blank map tile)
  TV.bitmap(element.x, element.y, map_bitmap);
  TV.bitmap(element.x, element.y + 8, map_bitmap);

  element.state = STATE_HIDDEN;

  //add heart element
  addRoomElement(ITEM_HEART, element.x, element.y, STATE_VISIBLE, COUNTER_START);

  return element;
}
Ejemplo n.º 2
0
void drawLogo(char start)
{
  //draw hearts
  char x_offset = 48;
  for (char i=start; i < (start+4); i++)
  {
      //draw logo element
      TV.bitmap(x_offset, 16, logo_bitmap + (SIZEOF_LOGO_RECORD * i));
   
    x_offset += 8;
  }   
}
Ejemplo n.º 3
0
void moveElf(unsigned char facing)
{
  //erase the old elf image (using blank map tile)
  TV.bitmap(elf.x, elf.y, map_bitmap);
  TV.bitmap(elf.x, elf.y + 8, map_bitmap);

  //if it is a new facing, then reset the step
  if (facing != elf.facing)
  {
     elf.step = 1;
  } else {
     elf.step++;
     if (elf.step > 2) elf.step = 1;
  }

  elf.facing = facing;

  switch (facing)
  {
     case FACING_DOWN:
         if (elf.y < 48)
         {
             if (checkMapRoomMove(elf.x, elf.y + 16) == 0)
                 if (checkMapRoomMove(elf.x+4, elf.y + 16) == 0) elf.y += STEP_LENGTH;
         } else {
             scrollMap(SCROLL_DOWN);
             elf.x = 36;
             elf.y = 8;
             elf.facing = FACING_DOWN;
         }
         break;

     case FACING_UP:
         if (elf.y > 4)
         {
             if (checkMapRoomMove(elf.x, elf.y - 4) == 0)
                 if (checkMapRoomMove(elf.x + 4, elf.y - 4) == 0) elf.y -= STEP_LENGTH;
         } else {
             scrollMap(SCROLL_UP);
             elf.x = 36;
             elf.y = 32;
             elf.facing = FACING_UP;
         }
         break;

     case FACING_LEFT:
         if (elf.x > 4)
         {
             if (checkMapRoomMove(elf.x - 4, elf.y) == 0)
                 if (checkMapRoomMove(elf.x - 4, elf.y + 12) == 0) elf.x -= STEP_LENGTH;
         } else {
             scrollMap(SCROLL_LEFT);
             elf.x = 64;
             elf.y = 24;
             elf.facing = FACING_LEFT;
         }
         break;

     case FACING_RIGHT:
         if (elf.x < 80)
         {
             if (checkMapRoomMove(elf.x + 12, elf.y) == 0)
                 if (checkMapRoomMove(elf.x + 12, elf.y + 12) == 0) elf.x += STEP_LENGTH;
         } else {
             scrollMap(SCROLL_RIGHT);
             elf.x = 16;
             elf.y = 24;
             elf.facing = FACING_RIGHT;
         }
         break;
  }

  //draw new elf bitmap
  overlaybitmap(elf.x, elf.y, elf_bitmap + ( elf.facing * SIZEOF_ELF_RECORD));
  overlaybitmap(elf.x, elf.y+8, elf_bitmap + ((elf.facing + elf.step) * SIZEOF_ELF_RECORD));
}
Ejemplo n.º 4
0
RoomElement moveMonster(RoomElement element)
{
  //draw new monster bitmap
  if (element.state > STATE_HIDDEN)
  {
    //erase the old monster image (using blank map tile)
    TV.bitmap(element.x, element.y, map_bitmap);
    TV.bitmap(element.x, element.y + 8, map_bitmap);

    element.step++;
    if (element.step > 2) element.step = 1;

    switch (element.state)
    {
       case STATE_VISIBLE:
           element.state = changeMonsterDirection();
           break;

       case STATE_MOVE_UP:
           element.state = STATE_VISIBLE;
           if (element.y > 4)
           {
             if (checkMapRoomMove(element.x, element.y - 4) == 0)
             {
                if (checkMapRoomMove(element.x + 4, element.y - 4) == 0)
                {
                  element.y -= STEP_LENGTH;
                   element.state = STATE_MOVE_UP;
                }
             }
           }
           break;

       case STATE_MOVE_DOWN:
           element.state = STATE_VISIBLE;
           if (element.y < 48)
           {
             if (checkMapRoomMove(element.x, element.y + 16) == 0)
             {
                if (checkMapRoomMove(element.x + 4, element.y + 16) == 0)
                {
                  element.y += STEP_LENGTH;
                  element.state = STATE_MOVE_DOWN;
                }
             }
           }
           break;

       case STATE_MOVE_LEFT:
           element.state = STATE_VISIBLE;
           if (element.x > 4)
           {
             if (checkMapRoomMove(element.x - 4, element.y) == 0)
             {
                if (checkMapRoomMove(element.x - 4, element.y + 12) == 0)
                {
                    element.x -= STEP_LENGTH;
                    element.state = STATE_MOVE_LEFT;
                }
             }
           }
           break;

       case STATE_MOVE_RIGHT:
           element.state = STATE_VISIBLE;
           if (element.x < 80)
           {
             if (checkMapRoomMove(element.x + 12, element.y) == 0)
             {
                if (checkMapRoomMove(element.x + 12, element.y + 12) == 0)
                {
                  element.x += STEP_LENGTH;
                  element.state = STATE_MOVE_RIGHT;
                }
             }
           }
           break;
    }

    overlaybitmap(element.x, element.y, monster_bitmap + ( element.type * SIZEOF_MONSTER_RECORD));
    overlaybitmap(element.x, element.y+8, monster_bitmap + ((element.type + element.step) * SIZEOF_MONSTER_RECORD));

    //decrement counter, if active
    if (element.counter > 0) element.counter--;
  }
  return element;
}