-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokens.java
More file actions
71 lines (64 loc) · 2.08 KB
/
Tokens.java
File metadata and controls
71 lines (64 loc) · 2.08 KB
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
import javafx.application.Application;
import javafx.scene.paint.ImagePattern;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.shape.*;
import javafx.util.Duration;
import javafx.scene.control.*;
import java.io.*;
import java.util.Random;
import java.util.Stack;
import javafx.scene.image.*;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.animation.*;
import javafx.scene.layout.*;
import javafx.scene.transform.Translate;
public class Tokens extends Circle {
private Random randomgenerator=new Random();
private String type;
public Text text;
public int value;
private static int [][]Colors=new int[][] {{255,0,0},{128,0,0},{255,255,0},{128,128,0},{0,255,0},{0,128,0},{0,255,255},{0,128,128},{0,0,255},{0,0,128},{255,0,255},{128,0,128}};
public String getType(){
return type;
}
public Tokens(int x, int y, String s){
super(10,Color.BLACK);
type=s;
value=0;
x+=10;
try {
if (type.equals("Magnet")) {
Image image1=new Image(new FileInputStream("C:/Users/Pratik/Desktop/Magnet.png"));
setFill(new ImagePattern(image1));
}
else if (type.equals("Destroyer")) {
Image image1=new Image(new FileInputStream("C:/Users/Pratik/Desktop/Destroyer.jpeg"));
setFill(new ImagePattern(image1));
}
else if(type.equals("Shield")) {
Image image1=new Image(new FileInputStream("C:/Users/Pratik/Desktop/Shield.jpeg"));
setFill(new ImagePattern(image1));
}
else if(type.equals("Ball")) {
setFill(Color.RED);
}
}
catch(Exception e) {
e.printStackTrace();
}
this.setTranslateX(x);
this.setTranslateY(y);
}
public void MoveDown() {
setTranslateY(getTranslateY() + 2);
}
public static Color getRandomColor() {
Random random = new Random() ;
int a = random.nextInt(12);
return (Color.rgb(Colors[a][0], Colors[a][1], Colors[a][2]));
}
}