Loading app/src/main/java/com/example/a8_bitinvader/Enemy.java +4 −15 Original line number Diff line number Diff line package com.example.a8_bitinvader; public class Enemy extends Sprite{ int XVal,YVal; //initialize the Xval,Yval. and inital position public Enemy(int PosX, int PosY, int theXVal, int theYVal, int img ) { super(PosX,PosY); XVal = theXVal; YVal = theYVal; } //this updates the location of the sprite @Override public void updateLocation(){ xPos += XVal; yPos += YVal; public Enemy(int xPos, int yPos, int xVel, int yVel) { super(xPos, yPos, xVel, yVel); } // will shoot bullets public void shootBullets(){ @Override public void destroy() { //call the destroy functions, then delete this. } } app/src/main/java/com/example/a8_bitinvader/Player.java +3 −4 Original line number Diff line number Diff line Loading @@ -30,12 +30,11 @@ public class Player extends Sprite{ private Queue<Bullet> Bullets = new LinkedList<>(); // max on the screen at the same time, can be change ltr; public Player(Resources res) { super(0,0); super(0,0,0,0); xPos = screenWidth/2; //haven't implement it yet yPos = 9 * screenHeight/10; //haven't implement it yet playerImg = BitmapFactory.decodeResource(res, R.drawable.green64); playerImg = Bitmap.createScaledBitmap(playerImg, getSpriteWidth(), getSpriteHeight(), false); spriteImage = BitmapFactory.decodeResource(res, R.drawable.green64); spriteImage = Bitmap.createScaledBitmap(spriteImage, getSpriteWidth(), getSpriteHeight(), false); } //get input from the joystick, and change the location Loading app/src/main/java/com/example/a8_bitinvader/Sprite.java +12 −7 Original line number Diff line number Diff line Loading @@ -12,22 +12,25 @@ public class Sprite { int xPos, yPos; int xVel, yVel; int screenWidth, screenHeight; Bitmap image; Bitmap spriteImage; //private properties private final int spriteHeight = 64; private final int spriteWidth = 64; private final int spriteHeight = 64, spriteWidth = 64; //private properties /** * @param xPos * @param yPos * @param xPos initial x position of Sprite * @param yPos initial y position of Sprite * @param xVel initial x velocity of Sprite * @param yVel initial y velocity of Sprite */ public Sprite(int xPos, int yPos) public Sprite(int xPos, int yPos, int xVel, int yVel) { this.xPos = xPos; this.yPos = yPos; this.xVel = xVel; this.yVel = yVel; } /** Loading @@ -52,6 +55,7 @@ public class Sprite { * @param yy * @return True if xx and yy are in the current sprite */ // IMPLEMENT THIS LATER TO CHECK FOR COLLISION WITH PASSING BULLET OBJECTS public boolean checkForCollision(int xx, int yy) { //implement Loading @@ -67,7 +71,8 @@ public class Sprite { } public void updateLocation() { //other classes will override this function xPos += xVel; yPos += yVel; } } Loading
app/src/main/java/com/example/a8_bitinvader/Enemy.java +4 −15 Original line number Diff line number Diff line package com.example.a8_bitinvader; public class Enemy extends Sprite{ int XVal,YVal; //initialize the Xval,Yval. and inital position public Enemy(int PosX, int PosY, int theXVal, int theYVal, int img ) { super(PosX,PosY); XVal = theXVal; YVal = theYVal; } //this updates the location of the sprite @Override public void updateLocation(){ xPos += XVal; yPos += YVal; public Enemy(int xPos, int yPos, int xVel, int yVel) { super(xPos, yPos, xVel, yVel); } // will shoot bullets public void shootBullets(){ @Override public void destroy() { //call the destroy functions, then delete this. } }
app/src/main/java/com/example/a8_bitinvader/Player.java +3 −4 Original line number Diff line number Diff line Loading @@ -30,12 +30,11 @@ public class Player extends Sprite{ private Queue<Bullet> Bullets = new LinkedList<>(); // max on the screen at the same time, can be change ltr; public Player(Resources res) { super(0,0); super(0,0,0,0); xPos = screenWidth/2; //haven't implement it yet yPos = 9 * screenHeight/10; //haven't implement it yet playerImg = BitmapFactory.decodeResource(res, R.drawable.green64); playerImg = Bitmap.createScaledBitmap(playerImg, getSpriteWidth(), getSpriteHeight(), false); spriteImage = BitmapFactory.decodeResource(res, R.drawable.green64); spriteImage = Bitmap.createScaledBitmap(spriteImage, getSpriteWidth(), getSpriteHeight(), false); } //get input from the joystick, and change the location Loading
app/src/main/java/com/example/a8_bitinvader/Sprite.java +12 −7 Original line number Diff line number Diff line Loading @@ -12,22 +12,25 @@ public class Sprite { int xPos, yPos; int xVel, yVel; int screenWidth, screenHeight; Bitmap image; Bitmap spriteImage; //private properties private final int spriteHeight = 64; private final int spriteWidth = 64; private final int spriteHeight = 64, spriteWidth = 64; //private properties /** * @param xPos * @param yPos * @param xPos initial x position of Sprite * @param yPos initial y position of Sprite * @param xVel initial x velocity of Sprite * @param yVel initial y velocity of Sprite */ public Sprite(int xPos, int yPos) public Sprite(int xPos, int yPos, int xVel, int yVel) { this.xPos = xPos; this.yPos = yPos; this.xVel = xVel; this.yVel = yVel; } /** Loading @@ -52,6 +55,7 @@ public class Sprite { * @param yy * @return True if xx and yy are in the current sprite */ // IMPLEMENT THIS LATER TO CHECK FOR COLLISION WITH PASSING BULLET OBJECTS public boolean checkForCollision(int xx, int yy) { //implement Loading @@ -67,7 +71,8 @@ public class Sprite { } public void updateLocation() { //other classes will override this function xPos += xVel; yPos += yVel; } }