Commit 690797de authored by Jiawei  Xiang's avatar Jiawei Xiang
Browse files

fixed update function. and when you run the app, you will see a functioning joystick

parent 9450e6db
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ public class GameView extends SurfaceView implements Runnable{
    private Background background1, background2;
    private Paint paint;

    Joystick joystick = new Joystick(0,0,0,0);
    Joystick joystick = new Joystick(450,1300,100,40);
    //undecided location


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

        joystick.update(joystick);
    }

    /*
@@ -82,7 +84,7 @@ 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);

            joystick.draw(canvas);
            getHolder().unlockCanvasAndPost(canvas);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class Joystick {
    public void update(Joystick joystick) {
        XVelocity = joystick.getActuatorX() * MAX_SPEED;
        YVelocity = joystick.getActuatorY() * MAX_SPEED;

        updateInnerCirclePosition();
    }

    public void updateInnerCirclePosition() {