Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Stage::render(Player *player, Teleporter *tele[], NPC *n, Enemy *enemy)
- {
- Object::render();
- for (int i = 0; i < HEIGHT / STAGEY; i++)
- {
- for (int j = 0; j < WIDTH / STAGEX; j++)
- {
- switch (map[i][j])
- {
- case 1:
- al_draw_bitmap_region(image, 1 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- case 2:
- al_draw_bitmap_region(image, 2 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- case 3:
- al_draw_bitmap_region(image, 3 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- case 9:
- al_draw_bitmap_region(image, 4 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- case 10:
- al_draw_bitmap_region(image, 5 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- case 4:
- n->setX(j * STAGEX);
- n->setY(i * STAGEY);
- break;
- case 5:
- if (n->isBlocked())
- {
- al_draw_scaled_bitmap(wall, 0, 0, 40, 90, j * STAGEX, i * STAGEY - 80, 40, 130, 0);
- }
- break;
- case 6:
- for (int k = 0; k < 3; k++)
- {
- if (!tele[k]->isLocked())
- {
- tele[k]->setX(j * STAGEX);
- tele[k]->setY(i * STAGEY);
- tele[k]->setLocked(true);
- break;
- }
- }
- break;
- case 7:
- if (!player->isLocked())
- {
- player->setLocked(true);
- player->setX(j * STAGEX);
- player->setY((i - 1) * STAGEY);
- }
- break;
- case 8:
- if (!enemy->isLocked())
- {
- enemy->setLocked(true);
- enemy->setX(j * STAGEX);
- enemy->setY((i - 1) * STAGEY);
- enemy->setStartX((j) * STAGEX);
- }
- break;
- case 11:
- al_draw_bitmap_region(image, 5 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- al_draw_bitmap(window, j * STAGEX + 7, i * STAGEY, 0);
- break;
- case 12:
- al_draw_bitmap_region(image, 5 * frameWidth - frameWidth, 0, frameWidth, frameHeight, j * frameWidth, i * frameHeight, 0);
- break;
- default:
- break;
- }
- if ((map[i][j] == 1) || (map[i][j] == 2) /*|| (map[i][j] == 3)*/ || (map[i][j] == 9) || (map[i][j] == 12))
- {
- if ((player->getY() + player->getBoundY() > i * STAGEY) && (player->getY() - player->getBoundY() + 50 < i * STAGEY + 40) &&
- (player->getX() + player->getBoundX() > j * STAGEX) && (player->getX() - player->getBoundX() < j * STAGEX + 40))
- {
- player->setY((i-2) * STAGEY);
- }
- if(boundBox)
- al_draw_filled_rectangle(j * STAGEX + 40, i * STAGEY + 40, j * STAGEX, i * STAGEY, al_map_rgba(255, 0, 255, 0.2));
- }
- if (map[i][j] == 3)
- {
- if ((player->getY() + player->getBoundY() > i * STAGEY) && (player->getY() - player->getBoundY() + 50 < i * STAGEY + 40) &&
- (player->getX() + player->getBoundX() > j * STAGEX) && (player->getX() - player->getBoundX() < j * STAGEX + 20))
- {
- int xo = 0;
- if (player->getX() - player->getBoundX()/2 > j * STAGEX + 15)
- {
- xo = 10;
- }
- if (player->getX() - player->getBoundX() / 2 > j * STAGEX + 25)
- {
- xo = 20;
- }
- if (player->getX() - player->getBoundX() / 2 > j * STAGEX + 35)
- {
- xo = 30;
- }
- player->setY((i - 2) * STAGEY + xo);
- }
- if (boundBox)
- al_draw_filled_rectangle(j * STAGEX + 40, i * STAGEY + 40, j * STAGEX , i * STAGEY, al_map_rgba(255, 0, 255, 0.2));
- }
- if (map[i][j] == 1)
- {
- if ((player->getY() + player->getBoundY() > i * STAGEY) && (player->getY() - player->getBoundY() + 50 < i * STAGEY + 40) &&
- (player->getX() + player->getBoundX() > j * STAGEX) && (player->getX() - player->getBoundX() < j * STAGEX + 40))
- {
- int xo = 0;
- if (player->getX() + player->getBoundX() < j * STAGEX + 35)
- {
- xo = 10;
- }
- if (player->getX() + player->getBoundX() < j * STAGEX + 25)
- {
- xo = 20;
- }
- if (player->getX() + player->getBoundX() < j * STAGEX + 15)
- {
- xo = 30;
- }
- player->setY((i - 2) * STAGEY + xo);
- }
- if (boundBox)
- al_draw_filled_rectangle(j * STAGEX + 40, i * STAGEY + 40, j * STAGEX, i * STAGEY, al_map_rgba(255, 0, 255, 0.2));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement