Advertisement
Guest User

calculations.c

a guest
Dec 5th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. #include <3ds.h>
  2. #include <config.h>
  3. #include <initvariables.h>
  4. #include <sprites.h>
  5. #include <draw.h>
  6. #include <stdio.h>
  7. #include <text.h>
  8.  
  9. struct bullet{
  10.     int x;
  11.     int y;
  12.     int exist;
  13.     int type;
  14. };
  15.  
  16. struct tank{
  17.     int x;
  18.     int alive;
  19.     int shotsfired;
  20.     struct bullet shots[100];
  21. };
  22.  
  23. char read_bit(char var_byte,char position){
  24. return var_byte & 1 << position;
  25. };
  26.  
  27. int get_text_fullsize(){
  28. return font_width + font_spacing;
  29. };
  30.  
  31. int get_draw_start_x(alien_array_position){
  32.     if (draw_start_x[alien_layout[alien_array_position]] !=0){
  33.         return draw_start_x[alien_layout[alien_array_position]];
  34.     }
  35.     else{
  36.         int Remainder = screen_top_width % (invader_layout_width * entity_width[alien_Large_arraypos]);
  37.         Remainder /= 2;
  38.         return Remainder;
  39.     }
  40.     return 0;
  41. };
  42.  
  43. int get_draw_start_y(alien_array_position){
  44.     return invader_start_height[alien_layout[alien_array_position]];
  45. };
  46.  
  47. int get_alien_collision(struct bullet *bulletStruct,int anim){
  48.     int i = 0;
  49.     int x = 0;
  50.     int y = 0;
  51.     //for(i=0;i<invader_layout_width*invader_layout_height;i++){
  52.     for(i=0;i<20;i++){
  53.         if (alien_layout > 0){
  54.             int alienPPositiony = get_ypos(i);
  55.             sprintf(debuglines[i], "bulletStruct[%d] = %d" ,i,bulletStruct->x);
  56.             int alienPPositionx = get_xpos(i);
  57.             for(x = 0;x<invader_width[alien_layout[i]];x++){
  58.                 for(y = 0;y<invader_height[alien_layout[i]];y++){
  59.                     if (read_bit(alien_sprite[alien_layout[i]][anim][y],x) == 0){
  60.                         if ((bulletStruct->x = alienPPositionx + x)&&(bulletStruct->y = alienPPositiony + y)){
  61.                                 bulletStruct->x= 0;
  62.                                 bulletStruct->y= 0;
  63.                                 //alien_layout[i] = 0; //Play Death Animation
  64.                             return 1;
  65.                         }
  66.                     }
  67.                 }
  68.             }
  69.         }
  70.     }
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement