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.

tank.c 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "tank.h"
  2. void renderTank(unsigned int* framePointer) {
  3. short tankx, tanky;
  4. tankx = getTankPositionX();
  5. tanky = getTankPositionY();
  6. int row, col;
  7. for(row=0; row < 16; row++) {
  8. for(col=0; col < 32; col++) {
  9. if ((tank[row%16] & (1<<(32-1-col)))) {
  10. framePointer[tanky*640 + tankx] = 0x0000FF00;
  11. } else {
  12. framePointer[tanky*640 + tankx] = 0x00000000;
  13. }
  14. tankx++;
  15. }
  16. tankx=getTankPositionX();
  17. tanky++;
  18. }
  19. }
  20. void renderDying1(unsigned int* framePointer) {
  21. short tankx, tanky;
  22. tankx = getTankPositionX();
  23. tanky = getTankPositionY();
  24. int row, col;
  25. for(row=0; row < 16; row++) {
  26. for(col=0; col < 32; col++) {
  27. if ((tank_dying1[row%16] & (1<<(32-1-col)))) {
  28. framePointer[tanky*640 + tankx] = 0x0000FF00;
  29. } else {
  30. framePointer[tanky*640 + tankx] = 0x00000000;
  31. }
  32. tankx++;
  33. }
  34. tankx=getTankPositionX();
  35. tanky++;
  36. }
  37. }
  38. void renderDying2(unsigned int* framePointer) {
  39. short tankx, tanky;
  40. tankx = getTankPositionX();
  41. tanky = getTankPositionY();
  42. int row, col;
  43. for(row=0; row < 16; row++) {
  44. for(col=0; col < 32; col++) {
  45. if ((tank_dying2[row%16] & (1<<(32-1-col)))) {
  46. framePointer[tanky*640 + tankx] = 0x0000FF00;
  47. } else {
  48. framePointer[tanky*640 + tankx] = 0x00000000;
  49. }
  50. tankx++;
  51. }
  52. tankx=getTankPositionX();
  53. tanky++;
  54. }
  55. }
  56. void blankTank(unsigned int* framePointer) {
  57. short tankx, tanky;
  58. tankx = getTankPositionX();
  59. tanky = getTankPositionY();
  60. int row, col;
  61. for(row=0; row < 16; row++) {
  62. for(col=0; col < 32; col++) {
  63. framePointer[tanky*640 + tankx] = 0x00000000;
  64. tankx++;
  65. }
  66. tankx=getTankPositionX();
  67. tanky++;
  68. }
  69. }
  70. void moveTankL(unsigned int* framePointer) {
  71. short dir = getDirection();
  72. short tankx, tanky;
  73. tankx = getTankPositionX();
  74. tanky = getTankPositionY();
  75. if(tankx+32 == 638) {
  76. tankx -= 2;
  77. setTankPosition(tankx, tanky);
  78. }
  79. if(tankx == 4 || tankx+32 == 638) {
  80. }
  81. else {
  82. tankx -= 2;
  83. setTankPosition(tankx, tanky);
  84. }
  85. }
  86. void moveTankR(unsigned int* framePointer) {
  87. short dir = getDirection();
  88. short tankx, tanky;
  89. tankx = getTankPositionX();
  90. tanky = getTankPositionY();
  91. if(tankx == 0) {
  92. tankx += 2;
  93. setTankPosition(tankx, tanky);
  94. }
  95. if(tankx == 0 || tankx+32 == 638) {
  96. }
  97. else {
  98. tankx += 2;
  99. setTankPosition(tankx, tanky);
  100. }
  101. }