Add original project.

This commit is contained in:
2025-01-04 12:48:09 -07:00
parent 2ea0f8441d
commit 6e7114a24d
92 changed files with 3462 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
package com.hyperling.apps.games;
import android.graphics.Bitmap;
import android.graphics.Canvas;
/**
* Created by ling on 12/26/16.
*/
public class BirdEnemy extends GameObject {
protected Bitmap image;
private Animation animation;
private int speed, damage;
public BirdEnemy(Bitmap b, int w, int h, int numFrames, int x, int y, int speed, int damage){
image = b;
width = w;
height = h;
this.x = x;
this.y = y;
this.speed = speed;
this.damage = damage;
if (speed > -1){
speed = -1;
}
if (this.y >= GameView.HEIGHT - this.height){
this.y = GameView.HEIGHT - this.height;
}
// Create animation
Bitmap[] image = new Bitmap[numFrames];
animation = new Animation();
for (int i = 0; i < numFrames; i++){
image[i] = Bitmap.createBitmap(b, width * i, 0, width, height);
}
animation.setFrames(image);
//animation.setDelay(100);
int delay = 25 * Math.abs(speed);
if (delay > 125){
delay = 125;
}
else if (delay < 75){
delay = 75;
}
animation.setDelay(delay);
animation.setCurrentFrame((int)(Math.random() * numFrames));
}
public void update(){
animation.update();
// Move the object
x += speed;
}
public void draw(Canvas canvas) {
// Draw the object
canvas.drawBitmap(animation.getImage(), getX(), getY(), null);
}
public int getDamage() {
return damage;
}
}