123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- #include "bullet.h"
-
- void renderBullet(unsigned int* framePointer) {
- if(getGuiseBullet() == 0) {
- setGuiseBullet(1);
- renderBullet1(framePointer);
- }else {
- setGuiseBullet(0);
- renderBullet2(framePointer);
- }
- }
-
- void renderBullet1(unsigned int* framePointer) {
- if(getTankBulletState() == 1) {
- short initial_x = getTankBulletPositionX();
- short initial_y = getTankBulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((tankBullet[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien1BulletState() == 1) {
- short initial_x = getAlien1BulletPositionX();
- short initial_y = getAlien1BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet1_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien2BulletState() == 1) {
- short initial_x = getAlien2BulletPositionX();
- short initial_y = getAlien2BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet2_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien3BulletState() == 1) {
- short initial_x = getAlien3BulletPositionX();
- short initial_y = getAlien3BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet3_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien4BulletState() == 1) {
- short initial_x = getAlien4BulletPositionX();
- short initial_y = getAlien4BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet1_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- }
-
- void renderBullet2(unsigned int* framePointer) {
- if(getTankBulletState() == 1) {
- short initial_x = getTankBulletPositionX();
- short initial_y = getTankBulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((tankBullet[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien1BulletState() == 1) {
- short initial_x = getAlien1BulletPositionX();
- short initial_y = getAlien1BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet1_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien2BulletState() == 1) {
- short initial_x = getAlien2BulletPositionX();
- short initial_y = getAlien2BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet2_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien3BulletState() == 1) {
- short initial_x = getAlien3BulletPositionX();
- short initial_y = getAlien3BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet3_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- if(getAlien4BulletState() == 1) {
- short initial_x = getAlien4BulletPositionX();
- short initial_y = getAlien4BulletPositionY();
- int x, y;
- for(x = 0; x < BLOCK_HEIGHT; x++) {
- for(y = 0; y < BLOCK_WIDTH; y++){
- if ((alienBullet1_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE;
- } else {
- framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000;
- }
- }
- }
- }
- }
-
- void blankTankBullet(unsigned int* framePointer){
- short tankx, tanky;
- tankx = getTankBulletPositionX();
- tanky = getTankBulletPositionY();
- short row=0, col=0;
- for(row = 0; row < BLOCK_HEIGHT; row++){
- for(col = 0; col < BLOCK_WIDTH; col++){
- framePointer[(tanky+row)*640 + tankx+col] = 0x00000000;
- }
- }
- }
-
- void blankAlienBullet(unsigned int* framePointer, short alienx, short alieny) {
- short row=0, col=0;
- for(row = 0; row < BLOCK_HEIGHT; row++){
- for(col = 0; col < BLOCK_WIDTH; col++){
- framePointer[(alieny+row)*640 + alienx+col] = 0x00000000;
- }
- }
- }
-
- void moveBullets(unsigned int* framePointer) {
- if(getTankBulletState() == 1) {
- if(getTankBulletPositionY() == 30) {
- blankTankBullet(framePointer);
- setTankBulletState(0);
- }
- else {
- setTankBulletPositionY(getTankBulletPositionY()-1);
- }
- }
- if(getAlien1BulletState() == 1) {
- if(getAlien1BulletPositionY() == 450) {
- blankAlienBullet(framePointer, getAlien1BulletPositionX(), getAlien1BulletPositionY());
- setAlien1BulletState(0);
- }
- else {
- setAlien1BulletPositionY(getAlien1BulletPositionY()+1);
- }
- }
- if(getAlien2BulletState() == 1) {
- if(getAlien2BulletPositionY() == 450) {
- blankAlienBullet(framePointer, getAlien2BulletPositionX(), getAlien2BulletPositionY());
- setAlien2BulletState(0);
- }
- else {
- setAlien2BulletPositionY(getAlien2BulletPositionY()+1);
- }
- }
- if(getAlien3BulletState() == 1) {
- if(getAlien3BulletPositionY() == 450) {
- blankAlienBullet(framePointer, getAlien3BulletPositionX(), getAlien3BulletPositionY());
- setAlien3BulletState(0);
- }
- else {
- setAlien3BulletPositionY(getAlien3BulletPositionY()+1);
- }
- }
- if(getAlien4BulletState() == 1) {
- if(getAlien4BulletPositionY() == 450) {
- blankAlienBullet(framePointer, getAlien4BulletPositionX(), getAlien4BulletPositionY());
- setAlien4BulletState(0);
- }
- else {
- setAlien4BulletPositionY(getAlien4BulletPositionY()+1);
- }
- }
- }
|