/TheElements/jni/app.c

http://thelements.googlecode.com/ · C · 128 lines · 60 code · 20 blank · 48 comment · 0 complexity · d8e702090e96a13581375aa84b34ca6e MD5 · raw file

  1. /*
  2. * app.c
  3. * -------------------------
  4. * Contains definitions for all of the global
  5. * variables used in the JNI part of the code.
  6. */
  7. //Include the global macros
  8. #include "macros.h"
  9. //Include the server functions
  10. #include "server.h"
  11. // The simple framework expects the application code to define these functions.
  12. void appInit();
  13. void appDeinit();
  14. void appRender();
  15. /* Value is non-zero when application is alive, and 0 when it is closing.
  16. * Defined by the application framework.
  17. */
  18. int gAppAlive;
  19. //Current element selected
  20. int celement = 0;
  21. //Current point during processing
  22. int cpoint = 0;
  23. //Play state
  24. int play = 1;
  25. //Size variable initialize it here so we don't have to do it in resetup and we can keep our brush size
  26. int size = 4;
  27. //Array for bitmap drawing
  28. unsigned char colors[TPixels*3]; // 3 bytes per pixel
  29. //Coordinates
  30. float x[TPoints];
  31. float y[TPoints];
  32. //Old coordinates (for collision resolving)
  33. short int oldx[TPoints];
  34. short int oldy[TPoints];
  35. //Velocities
  36. short int xvel[TPoints];
  37. short int yvel[TPoints];
  38. //Element type
  39. char element[TPoints];
  40. //Frozen state
  41. char frozen[TPoints];
  42. //Spawn type
  43. char spawn[TPoints];
  44. //RGB properties
  45. unsigned char red[TElements];
  46. unsigned char green[TElements];
  47. unsigned char blue[TElements];
  48. //Fall velocity property
  49. int fallvel[TElements];
  50. //Density property
  51. int density[TElements];
  52. //Solid property
  53. int solid[TElements];
  54. //Growing property
  55. int growing[TElements];
  56. //Condensing property
  57. int condensing[TElements];
  58. //Fire-like burning property
  59. int fireburn[TElements];
  60. //Explosiveness property
  61. int exploness[TElements];
  62. //Custom element collision data
  63. int colliseelement1[TCollision];
  64. //Collision matrix
  65. int collision[TElements][TElements];
  66. //Index set state
  67. int set[TPoints];
  68. //Index available state
  69. int avail[TPoints];
  70. //Location in avail array
  71. int loq;
  72. //Zoom value
  73. int screensize;
  74. //Gravity values
  75. float gravx;
  76. float gravy;
  77. //Accelerometer control state
  78. int accelcon;
  79. //Flipped state
  80. int flipped;
  81. //The extent of the screen (what area to draw in)
  82. int maxx;
  83. int maxy;
  84. char shouldClear = 0;
  85. // A map of all the coordinates on the screen
  86. int allcoords[WIDTH][HEIGHT];
  87. //Mouse positions
  88. int xm;
  89. int ym;
  90. //Old mouse positions
  91. int lmx;
  92. int lmy;
  93. //Finger down state
  94. int fd;
  95. //Buffer building variables
  96. char username[8];
  97. char password[8];
  98. char userlength;
  99. char passlength;
  100. char buffer[ 1/*3 + 1 + (2 * TPoints * 4) + 200*/];
  101. int bufferlength;
  102. //Error variable
  103. char* error;
  104. //Socket variables
  105. int sockfd; //The file descriptor for the socket
  106. int n; //Used in sending and recieving data
  107. struct sockaddr_in serv_addr; //The server address struct
  108. struct hostent *server; //Pointer to a hostent struct that is used to set up serv_addr