Loading app/src/main/java/com/example/a8_bitinvader/GameView.java +6 −7 Original line number Diff line number Diff line Loading @@ -14,16 +14,13 @@ public class GameView extends SurfaceView implements Runnable{ private float screenRatioWidth, screenRatioHeight; private Background background1, background2; private Paint paint; Joystick joystick = new Joystick(450,1300,100,40); Player p1 = new Player(0,1000,5,0, getResources()); //undecided location Joystick joystick; Player p1; public GameView(Context context, int screenWidth, int screenHeight) { super(context); joystick = new Joystick(screenWidth/2,screenHeight*9/10,100,40); p1 = new Player(screenWidth/2,screenHeight*7/10,0,0, getResources()); this.screenWidth = screenWidth; this.screenHeight = screenHeight; Loading Loading @@ -74,6 +71,8 @@ public class GameView extends SurfaceView implements Runnable{ if(background2.yPos > screenHeight) { background2.yPos = -screenHeight; } p1.xVel = (int)joystick.XVelocity* p1.SPEEDMULTIPLIER; p1.yVel = (int)joystick.YVelocity* p1.SPEEDMULTIPLIER; p1.update(); joystick.update(joystick); } Loading app/src/main/java/com/example/a8_bitinvader/Player.java +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.util.Log; public class Player extends Sprite{ private int health = 3; public final int SPEEDMULTIPLIER = 5; public Player(int xPos, int yPos, int xVel, int yVel, Resources res) { super(xPos,yPos,xVel,yVel); Loading Loading
app/src/main/java/com/example/a8_bitinvader/GameView.java +6 −7 Original line number Diff line number Diff line Loading @@ -14,16 +14,13 @@ public class GameView extends SurfaceView implements Runnable{ private float screenRatioWidth, screenRatioHeight; private Background background1, background2; private Paint paint; Joystick joystick = new Joystick(450,1300,100,40); Player p1 = new Player(0,1000,5,0, getResources()); //undecided location Joystick joystick; Player p1; public GameView(Context context, int screenWidth, int screenHeight) { super(context); joystick = new Joystick(screenWidth/2,screenHeight*9/10,100,40); p1 = new Player(screenWidth/2,screenHeight*7/10,0,0, getResources()); this.screenWidth = screenWidth; this.screenHeight = screenHeight; Loading Loading @@ -74,6 +71,8 @@ public class GameView extends SurfaceView implements Runnable{ if(background2.yPos > screenHeight) { background2.yPos = -screenHeight; } p1.xVel = (int)joystick.XVelocity* p1.SPEEDMULTIPLIER; p1.yVel = (int)joystick.YVelocity* p1.SPEEDMULTIPLIER; p1.update(); joystick.update(joystick); } Loading
app/src/main/java/com/example/a8_bitinvader/Player.java +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.util.Log; public class Player extends Sprite{ private int health = 3; public final int SPEEDMULTIPLIER = 5; public Player(int xPos, int yPos, int xVel, int yVel, Resources res) { super(xPos,yPos,xVel,yVel); Loading