Commit 130b4943 authored by Anish Sinha's avatar Anish Sinha
Browse files

Merge branch 'Sprites' of https://agile.bu.edu/gitlab/ec327_projects/group5project into Sprites

parents 6c59cd1c 2bf19718
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ public class Enemy extends Sprite{

    @Override
    public void destroy() {
        //call the distroy functions, then delete this.
        //call the destroy functions, then delete this.
    }

}
+3 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class Player extends Sprite{
        xPos = screenWidth/2;  //haven't implement it yet
        yPos = 9 * screenHeight/10; //haven't implement it yet
        playerImg = BitmapFactory.decodeResource(res, R.drawable.green64);
        playerImg = Bitmap.createScaledBitmap(playerImg, getWidth(), getHeight(), false);
        playerImg = Bitmap.createScaledBitmap(playerImg, getSpriteWidth(), getSpriteHeight(), false);

    }

@@ -50,9 +50,9 @@ public class Player extends Sprite{
    }

    @Override //the return doesn't really mean anything all we need is that when any of the point hit within the hit box of player, call the loose health function.
    public boolean touching(int xx, int yy)
    public boolean checkForCollision(int xx, int yy)
    {
        if( super.touching(xx,yy) ) {
        if( super.checkForCollision(xx,yy) ) {
            looseHealth();
            return true;
        } else {
+16 −15
Original line number Diff line number Diff line
@@ -6,16 +6,17 @@ import android.graphics.BitmapFactory;
public class Sprite {

    // public fields
    // xPos and yPos are represent top left corner of Sprite hit box
    // xPos and yPos represent top left corner of Sprite hit box
    // xVel and yVel represent x and y velocity respectively
    // image is the Bitmap of the Sprite object
    int xPos, yPos;
    int xVel, yVel;
    int screenWidth, screenHeight;
    Bitmap image;

    //private properties
    //FIXME THIS FORMULA IS WRONG, ONLY RETURNS 0
    private final int height = 128;//displayMetrics.heightPixels/100;
    private final int width = 128;//displayMetrics.widthPixels/100;
    private final int spriteHeight = 64;
    private final int spriteWidth = 64;

    //private properties

@@ -30,21 +31,19 @@ public class Sprite {
    }

    /**
     *
     * @return Height of the sprite
     * @return height of the sprite
     */
    public int getHeight()
    public int getSpriteHeight()
    {
        return height;
        return spriteHeight;
    }

    /**
     *
     * @return Width of the sprite
     * @return width of the sprite
     */
    public int getWidth()
    public int getSpriteWidth()
    {
        return width;
        return spriteWidth;
    }

    /**
@@ -53,10 +52,10 @@ public class Sprite {
     * @param yy
     * @return True if xx and yy are in the current sprite
     */
    public boolean touching(int xx, int yy)
    public boolean checkForCollision(int xx, int yy)
    {
        //implement
        if((xx < (xPos+width) && xx > xPos) && (yy < (yPos+height) && yy > yPos))
        if((xx < (xPos+spriteWidth) && xx > xPos) && (yy < (yPos+spriteHeight) && yy > yPos))
        {
            return true;
        }
@@ -67,6 +66,8 @@ public class Sprite {
        //this should call the animation, and delete the object
    }

    void updateLocation() {}    //other classes will override this function
    public void updateLocation() {
        //other classes will override this function
    }

}