Loading app/src/main/java/com/example/a8_bitinvader/GameView.java +5 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ public class GameView extends SurfaceView implements Runnable{ private Paint paint; Joystick joystick = new Joystick(450,1300,100,40); Player p1 = new Player(0,0,0,0, getResources()); //undecided location Loading Loading @@ -72,7 +74,7 @@ public class GameView extends SurfaceView implements Runnable{ if(background2.yPos > screenHeight) { background2.yPos = -screenHeight; } p1.updateLocation(); joystick.update(joystick); } Loading @@ -84,8 +86,8 @@ public class GameView extends SurfaceView implements Runnable{ Canvas canvas = getHolder().lockCanvas(); canvas.drawBitmap(background1.background, background1.xPos, background1.yPos, paint); canvas.drawBitmap(background2.background, background2.xPos, background2.yPos, paint); Player p1 = new Player(getResources()); canvas.drawBitmap(p1.playerImg, p1.xPos, p1.yPos, paint); canvas.drawBitmap(p1.spriteImage, p1.xPos, p1.yPos, paint); joystick.draw(canvas); getHolder().unlockCanvasAndPost(canvas); } Loading app/src/main/java/com/example/a8_bitinvader/Player.java +4 −5 Original line number Diff line number Diff line Loading @@ -26,13 +26,12 @@ public class Player extends Sprite{ } private int health = 3; public Bitmap playerImg; 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,0,0); xPos = screenWidth/2; //haven't implement it yet yPos = 9 * screenHeight/10; //haven't implement it yet public Player(int xPos, int yPos, int xVel, int yVel, Resources res) { super(xPos,yPos,xVel,yVel); this.xPos = xPos; //haven't implement it yet this.yPos = yPos; //haven't implement it yet spriteImage = BitmapFactory.decodeResource(res, R.drawable.green64); spriteImage = Bitmap.createScaledBitmap(spriteImage, getSpriteWidth(), getSpriteHeight(), false); } Loading app/src/main/java/com/example/a8_bitinvader/Sprite.java +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ public class Sprite { Bitmap spriteImage; //private properties private final int spriteHeight = 64, spriteWidth = 64; private final int spriteHeight = 128, spriteWidth = 128; //private properties Loading Loading
app/src/main/java/com/example/a8_bitinvader/GameView.java +5 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ public class GameView extends SurfaceView implements Runnable{ private Paint paint; Joystick joystick = new Joystick(450,1300,100,40); Player p1 = new Player(0,0,0,0, getResources()); //undecided location Loading Loading @@ -72,7 +74,7 @@ public class GameView extends SurfaceView implements Runnable{ if(background2.yPos > screenHeight) { background2.yPos = -screenHeight; } p1.updateLocation(); joystick.update(joystick); } Loading @@ -84,8 +86,8 @@ public class GameView extends SurfaceView implements Runnable{ Canvas canvas = getHolder().lockCanvas(); canvas.drawBitmap(background1.background, background1.xPos, background1.yPos, paint); canvas.drawBitmap(background2.background, background2.xPos, background2.yPos, paint); Player p1 = new Player(getResources()); canvas.drawBitmap(p1.playerImg, p1.xPos, p1.yPos, paint); canvas.drawBitmap(p1.spriteImage, p1.xPos, p1.yPos, paint); joystick.draw(canvas); getHolder().unlockCanvasAndPost(canvas); } Loading
app/src/main/java/com/example/a8_bitinvader/Player.java +4 −5 Original line number Diff line number Diff line Loading @@ -26,13 +26,12 @@ public class Player extends Sprite{ } private int health = 3; public Bitmap playerImg; 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,0,0); xPos = screenWidth/2; //haven't implement it yet yPos = 9 * screenHeight/10; //haven't implement it yet public Player(int xPos, int yPos, int xVel, int yVel, Resources res) { super(xPos,yPos,xVel,yVel); this.xPos = xPos; //haven't implement it yet this.yPos = yPos; //haven't implement it yet spriteImage = BitmapFactory.decodeResource(res, R.drawable.green64); spriteImage = Bitmap.createScaledBitmap(spriteImage, getSpriteWidth(), getSpriteHeight(), false); } Loading
app/src/main/java/com/example/a8_bitinvader/Sprite.java +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ public class Sprite { Bitmap spriteImage; //private properties private final int spriteHeight = 64, spriteWidth = 64; private final int spriteHeight = 128, spriteWidth = 128; //private properties Loading