package haiherdev.boxingdayblitz.object.Entity;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;

import haiherdev.boxingdayblitz.object.GameObject;
import haiherdev.boxingdayblitz.object.vector.Vector2z;
import haiherdev.boxingdayblitz.object.vector.Vector4z;

/**
 * Created by David on 2/11/2015.
 */
public class Player extends GameObject {

    private Vector4z v4z;

    //damaged state
    private boolean isDamaged;

    //how long ago was the character damaged?
    private int damagedTime;

    //the time it takes to get out of damage cycle
    private final int DAMAGE_TIME = 1000;


    /**
     * Constructor
     * @param v4z: contains x, y, width and height of character
     *           x and y can be changed in the future
     */
    public Player (Vector4z v4z) {
        this.v4z = v4z;
    }

    @Override
    public void render(Canvas c) {
        Paint p = new Paint();
        p.setColor(Color.RED);
        c.drawRect(v4z.getX(), v4z.getY(), v4z.getWidth(), v4z.getHeight(), p);
    }

    @Override
    public void update() {

        //count damage time when hit after being hit by an object
        if (isDamaged) {
            if (damagedTime < DAMAGE_TIME)
                damagedTime ++;
            else
                isDamaged = false;
        }
    }

    @Override
    public void input(MotionEvent e) {

    }

    private void move (Vector2z v2z) {
        this.v4z.addVector2z(v2z);
    }

    private boolean checkCollision (Vector4z v4z) {
        if (Vector4z.isColliding(this.v4z, v4z)) {
            return true;
        }
        return false;
    }


    public int getX () {
        return v4z.getX();
    }

    public int getY () {
        return v4z.getY();
    }

    public void setX (int x) {
        v4z.setX(x);
    }

    public void setY (int y) {
        v4z.setY(y);
    }
}

@@ -444,24 +444,77 @@
 meObject %7B%0A%0A
+    //contains x, y, width, and height of the player%0A
     private 
@@ -749,16 +749,191 @@
 = 1000;%0A
+    %0A    //minumum height the player can travel up%0A    private final int MIN_HEIGHT = 100%0A    %0A    //height where player will die if reached%0A    private final int MAX_HEIGHT;%0A
 %0A%0A    /*
@@ -1102,32 +1102,47 @@
 er (Vector4z v4z
+, int maxHeight
 ) %7B%0A        this
@@ -1153,16 +1153,48 @@
  = v4z;%0A
+        MAX_HEIGHT = maxHeight;%0A
     %7D%0A%0A 
@@ -1428,24 +1428,69 @@
 update() %7B%0A%0A
+        Vector2z temp = new Vector2z(0, 0);%0A%0A
         //co
@@ -1610,16 +1610,18 @@
 GE_TIME)
+ %7B
 %0A       
@@ -1661,57 +1661,347 @@
     
-else%0A                isDamaged = false;%0A        %7D
+    v2z.setY(v2z.getY() + 1);%0A            %7D%0A            else%0A                isDamaged = false;%0A        %7D else %7B%0A            //if the player is not damaged, slowly move up at constant speed until maximum height is reached%0A            if (getY() %3E MIN_HEIGHT)%0A                v2z.setY(v2z.getY() - 1);%0A        %7D%0A        %0A        move (v2z);
 %0A   

Update Player.java