Advertisement
renix1

DDTank 65 angle perfect

Sep 4th, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5.  
  6.  
  7. bool isinarray(char *ch, char **arr, int size) {
  8.     for (int i=0; i<size; i++) {
  9.         if (ch[1] == arr[i][1])
  10.             return true;
  11.     }
  12.     return false;
  13. }
  14.  
  15. // sys args => (distance, windForce, directions)
  16. int main (int argc, char *argv[]) {
  17.     // variables
  18.     int distance = 0, angle = 65;
  19.     float windForce = 0.0;
  20.     float strength[21] = {13, 21, 26, 31.5, 37, 41, 44, 48.5, 53, 56,
  21.                             58, 61, 64, 67, 70, 73, 76, 79, 82, 85};
  22.     char *directions = " ";
  23.     char charDirection = ' ', windDirection = ' ';
  24.     // logic
  25.     if (argc == 4) {
  26.         distance = atoi(argv[1]);
  27.         windForce = atof(argv[2]);
  28.         directions = argv[3];
  29.         if ((distance >= 0) && (distance <= 20)) {
  30.             if (strlen(directions) == 3) {
  31.                 charDirection = directions[0];
  32.                 windDirection = directions[2];
  33.                 if (charDirection != windDirection)
  34.                     angle -= windForce / 0.5;
  35.                 else if (charDirection == windDirection)
  36.                     angle += windForce / 0.5;
  37.                 printf("%.1fF | %dA\n", strength[distance], angle);
  38.             } else
  39.                 printf("Sentido do personagem e/ou do vento nao detectado!\n");
  40.         } else
  41.             printf("Distancia fora do limite!\n");
  42.     } else {
  43.         if (isinarray("-h", argv, argc))
  44.             printf("Para usar o script é necessário os seguintes argumentos:\n\t(1) distancia\n\t(2) forca do vento\n\t(3) direcao_personagem,direcao_vento\n");
  45.         else
  46.             printf("Esse script requer argumentos\n");
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement