Skip to content

Commit

Permalink
add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
AsadiAhmad authored Oct 20, 2023
1 parent 7337d44 commit 47d9c99
Show file tree
Hide file tree
Showing 88 changed files with 5,665 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Plants VS Zombies/ConeHeadZombie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package ProjectFinal;

import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.util.Duration;

import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;

public class ConeHeadZombie {

public static int coneHeadZombieHealth = 30;

String zombieGif = "myPicture/gif/ZombieGif.gif";

private int zombieImageChang (ImageView myImageView, int yZombieBlock, int currentZombie, int result) {
if (GameData.zombieHealth[yZombieBlock].get (currentZombie) <= 10 && result == 1) {
result = 0;
InputStream input = getClass().getResourceAsStream(zombieGif);
Image image = new Image(input);
myImageView.setImage (image);
myImageView.setFitHeight (120);
myImageView.setFitWidth (80);
}
return result;
}

private void zombieImageChanger (ImageView myImageView, int yZombieBlock, int currentZombie) {
AtomicInteger result = new AtomicInteger();
result.set (1);
Timeline myTimeline = new Timeline (new KeyFrame(Duration.millis(10),
(event) -> result.set(zombieImageChang (myImageView, yZombieBlock, currentZombie, result.get()))));
myTimeline.setCycleCount (Animation.INDEFINITE);
myTimeline.play();
}

public void playConeHeadZombie (ImageView myImageView, int yZombieBlock, int currentZombie) {
zombieImageChanger (myImageView, yZombieBlock, currentZombie);
}

}
Loading

0 comments on commit 47d9c99

Please sign in to comment.