-
Notifications
You must be signed in to change notification settings - Fork 0
/
Peashooter.java
142 lines (128 loc) · 3.87 KB
/
Peashooter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package application;
import javafx.scene.input.DragEvent;
import javafx.scene.effect.BlendMode;
import javafx.geometry.Insets;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.scene.text.*;
import javafx.animation.PathTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.input.ClipboardContent;
import javafx.scene.shape.Path;
import javafx.scene.shape.Sphere;
import javafx.scene.paint.*;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.control.Label;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.util.Duration;
import javafx.scene.input.MouseEvent;
import java.awt.event.MouseListener;
public class Peashooter implements actor{
private int price = 100;
private int posx;
private int posy;
private int health = 500;
private int power = 0;
private StackPane s = new StackPane();
private Group root;
private Image plant;
private HBox hBox;
private ImageView plantView;
private double sizeX;
private double sizeY;
private boolean status;
//private Player player;
private VBox vBox;
public Peashooter (Group root /*,Player player*/) throws FileNotFoundException{
//this.player = player;
this.hBox=new HBox();
this.posx=430;
this.posy=350;
this.plant = new Image(new FileInputStream("C:\\Users\\HARSHIT\\Desktop\\pea_shooter.gif"));
this.plantView = new ImageView(plant);
s.getChildren().add(plantView);
this.root = root;
// plantView.setY(600);
// plantView.setX(300);
this.sizeX = 100;
this.sizeY = 100;
hBox.setTranslateX(430);
hBox.setTranslateY(325);
hBox.setPrefWidth(100);
hBox.setPrefHeight(95);
this.vBox = new VBox();
vBox.getChildren().addAll(hBox);
root = new Group(s,plantView,vBox);
//insertImage(plant,hBox);
}
public void insertImage(Image i, HBox hb){
ImageView iv = new ImageView();
iv.setImage(i);
//setupGestureSource(iv);
hb.getChildren().add(iv);
}
public void removeImage(){
this.s.getChildren().remove(this.plantView);
this.root.getChildren().remove(this.s);
}
public void setPos(int row, int column){
this.posx=980;
this.posy=-80;
}
public void setSize(double width, double height) {
this.plantView.setFitWidth(width);
this.plantView.setFitHeight(height);
}
public int getHealth(){
return health;
}
public void setHealth(int health){
this.health = health;
}
public int getPower(){
return power;
}
public void setPower(int power){
this.power = power;
}
public int getPrice(){
return price;
}
public String getName(){
return "sunflower";
}
public VBox getvbox() {
return vBox;
}
public HBox gethbox() {
return hBox;
}
public Image getimage() {
return plant;
}
public void setstatus(Boolean status) {
this.status=true;
}
public Boolean getstatus() {
if(this.health==0)
this.status=false;
return status;
}
}