Commit a2f764b4 authored by Thomas Poimenidis's avatar Thomas Poimenidis
Browse files

fixed Player implementation

parent be9753b2
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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


@@ -72,7 +74,7 @@ public class GameView extends SurfaceView implements Runnable{
        if(background2.yPos > screenHeight) {
            background2.yPos = -screenHeight;
        }

        p1.updateLocation();
        joystick.update(joystick);
    }

@@ -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);
        }
+4 −5
Original line number Diff line number Diff line
@@ -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);
    }
+1 −1
Original line number Diff line number Diff line
@@ -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