package com.jalenwinslow.game.gameobjects; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.jalenwinslow.game.Handler; /** * Created by jalen on 2/16/2018. */ public abstract class GameObject { protected Handler handler; protected Vector2 pos; protected float depth; protected TextureRegion image; protected Rectangle bounds; public GameObject(Handler handler, float x, float y, Texture image) { this.handler = handler; this.pos = new Vector2(x, y); this.depth = y; if (image != null) this.image = new TextureRegion(image); else this.image = null; this.bounds = new Rectangle(); } public abstract void init(int initState); public abstract void update(float dt); public abstract void render(SpriteBatch batch); public abstract void dispose(); public boolean hasCollided(float x, float y) { return (x < bounds.x + bounds.width && x > bounds.x && y < bounds.y + bounds.height && y > bounds.y); } //Getters and Setters public Vector2 getPos() {return pos;} public float getDepth() {return depth;} public TextureRegion getImage() {return image;} public Rectangle getBounds() {return bounds;} public void setPos(Vector2 pos) {this.pos = pos;} public void setPos(float x, float y) {this.pos.set(x, y);} public void setDepth(float depth) {this.depth = depth;} public void setImage(TextureRegion image) {this.image = image;} public void setBounds(Rectangle bounds) {this.bounds = bounds;} }