Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

global.c 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. #include "global.h"
  2. static point_t alienBlockPosition;
  3. static point_t tankPosition;
  4. static short alienDirection;
  5. static short guise = 0;
  6. static short guiseBullet = 0;
  7. static short aliens[55] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  8. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  9. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  10. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  11. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  12. static short bunker1[10] = {0,0,0,0,0,0,0,0,0,0};
  13. static short bunker2[10] = {0,0,0,0,0,0,0,0,0,0};
  14. static short bunker3[10] = {0,0,0,0,0,0,0,0,0,0};
  15. static short bunker4[10] = {0,0,0,0,0,0,0,0,0,0};
  16. static point_t tankBulletPosition;
  17. static point_t alienBulletPosition1;
  18. static point_t alienBulletPosition2;
  19. static point_t alienBulletPosition3;
  20. static point_t alienBulletPosition4;
  21. static short tankBullet = 0;
  22. static short alienBullet1 = 0;
  23. static short alienBullet2 = 0;
  24. static short alienBullet3 = 0;
  25. static short alienBullet4 = 0;
  26. static point_t ufoPosition;
  27. static short ufo_state = 0;
  28. static short ufo_left;
  29. short getUfoDirection(){
  30. return ufo_left;
  31. }
  32. short setUfoDirection(){
  33. ufo_left = rand()%2;
  34. }
  35. short getUfoPositionY() {
  36. return ufoPosition.y;
  37. }
  38. void setUfoPositionY(short update) {
  39. ufoPosition.y = update;
  40. }
  41. short getUfoPositionX() {
  42. return ufoPosition.x;
  43. }
  44. void setUfoPositionX(short update) {
  45. ufoPosition.x = update;
  46. }
  47. short getUfoState(){
  48. return ufo_state;
  49. }
  50. void setUfoState(short state){
  51. ufo_state = state;
  52. }
  53. unsigned short getGuiseBullet() {
  54. return guiseBullet;
  55. }
  56. void setGuiseBullet(unsigned short frame) {
  57. guiseBullet = frame;
  58. }
  59. // for tank bullet
  60. void setTankBulletState(short state) {
  61. tankBullet = state;
  62. }
  63. short getTankBulletState() {
  64. return tankBullet;
  65. }
  66. void initialTankBulletPosition() {
  67. tankBulletPosition.x = getTankPositionX()+11;
  68. tankBulletPosition.y = 410;
  69. }
  70. short getTankBulletPositionX() {
  71. return tankBulletPosition.x;
  72. }
  73. short getTankBulletPositionY() {
  74. return tankBulletPosition.y;
  75. }
  76. void setTankBulletPositionY(short update) {
  77. tankBulletPosition.y = update;
  78. }
  79. //for alien bullet1
  80. void setAlien1BulletState(short state) {
  81. alienBullet1 = state;
  82. }
  83. short getAlien1BulletState() {
  84. return alienBullet1;
  85. }
  86. short getAlien1BulletPositionX() {
  87. return alienBulletPosition1.x;
  88. }
  89. short getAlien1BulletPositionY() {
  90. return alienBulletPosition1.y;
  91. }
  92. void setAlien1BulletPositionY(short update) {
  93. alienBulletPosition1.y = update;
  94. }
  95. void setAlien1BulletPosition(short x, short y) {
  96. alienBulletPosition1.x = x;
  97. alienBulletPosition1.y = y;
  98. }
  99. //for alien bullet2
  100. void setAlien2BulletState(short state) {
  101. alienBullet2 = state;
  102. }
  103. short getAlien2BulletState() {
  104. return alienBullet2;
  105. }
  106. short getAlien2BulletPositionX() {
  107. return alienBulletPosition2.x;
  108. }
  109. short getAlien2BulletPositionY() {
  110. return alienBulletPosition2.y;
  111. }
  112. void setAlien2BulletPositionY(short update) {
  113. alienBulletPosition2.y = update;
  114. }
  115. void setAlien2BulletPosition(short x, short y) {
  116. alienBulletPosition2.x = x;
  117. alienBulletPosition2.y = y;
  118. }
  119. //for alien bullet3
  120. void setAlien3BulletState(short state) {
  121. alienBullet3 = state;
  122. }
  123. short getAlien3BulletState() {
  124. return alienBullet3;
  125. }
  126. short getAlien3BulletPositionX() {
  127. return alienBulletPosition3.x;
  128. }
  129. short getAlien3BulletPositionY() {
  130. return alienBulletPosition3.y;
  131. }
  132. void setAlien3BulletPositionY(short update) {
  133. alienBulletPosition3.y = update;
  134. }
  135. void setAlien3BulletPosition(short x, short y) {
  136. alienBulletPosition3.x = x;
  137. alienBulletPosition3.y = y;
  138. }
  139. //for alien bullet4
  140. void setAlien4BulletState(short state) {
  141. alienBullet4 = state;
  142. }
  143. short getAlien4BulletState() {
  144. return alienBullet4;
  145. }
  146. short getAlien4BulletPositionX() {
  147. return alienBulletPosition4.x;
  148. }
  149. short getAlien4BulletPositionY() {
  150. return alienBulletPosition4.y;
  151. }
  152. void setAlien4BulletPositionY(short update) {
  153. alienBulletPosition4.y = update;
  154. }
  155. void setAlien4BulletPosition(short x, short y) {
  156. alienBulletPosition4.x = x;
  157. alienBulletPosition4.y = y;
  158. }
  159. //for bunker
  160. short* getBunker1() {
  161. return bunker1;
  162. }
  163. void setBunker1(unsigned short state, unsigned short block) {
  164. bunker1[block] = state;
  165. }
  166. short* getBunker2() {
  167. return bunker2;
  168. }
  169. void setBunker2(unsigned short state, unsigned short block) {
  170. bunker2[block] = state;
  171. }
  172. short* getBunker3() {
  173. return bunker3;
  174. }
  175. void setBunker3(unsigned short state, unsigned short block) {
  176. bunker3[block] = state;
  177. }
  178. short* getBunker4() {
  179. return bunker4;
  180. }
  181. void setBunker4(unsigned short state, unsigned short block) {
  182. bunker1[block] = state;
  183. }
  184. // Here are the accessors.
  185. short* getAliens() {
  186. return aliens;
  187. }
  188. void setAliens(unsigned short alien, unsigned short position) {
  189. xil_printf("setting alien\r\n");
  190. aliens[position] = alien;
  191. }
  192. unsigned short getGuise() {
  193. return guise;
  194. }
  195. void setGuise(unsigned short frame) {
  196. guise = frame;
  197. }
  198. unsigned short getDirection() {
  199. return alienDirection;
  200. }
  201. void setDirection(unsigned short direction) {
  202. alienDirection = direction;
  203. }
  204. void setAlienBlockPosition(unsigned short x, unsigned short y) {
  205. alienBlockPosition.x = x;
  206. alienBlockPosition.y = y;
  207. }
  208. unsigned short getAlienBlockPositionX() {
  209. return alienBlockPosition.x;
  210. }
  211. unsigned short getAlienBlockPositionY() {
  212. return alienBlockPosition.y;
  213. }
  214. void setTankPosition(unsigned short x, unsigned short y) {
  215. tankPosition.x = x;
  216. tankPosition.y = y;
  217. }
  218. unsigned short getTankPositionX() {
  219. return tankPosition.x;
  220. }
  221. unsigned short getTankPositionY() {
  222. return tankPosition.y;
  223. }