Files
android-hypergames/app/src/main/java/com/hyperling/apps/games/EnvironmentObject.java
T
2025-01-04 12:48:09 -07:00

35 lines
706 B
Java
Executable File

package com.hyperling.apps.games;
import android.graphics.Bitmap;
import android.graphics.Canvas;
/**
* Created by ling on 12/23/16.
*/
public abstract class EnvironmentObject extends GameObject {
protected Bitmap image;
public EnvironmentObject(Bitmap i, int w, int h, int x, int y){
image = i;
width = w;
height = h;
this.x = x;
this.y = y;
}
public void update(int gameSpeed){
// Move the object
x += gameSpeed;
setEndX(getX() + getWidth());
setCenterX((getX() + getEndX()) / 2);
}
public void draw(Canvas canvas) {
// Draw the object
canvas.drawBitmap(image, x, y, null);
}
}