Guest User

Космические захватчики

a guest
May 30th, 2026
116
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 15.49 KB | Source Code | 0 0
  1. #include <conio.h>
  2. #include <dos.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <graphics.h>
  6. #include <math.h>
  7.  
  8. #define WIDTH 640
  9. #define HEIGHT 480
  10. #define PLAYER_WIDTH 40
  11. #define PLAYER_HEIGHT 20
  12. #define INVADER_SIZE 30
  13. #define BULLET_SIZE 4
  14. #define SHIELD_WIDTH 60
  15. #define SHIELD_HEIGHT 30
  16.  
  17. typedef struct {
  18.     int x, y;
  19.     int active;
  20.     int speed;
  21. } Bullet;
  22.  
  23. typedef struct {
  24.     int x, y;
  25.     int active;
  26.     int type;
  27.     int animFrame;
  28. } Invader;
  29.  
  30. typedef struct {
  31.     int x, y;
  32.     int health;
  33. } Shield;
  34.  
  35. int playerX;
  36. Bullet bullets[5];
  37. Bullet enemyBullets[10];
  38. Invader invaders[55];
  39. Shield shields[4];
  40. int score;
  41. int lives;
  42. int gameOver;
  43. int invadersDirection;
  44. int invadersMoveDelay;
  45. int gameSpeed;
  46. int enemyShootDelay;
  47.  
  48. void setupGame();
  49. void drawGame();
  50. void updateGame();
  51. void handleInput();
  52. void drawPlayer();
  53. void drawInvaders();
  54. void drawInvader(int x, int y, int type, int frame);
  55. void drawShields();
  56. void drawBullets();
  57. void drawUI();
  58. void moveInvaders();
  59. void spawnBullet();
  60. void spawnEnemyBullet();
  61. void updateBullets();
  62. void checkCollisions();
  63. void gameOverScreen();
  64. void initGraphics();
  65. void closeGraphics();
  66.  
  67. int main() {
  68.     initGraphics();
  69.     setupGame();
  70.    
  71.     while (!gameOver) {
  72.         handleInput();
  73.         updateGame();
  74.         drawGame();
  75.         delay(gameSpeed);
  76.     }
  77.    
  78.     gameOverScreen();
  79.     closeGraphics();
  80.     return 0;
  81. }
  82.  
  83. void initGraphics() {
  84.     int gdriver = DETECT, gmode;
  85.     initgraph(&gdriver, &gmode, "");
  86.    
  87.     if (graphresult() != grOk) {
  88.         printf("Graphics error: %s\n", grapherrormsg(graphresult()));
  89.         exit(1);
  90.     }
  91. }
  92.  
  93. void closeGraphics() {
  94.     closegraph();
  95. }
  96.  
  97. void setupGame() {
  98.     int i, j, idx = 0;
  99.    
  100.     // €­ЁжЁ «Ё§ жЁп ЁЈа®Є 
  101.     playerX = WIDTH / 2 - PLAYER_WIDTH / 2;
  102.    
  103.     // €­ЁжЁ «Ё§ жЁп Їг«м ЁЈа®Є 
  104.     for (i = 0; i < 5; i++) {
  105.         bullets[i].active = 0;
  106.         bullets[i].speed = 8;
  107.     }
  108.    
  109.     // €­ЁжЁ «Ё§ жЁп Їг«м ўа Ј®ў
  110.     for (i = 0; i < 10; i++) {
  111.         enemyBullets[i].active = 0;
  112.         enemyBullets[i].speed = 4;
  113.     }
  114.    
  115.     // €­ЁжЁ «Ё§ жЁп ЇаЁиҐ«м楢 (5 а冷ў Ї® 11)
  116.     for (i = 0; i < 5; i++) {
  117.         for (j = 0; j < 11; j++) {
  118.             invaders[idx].x = 50 + j * 50;
  119.             invaders[idx].y = 50 + i * 50;
  120.             invaders[idx].active = 1;
  121.             invaders[idx].type = i;
  122.             invaders[idx].animFrame = 0;
  123.             idx++;
  124.         }
  125.     }
  126.    
  127.     // €­ЁжЁ «Ё§ жЁп йЁв®ў
  128.     for (i = 0; i < 4; i++) {
  129.         shields[i].x = 80 + i * 150;
  130.         shields[i].y = 350;
  131.         shields[i].health = 10;
  132.     }
  133.    
  134.     // €­ЁжЁ «Ё§ жЁп ЁЈа®ўле ЇҐаҐ¬Ґ­­ле
  135.     score = 0;
  136.     lives = 3;
  137.     gameOver = 0;
  138.     invadersDirection = 3;
  139.     invadersMoveDelay = 0;
  140.     enemyShootDelay = 0;
  141.     gameSpeed = 16;
  142. }
  143.  
  144. void drawGame() {
  145.     cleardevice();
  146.     drawUI();
  147.     drawPlayer();
  148.     drawInvaders();
  149.     drawShields();
  150.     drawBullets();
  151. }
  152.  
  153. void updateGame() {
  154.     moveInvaders();
  155.     updateBullets();
  156.     checkCollisions();
  157.  
  158.     // ‚а ¦ҐбЄ п бв५졠
  159.     enemyShootDelay++;
  160.     if (enemyShootDelay > 30) {
  161.     spawnEnemyBullet();
  162.     enemyShootDelay = 0;
  163.     }
  164.     int i=0;
  165.  
  166.     // Ђ­Ё¬ жЁп ЇаЁиҐ«м楢
  167.     for (i = 0; i < 55; i++) {
  168.     if (invaders[i].active) {
  169.         invaders[i].animFrame = !invaders[i].animFrame;
  170.     }
  171.     }
  172.  
  173.     // Џа®ўҐаЄ  § ўҐа襭Ёп ЁЈал
  174.     if (lives <= 0) {
  175.     gameOver = 1;
  176.     }
  177.  
  178.     // Џа®ўҐаЄ  Ї®ЎҐ¤л
  179.     int invadersLeft = 0;
  180.     for (i = 0; i < 55; i++) {
  181.         if (invaders[i].active) {
  182.             invadersLeft = 1;
  183.             break;
  184.         }
  185.     }
  186.     if (!invadersLeft) {
  187.         gameOver = 1;
  188.     }
  189. }
  190.  
  191. void handleInput() {
  192.     if (kbhit()) {
  193.         char key = getch();
  194.        
  195.         switch (key) {
  196.             case 'a':
  197.             case 'A':
  198.             case 75: // бв५Є  ў«Ґў®
  199.                 if (playerX > 10) playerX -= 10;
  200.                 break;
  201.                
  202.             case 'd':
  203.             case 'D':
  204.             case 77: // бв५Є  ўЇа ў®
  205.                 if (playerX < WIDTH - PLAYER_WIDTH - 10) playerX += 10;
  206.                 break;
  207.                
  208.             case ' ':
  209.                 spawnBullet();
  210.                 break;
  211.                
  212.             case 'q':
  213.             case 'Q':
  214.                 gameOver = 1;
  215.                 break;
  216.                
  217.             case 0: // extended key
  218.                 key = getch(); // get extended code
  219.                 switch (key) {
  220.                     case 75: // left arrow
  221.                         if (playerX > 10) playerX -= 10;
  222.                         break;
  223.                     case 77: // right arrow
  224.                         if (playerX < WIDTH - PLAYER_WIDTH - 10) playerX += 10;
  225.                         break;
  226.                 }
  227.                 break;
  228.         }
  229.     }
  230. }
  231.  
  232. void drawPlayer() {
  233.     setcolor(LIGHTGREEN);
  234.     setfillstyle(SOLID_FILL, LIGHTGREEN);
  235.    
  236.     // Ћб­®ў­ п з бвм Є®а Ў«п
  237.     bar(playerX, HEIGHT - 50, playerX + PLAYER_WIDTH, HEIGHT - 40);
  238.    
  239.     // ‚Ґае­пп з бвм Є®а Ў«п
  240.     bar(playerX + 10, HEIGHT - 60, playerX + PLAYER_WIDTH - 10, HEIGHT - 50);
  241.    
  242.     // Љ ЎЁ­ 
  243.     setcolor(YELLOW);
  244.     setfillstyle(SOLID_FILL, YELLOW);
  245.     bar(playerX + 15, HEIGHT - 65, playerX + PLAYER_WIDTH - 15, HEIGHT - 60);
  246. }
  247.  
  248. void drawInvader(int x, int y, int type, int frame) {
  249.     int color;
  250.    
  251.     switch (type) {
  252.         case 0: color = LIGHTRED; break;
  253.         case 1: color = LIGHTMAGENTA; break;
  254.         case 2: color = YELLOW; break;
  255.         case 3: color = LIGHTBLUE; break;
  256.         case 4: color = LIGHTCYAN; break;
  257.     }
  258.    
  259.     setcolor(color);
  260.     setfillstyle(SOLID_FILL, color);
  261.    
  262.     if (frame == 0) {
  263.         // ЏҐаўл© Є ¤а  ­Ё¬ жЁЁ
  264.         bar(x, y, x + INVADER_SIZE, y + 10);
  265.         bar(x + 5, y + 10, x + INVADER_SIZE - 5, y + 20);
  266.         bar(x, y + 20, x + INVADER_SIZE, y + 30);
  267.        
  268.         // ѓ« § 
  269.         setcolor(BLACK);
  270.         setfillstyle(SOLID_FILL, BLACK);
  271.         bar(x + 8, y + 8, x + 12, y + 12);
  272.         bar(x + INVADER_SIZE - 12, y + 8, x + INVADER_SIZE - 8, y + 12);
  273.     } else {
  274.         // ‚в®а®© Є ¤а  ­Ё¬ жЁЁ
  275.         bar(x + 5, y, x + INVADER_SIZE - 5, y + 10);
  276.         bar(x, y + 10, x + INVADER_SIZE, y + 20);
  277.         bar(x + 5, y + 20, x + INVADER_SIZE - 5, y + 30);
  278.        
  279.         // ѓ« § 
  280.         setcolor(BLACK);
  281.         setfillstyle(SOLID_FILL, BLACK);
  282.         bar(x + 10, y + 8, x + 14, y + 12);
  283.         bar(x + INVADER_SIZE - 14, y + 8, x + INVADER_SIZE - 10, y + 12);
  284.     }
  285. }
  286.  
  287. void drawInvaders() {
  288.     for (int i = 0; i < 55; i++) {
  289.         if (invaders[i].active) {
  290.             drawInvader(invaders[i].x, invaders[i].y, invaders[i].type, invaders[i].animFrame);
  291.         }
  292.     }
  293. }
  294.  
  295. void drawShields() {
  296.     for (int i = 0; i < 4; i++) {
  297.         if (shields[i].health > 0) {
  298.             setcolor(LIGHTGREEN);
  299.             setfillstyle(SOLID_FILL, LIGHTGREEN);
  300.            
  301.             // ђЁб㥬 йЁв б гзҐв®¬ §¤®а®ўмп
  302.             int shieldWidth = SHIELD_WIDTH * shields[i].health / 10;
  303.             int shieldHeight = SHIELD_HEIGHT * shields[i].health / 10;
  304.            
  305.             bar(shields[i].x, shields[i].y,
  306.                 shields[i].x + shieldWidth,
  307.                 shields[i].y + shieldHeight);
  308.         }
  309.     }
  310. }
  311.  
  312. void drawBullets() {
  313.     // Џг«Ё ЁЈа®Є 
  314.     setcolor(WHITE);
  315.     setfillstyle(SOLID_FILL, WHITE);
  316.     for (int i = 0; i < 5; i++) {
  317.         if (bullets[i].active) {
  318.             bar(bullets[i].x, bullets[i].y,
  319.                 bullets[i].x + BULLET_SIZE,
  320.                 bullets[i].y + BULLET_SIZE * 2);
  321.         }
  322.     }
  323.    
  324.     // Џг«Ё ўа Ј®ў
  325.     setcolor(LIGHTRED);
  326.     setfillstyle(SOLID_FILL, LIGHTRED);
  327.     for (i = 0; i < 10; i++) {
  328.         if (enemyBullets[i].active) {
  329.             bar(enemyBullets[i].x, enemyBullets[i].y,
  330.                 enemyBullets[i].x + BULLET_SIZE,
  331.                 enemyBullets[i].y + BULLET_SIZE * 2);
  332.         }
  333.     }
  334. }
  335.  
  336. void drawUI() {
  337.     char scoreText[50];
  338.     char livesText[50];
  339.    
  340.     setcolor(WHITE);
  341.     settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
  342.    
  343.     // ‘зҐв
  344.     sprintf(scoreText, "Score: %d", score);
  345.     outtextxy(10, 10, scoreText);
  346.    
  347.     // †Ё§­Ё
  348.     sprintf(livesText, "Lives: %d", lives);
  349.     outtextxy(WIDTH - 150, 10, livesText);
  350.    
  351.     // Ќ §ў ­ЁҐ ЁЈал
  352.     settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
  353.     outtextxy(WIDTH / 2 - 50, 10, "SPACE INVADERS");
  354. }
  355.  
  356. void moveInvaders() {
  357.     invadersMoveDelay++;
  358.     if (invadersMoveDelay < 5) return;
  359.     invadersMoveDelay = 0;
  360.    
  361.     int moveDown = 0;
  362.    
  363.     // Џа®ўҐа塞, ­г¦­® «Ё ¬Ґ­пвм ­ Їа ў«Ґ­ЁҐ
  364.     for (int i = 0; i < 55; i++) {
  365.         if (invaders[i].active) {
  366.             if ((invaders[i].x <= 10 && invadersDirection < 0) ||
  367.                 (invaders[i].x >= WIDTH - INVADER_SIZE - 10 && invadersDirection > 0)) {
  368.                 moveDown = 1;
  369.                 break;
  370.             }
  371.         }
  372.     }
  373.    
  374.     // „ўЁЈ Ґ¬ ЇаЁиҐ«м楢
  375.     for (i = 0; i < 55; i++) {
  376.         if (invaders[i].active) {
  377.             if (moveDown) {
  378.                 invaders[i].y += 20;
  379.                 // Џа®ўҐаЄ  ¤®бвЁ¦Ґ­Ёп ЁЈа®Є 
  380.                 if (invaders[i].y >= HEIGHT - 100) {
  381.                     gameOver = 1;
  382.                 }
  383.             } else {
  384.                 invaders[i].x += invadersDirection;
  385.             }
  386.         }
  387.     }
  388.    
  389.     if (moveDown) {
  390.         invadersDirection = -invadersDirection;
  391.         // “ўҐ«ЁзЁў Ґ¬ бЄ®а®бвм ЇаЁ бЇгбЄҐ
  392.         if (invadersDirection > 0) invadersDirection++;
  393.         else invadersDirection--;
  394.     }
  395. }
  396.  
  397. void spawnBullet() {
  398.     // €йҐ¬ бў®Ў®¤­го Їг«о
  399.     for (int i = 0; i < 5; i++) {
  400.         if (!bullets[i].active) {
  401.             bullets[i].x = playerX + PLAYER_WIDTH / 2 - BULLET_SIZE / 2;
  402.             bullets[i].y = HEIGHT - 60;
  403.             bullets[i].active = 1;
  404.             break;
  405.         }
  406.     }
  407. }
  408.  
  409. void spawnEnemyBullet() {
  410.     // ‚лЎЁа Ґ¬ б«гз ©­®Ј®  ЄвЁў­®Ј® ЇаЁиҐ«мж  ¤«п бв५мЎл
  411.     int activeInvaders[55];
  412.     int count = 0;
  413.    
  414.     for (int i = 0; i < 55; i++) {
  415.         if (invaders[i].active) {
  416.             activeInvaders[count++] = i;
  417.         }
  418.     }
  419.    
  420.     if (count > 0) {
  421.         int randomInvader = activeInvaders[rand() % count];
  422.        
  423.         // €йҐ¬ бў®Ў®¤­го ўа ¦ҐбЄго Їг«о
  424.         for (int i = 0; i < 10; i++) {
  425.             if (!enemyBullets[i].active) {
  426.                 enemyBullets[i].x = invaders[randomInvader].x + INVADER_SIZE / 2 - BULLET_SIZE / 2;
  427.                 enemyBullets[i].y = invaders[randomInvader].y + INVADER_SIZE;
  428.                 enemyBullets[i].active = 1;
  429.                 break;
  430.             }
  431.         }
  432.     }
  433. }
  434.  
  435. void updateBullets() {
  436.     // Џг«Ё ЁЈа®Є 
  437.     for (int i = 0; i < 5; i++) {
  438.         if (bullets[i].active) {
  439.             bullets[i].y -= bullets[i].speed;
  440.            
  441.             // “¤ «пҐ¬ Їг«о, Ґб«Ё ®­  ўли«  §  нЄа ­
  442.             if (bullets[i].y < 0) {
  443.                 bullets[i].active = 0;
  444.             }
  445.         }
  446.     }
  447.    
  448.     // Џг«Ё ўа Ј®ў
  449.     for (i = 0; i < 10; i++) {
  450.         if (enemyBullets[i].active) {
  451.             enemyBullets[i].y += enemyBullets[i].speed;
  452.            
  453.             // “¤ «пҐ¬ Їг«о, Ґб«Ё ®­  ўли«  §  нЄа ­
  454.             if (enemyBullets[i].y > HEIGHT) {
  455.                 enemyBullets[i].active = 0;
  456.             }
  457.         }
  458.     }
  459. }
  460.  
  461. void checkCollisions() {
  462.     // Џа®ўҐаЄ  бв®«Є­®ўҐ­Ё© Їг«м ЁЈа®Є  б ЇаЁиҐ«мж ¬Ё
  463.     for (int i = 0; i < 5; i++) {
  464.         if (bullets[i].active) {
  465.             for (int j = 0; j < 55; j++) {
  466.                 if (invaders[j].active) {
  467.                     if (bullets[i].x < invaders[j].x + INVADER_SIZE &&
  468.                         bullets[i].x + BULLET_SIZE > invaders[j].x &&
  469.                         bullets[i].y < invaders[j].y + INVADER_SIZE &&
  470.                         bullets[i].y + BULLET_SIZE * 2 > invaders[j].y) {
  471.                        
  472.                         bullets[i].active = 0;
  473.                         invaders[j].active = 0;
  474.                         score += (5 - invaders[j].type) * 10;
  475.                         break;
  476.                     }
  477.                 }
  478.             }
  479.         }
  480.     }
  481.    
  482.     // Џа®ўҐаЄ  бв®«Є­®ўҐ­Ё© Їг«м ЁЈа®Є  б® йЁв ¬Ё
  483.     for (i = 0; i < 5; i++) {
  484.         if (bullets[i].active) {
  485.             for (int j = 0; j < 4; j++) {
  486.                 if (shields[j].health > 0) {
  487.                     if (bullets[i].x < shields[j].x + SHIELD_WIDTH &&
  488.                         bullets[i].x + BULLET_SIZE > shields[j].x &&
  489.                         bullets[i].y < shields[j].y + SHIELD_HEIGHT &&
  490.                         bullets[i].y + BULLET_SIZE * 2 > shields[j].y) {
  491.                        
  492.                         bullets[i].active = 0;
  493.                         shields[j].health -= 2;
  494.                         if (shields[j].health < 0) shields[j].health = 0;
  495.                     }
  496.                 }
  497.             }
  498.         }
  499.     }
  500.    
  501.     // Џа®ўҐаЄ  бв®«Є­®ўҐ­Ё© Їг«м ўа Ј®ў б® йЁв ¬Ё
  502.     for (i = 0; i < 10; i++) {
  503.         if (enemyBullets[i].active) {
  504.             for (int j = 0; j < 4; j++) {
  505.                 if (shields[j].health > 0) {
  506.                     if (enemyBullets[i].x < shields[j].x + SHIELD_WIDTH &&
  507.                         enemyBullets[i].x + BULLET_SIZE > shields[j].x &&
  508.                         enemyBullets[i].y < shields[j].y + SHIELD_HEIGHT &&
  509.                         enemyBullets[i].y + BULLET_SIZE * 2 > shields[j].y) {
  510.                        
  511.                         enemyBullets[i].active = 0;
  512.                         shields[j].health -= 2;
  513.                         if (shields[j].health < 0) shields[j].health = 0;
  514.                     }
  515.                 }
  516.             }
  517.         }
  518.     }
  519.    
  520.     // Џа®ўҐаЄ  бв®«Є­®ўҐ­Ё© Їг«м ўа Ј®ў б ЁЈа®Є®¬
  521.     for (i = 0; i < 10; i++) {
  522.         if (enemyBullets[i].active) {
  523.             if (enemyBullets[i].x < playerX + PLAYER_WIDTH &&
  524.                 enemyBullets[i].x + BULLET_SIZE > playerX &&
  525.                 enemyBullets[i].y < HEIGHT - 40 &&
  526.                 enemyBullets[i].y + BULLET_SIZE * 2 > HEIGHT - 50) {
  527.                
  528.                 enemyBullets[i].active = 0;
  529.                 lives--;
  530.                 if (lives < 0) lives = 0;
  531.             }
  532.         }
  533.     }
  534. }
  535.  
  536. void gameOverScreen() {
  537.     cleardevice();
  538.    
  539.     setcolor(LIGHTRED);
  540.     settextstyle(DEFAULT_FONT, HORIZ_DIR, 4);
  541.     outtextxy(WIDTH / 2 - 100, HEIGHT / 2 - 50, "GAME OVER");
  542.    
  543.     setcolor(WHITE);
  544.     settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
  545.    
  546.     char scoreText[50];
  547.     sprintf(scoreText, "Final Score: %d", score);
  548.     outtextxy(WIDTH / 2 - 100, HEIGHT / 2, scoreText);
  549.    
  550.     outtextxy(WIDTH / 2 - 150, HEIGHT / 2 + 50, "Press any key to exit");
  551.    
  552.     getch();
  553. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Dunsunal
    26 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Arddikyk
    2 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=spseashnza
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment