Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <dos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <graphics.h>
- #include <math.h>
- #define WIDTH 640
- #define HEIGHT 480
- #define PLAYER_WIDTH 40
- #define PLAYER_HEIGHT 20
- #define INVADER_SIZE 30
- #define BULLET_SIZE 4
- #define SHIELD_WIDTH 60
- #define SHIELD_HEIGHT 30
- typedef struct {
- int x, y;
- int active;
- int speed;
- } Bullet;
- typedef struct {
- int x, y;
- int active;
- int type;
- int animFrame;
- } Invader;
- typedef struct {
- int x, y;
- int health;
- } Shield;
- int playerX;
- Bullet bullets[5];
- Bullet enemyBullets[10];
- Invader invaders[55];
- Shield shields[4];
- int score;
- int lives;
- int gameOver;
- int invadersDirection;
- int invadersMoveDelay;
- int gameSpeed;
- int enemyShootDelay;
- void setupGame();
- void drawGame();
- void updateGame();
- void handleInput();
- void drawPlayer();
- void drawInvaders();
- void drawInvader(int x, int y, int type, int frame);
- void drawShields();
- void drawBullets();
- void drawUI();
- void moveInvaders();
- void spawnBullet();
- void spawnEnemyBullet();
- void updateBullets();
- void checkCollisions();
- void gameOverScreen();
- void initGraphics();
- void closeGraphics();
- int main() {
- initGraphics();
- setupGame();
- while (!gameOver) {
- handleInput();
- updateGame();
- drawGame();
- delay(gameSpeed);
- }
- gameOverScreen();
- closeGraphics();
- return 0;
- }
- void initGraphics() {
- int gdriver = DETECT, gmode;
- initgraph(&gdriver, &gmode, "");
- if (graphresult() != grOk) {
- printf("Graphics error: %s\n", grapherrormsg(graphresult()));
- exit(1);
- }
- }
- void closeGraphics() {
- closegraph();
- }
- void setupGame() {
- int i, j, idx = 0;
- // €ЁжЁ «Ё§ жЁп ЁЈа®Є
- playerX = WIDTH / 2 - PLAYER_WIDTH / 2;
- // €ЁжЁ «Ё§ жЁп Їг«м ЁЈа®Є
- for (i = 0; i < 5; i++) {
- bullets[i].active = 0;
- bullets[i].speed = 8;
- }
- // €ЁжЁ «Ё§ жЁп Їг«м ўа Ј®ў
- for (i = 0; i < 10; i++) {
- enemyBullets[i].active = 0;
- enemyBullets[i].speed = 4;
- }
- // €ЁжЁ «Ё§ жЁп ЇаЁиҐ«м楢 (5 а冷ў Ї® 11)
- for (i = 0; i < 5; i++) {
- for (j = 0; j < 11; j++) {
- invaders[idx].x = 50 + j * 50;
- invaders[idx].y = 50 + i * 50;
- invaders[idx].active = 1;
- invaders[idx].type = i;
- invaders[idx].animFrame = 0;
- idx++;
- }
- }
- // €ЁжЁ «Ё§ жЁп йЁв®ў
- for (i = 0; i < 4; i++) {
- shields[i].x = 80 + i * 150;
- shields[i].y = 350;
- shields[i].health = 10;
- }
- // €ЁжЁ «Ё§ жЁп ЁЈа®ўле ЇҐаҐ¬Ґле
- score = 0;
- lives = 3;
- gameOver = 0;
- invadersDirection = 3;
- invadersMoveDelay = 0;
- enemyShootDelay = 0;
- gameSpeed = 16;
- }
- void drawGame() {
- cleardevice();
- drawUI();
- drawPlayer();
- drawInvaders();
- drawShields();
- drawBullets();
- }
- void updateGame() {
- moveInvaders();
- updateBullets();
- checkCollisions();
- // ‚а ¦ҐбЄ п бв५мЎ
- enemyShootDelay++;
- if (enemyShootDelay > 30) {
- spawnEnemyBullet();
- enemyShootDelay = 0;
- }
- int i=0;
- // ЂЁ¬ жЁп ЇаЁиҐ«м楢
- for (i = 0; i < 55; i++) {
- if (invaders[i].active) {
- invaders[i].animFrame = !invaders[i].animFrame;
- }
- }
- // Џа®ўҐаЄ § ўҐаиҐЁп ЁЈал
- if (lives <= 0) {
- gameOver = 1;
- }
- // Џа®ўҐаЄ Ї®ЎҐ¤л
- int invadersLeft = 0;
- for (i = 0; i < 55; i++) {
- if (invaders[i].active) {
- invadersLeft = 1;
- break;
- }
- }
- if (!invadersLeft) {
- gameOver = 1;
- }
- }
- void handleInput() {
- if (kbhit()) {
- char key = getch();
- switch (key) {
- case 'a':
- case 'A':
- case 75: // бв५Є ў«Ґў®
- if (playerX > 10) playerX -= 10;
- break;
- case 'd':
- case 'D':
- case 77: // бв५Є ўЇа ў®
- if (playerX < WIDTH - PLAYER_WIDTH - 10) playerX += 10;
- break;
- case ' ':
- spawnBullet();
- break;
- case 'q':
- case 'Q':
- gameOver = 1;
- break;
- case 0: // extended key
- key = getch(); // get extended code
- switch (key) {
- case 75: // left arrow
- if (playerX > 10) playerX -= 10;
- break;
- case 77: // right arrow
- if (playerX < WIDTH - PLAYER_WIDTH - 10) playerX += 10;
- break;
- }
- break;
- }
- }
- }
- void drawPlayer() {
- setcolor(LIGHTGREEN);
- setfillstyle(SOLID_FILL, LIGHTGREEN);
- // Ћб®ў п з бвм Є®а Ў«п
- bar(playerX, HEIGHT - 50, playerX + PLAYER_WIDTH, HEIGHT - 40);
- // ‚Ґаепп з бвм Є®а Ў«п
- bar(playerX + 10, HEIGHT - 60, playerX + PLAYER_WIDTH - 10, HEIGHT - 50);
- // Љ ЎЁ
- setcolor(YELLOW);
- setfillstyle(SOLID_FILL, YELLOW);
- bar(playerX + 15, HEIGHT - 65, playerX + PLAYER_WIDTH - 15, HEIGHT - 60);
- }
- void drawInvader(int x, int y, int type, int frame) {
- int color;
- switch (type) {
- case 0: color = LIGHTRED; break;
- case 1: color = LIGHTMAGENTA; break;
- case 2: color = YELLOW; break;
- case 3: color = LIGHTBLUE; break;
- case 4: color = LIGHTCYAN; break;
- }
- setcolor(color);
- setfillstyle(SOLID_FILL, color);
- if (frame == 0) {
- // ЏҐаўл© Є ¤а Ё¬ жЁЁ
- bar(x, y, x + INVADER_SIZE, y + 10);
- bar(x + 5, y + 10, x + INVADER_SIZE - 5, y + 20);
- bar(x, y + 20, x + INVADER_SIZE, y + 30);
- // ѓ« §
- setcolor(BLACK);
- setfillstyle(SOLID_FILL, BLACK);
- bar(x + 8, y + 8, x + 12, y + 12);
- bar(x + INVADER_SIZE - 12, y + 8, x + INVADER_SIZE - 8, y + 12);
- } else {
- // ‚в®а®© Є ¤а Ё¬ жЁЁ
- bar(x + 5, y, x + INVADER_SIZE - 5, y + 10);
- bar(x, y + 10, x + INVADER_SIZE, y + 20);
- bar(x + 5, y + 20, x + INVADER_SIZE - 5, y + 30);
- // ѓ« §
- setcolor(BLACK);
- setfillstyle(SOLID_FILL, BLACK);
- bar(x + 10, y + 8, x + 14, y + 12);
- bar(x + INVADER_SIZE - 14, y + 8, x + INVADER_SIZE - 10, y + 12);
- }
- }
- void drawInvaders() {
- for (int i = 0; i < 55; i++) {
- if (invaders[i].active) {
- drawInvader(invaders[i].x, invaders[i].y, invaders[i].type, invaders[i].animFrame);
- }
- }
- }
- void drawShields() {
- for (int i = 0; i < 4; i++) {
- if (shields[i].health > 0) {
- setcolor(LIGHTGREEN);
- setfillstyle(SOLID_FILL, LIGHTGREEN);
- // ђЁб㥬 йЁв б гзҐв®¬ §¤®а®ўмп
- int shieldWidth = SHIELD_WIDTH * shields[i].health / 10;
- int shieldHeight = SHIELD_HEIGHT * shields[i].health / 10;
- bar(shields[i].x, shields[i].y,
- shields[i].x + shieldWidth,
- shields[i].y + shieldHeight);
- }
- }
- }
- void drawBullets() {
- // Џг«Ё ЁЈа®Є
- setcolor(WHITE);
- setfillstyle(SOLID_FILL, WHITE);
- for (int i = 0; i < 5; i++) {
- if (bullets[i].active) {
- bar(bullets[i].x, bullets[i].y,
- bullets[i].x + BULLET_SIZE,
- bullets[i].y + BULLET_SIZE * 2);
- }
- }
- // Џг«Ё ўа Ј®ў
- setcolor(LIGHTRED);
- setfillstyle(SOLID_FILL, LIGHTRED);
- for (i = 0; i < 10; i++) {
- if (enemyBullets[i].active) {
- bar(enemyBullets[i].x, enemyBullets[i].y,
- enemyBullets[i].x + BULLET_SIZE,
- enemyBullets[i].y + BULLET_SIZE * 2);
- }
- }
- }
- void drawUI() {
- char scoreText[50];
- char livesText[50];
- setcolor(WHITE);
- settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
- // ‘зҐв
- sprintf(scoreText, "Score: %d", score);
- outtextxy(10, 10, scoreText);
- // †Ё§Ё
- sprintf(livesText, "Lives: %d", lives);
- outtextxy(WIDTH - 150, 10, livesText);
- // Ќ §ў ЁҐ ЁЈал
- settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
- outtextxy(WIDTH / 2 - 50, 10, "SPACE INVADERS");
- }
- void moveInvaders() {
- invadersMoveDelay++;
- if (invadersMoveDelay < 5) return;
- invadersMoveDelay = 0;
- int moveDown = 0;
- // Џа®ўҐа塞, 㦮 «Ё ¬Ґпвм Їа ў«ҐЁҐ
- for (int i = 0; i < 55; i++) {
- if (invaders[i].active) {
- if ((invaders[i].x <= 10 && invadersDirection < 0) ||
- (invaders[i].x >= WIDTH - INVADER_SIZE - 10 && invadersDirection > 0)) {
- moveDown = 1;
- break;
- }
- }
- }
- // „ўЁЈ Ґ¬ ЇаЁиҐ«м楢
- for (i = 0; i < 55; i++) {
- if (invaders[i].active) {
- if (moveDown) {
- invaders[i].y += 20;
- // Џа®ўҐаЄ ¤®бвЁ¦ҐЁп ЁЈа®Є
- if (invaders[i].y >= HEIGHT - 100) {
- gameOver = 1;
- }
- } else {
- invaders[i].x += invadersDirection;
- }
- }
- }
- if (moveDown) {
- invadersDirection = -invadersDirection;
- // “ўҐ«ЁзЁў Ґ¬ бЄ®а®бвм ЇаЁ бЇгбЄҐ
- if (invadersDirection > 0) invadersDirection++;
- else invadersDirection--;
- }
- }
- void spawnBullet() {
- // €йҐ¬ бў®Ў®¤го Їг«о
- for (int i = 0; i < 5; i++) {
- if (!bullets[i].active) {
- bullets[i].x = playerX + PLAYER_WIDTH / 2 - BULLET_SIZE / 2;
- bullets[i].y = HEIGHT - 60;
- bullets[i].active = 1;
- break;
- }
- }
- }
- void spawnEnemyBullet() {
- // ‚лЎЁа Ґ¬ б«гз ©®Ј® ЄвЁў®Ј® ЇаЁиҐ«мж ¤«п бв५мЎл
- int activeInvaders[55];
- int count = 0;
- for (int i = 0; i < 55; i++) {
- if (invaders[i].active) {
- activeInvaders[count++] = i;
- }
- }
- if (count > 0) {
- int randomInvader = activeInvaders[rand() % count];
- // €йҐ¬ бў®Ў®¤го ўа ¦ҐбЄго Їг«о
- for (int i = 0; i < 10; i++) {
- if (!enemyBullets[i].active) {
- enemyBullets[i].x = invaders[randomInvader].x + INVADER_SIZE / 2 - BULLET_SIZE / 2;
- enemyBullets[i].y = invaders[randomInvader].y + INVADER_SIZE;
- enemyBullets[i].active = 1;
- break;
- }
- }
- }
- }
- void updateBullets() {
- // Џг«Ё ЁЈа®Є
- for (int i = 0; i < 5; i++) {
- if (bullets[i].active) {
- bullets[i].y -= bullets[i].speed;
- // “¤ «пҐ¬ Їг«о, Ґб«Ё ® ўли« § нЄа
- if (bullets[i].y < 0) {
- bullets[i].active = 0;
- }
- }
- }
- // Џг«Ё ўа Ј®ў
- for (i = 0; i < 10; i++) {
- if (enemyBullets[i].active) {
- enemyBullets[i].y += enemyBullets[i].speed;
- // “¤ «пҐ¬ Їг«о, Ґб«Ё ® ўли« § нЄа
- if (enemyBullets[i].y > HEIGHT) {
- enemyBullets[i].active = 0;
- }
- }
- }
- }
- void checkCollisions() {
- // Џа®ўҐаЄ бв®«Є®ўҐЁ© Їг«м ЁЈа®Є б ЇаЁиҐ«мж ¬Ё
- for (int i = 0; i < 5; i++) {
- if (bullets[i].active) {
- for (int j = 0; j < 55; j++) {
- if (invaders[j].active) {
- if (bullets[i].x < invaders[j].x + INVADER_SIZE &&
- bullets[i].x + BULLET_SIZE > invaders[j].x &&
- bullets[i].y < invaders[j].y + INVADER_SIZE &&
- bullets[i].y + BULLET_SIZE * 2 > invaders[j].y) {
- bullets[i].active = 0;
- invaders[j].active = 0;
- score += (5 - invaders[j].type) * 10;
- break;
- }
- }
- }
- }
- }
- // Џа®ўҐаЄ бв®«Є®ўҐЁ© Їг«м ЁЈа®Є б® йЁв ¬Ё
- for (i = 0; i < 5; i++) {
- if (bullets[i].active) {
- for (int j = 0; j < 4; j++) {
- if (shields[j].health > 0) {
- if (bullets[i].x < shields[j].x + SHIELD_WIDTH &&
- bullets[i].x + BULLET_SIZE > shields[j].x &&
- bullets[i].y < shields[j].y + SHIELD_HEIGHT &&
- bullets[i].y + BULLET_SIZE * 2 > shields[j].y) {
- bullets[i].active = 0;
- shields[j].health -= 2;
- if (shields[j].health < 0) shields[j].health = 0;
- }
- }
- }
- }
- }
- // Џа®ўҐаЄ бв®«Є®ўҐЁ© Їг«м ўа Ј®ў б® йЁв ¬Ё
- for (i = 0; i < 10; i++) {
- if (enemyBullets[i].active) {
- for (int j = 0; j < 4; j++) {
- if (shields[j].health > 0) {
- if (enemyBullets[i].x < shields[j].x + SHIELD_WIDTH &&
- enemyBullets[i].x + BULLET_SIZE > shields[j].x &&
- enemyBullets[i].y < shields[j].y + SHIELD_HEIGHT &&
- enemyBullets[i].y + BULLET_SIZE * 2 > shields[j].y) {
- enemyBullets[i].active = 0;
- shields[j].health -= 2;
- if (shields[j].health < 0) shields[j].health = 0;
- }
- }
- }
- }
- }
- // Џа®ўҐаЄ бв®«Є®ўҐЁ© Їг«м ўа Ј®ў б ЁЈа®Є®¬
- for (i = 0; i < 10; i++) {
- if (enemyBullets[i].active) {
- if (enemyBullets[i].x < playerX + PLAYER_WIDTH &&
- enemyBullets[i].x + BULLET_SIZE > playerX &&
- enemyBullets[i].y < HEIGHT - 40 &&
- enemyBullets[i].y + BULLET_SIZE * 2 > HEIGHT - 50) {
- enemyBullets[i].active = 0;
- lives--;
- if (lives < 0) lives = 0;
- }
- }
- }
- }
- void gameOverScreen() {
- cleardevice();
- setcolor(LIGHTRED);
- settextstyle(DEFAULT_FONT, HORIZ_DIR, 4);
- outtextxy(WIDTH / 2 - 100, HEIGHT / 2 - 50, "GAME OVER");
- setcolor(WHITE);
- settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
- char scoreText[50];
- sprintf(scoreText, "Final Score: %d", score);
- outtextxy(WIDTH / 2 - 100, HEIGHT / 2, scoreText);
- outtextxy(WIDTH / 2 - 150, HEIGHT / 2 + 50, "Press any key to exit");
- getch();
- }
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=spseashnza
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment