-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trees.java
34 lines (26 loc) · 841 Bytes
/
Trees.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
/* HackTJ Dino Game
Method to move trees across the background */
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.Timer;
public class Trees {
private int xPos, yPos;
private ImageIcon tree1;
Trees(int x) {
xPos = x;
yPos = 230; //180
tree1 = new ImageIcon ("imgs/treeSmall.jpg");
}
public void draw (Graphics g) {
// for(int i = 0; i < trees.length; i++)
// g.drawImage(trees[i].getImage(), 200, 100, null);
g.drawImage(tree1.getImage(), xPos, yPos, null);
// g.drawImage(tree2.getImage(), xPos, yPos, null);
// g.drawImage(tree3.getImage(), xPos, yPos, null);
}
public void scroll (){
xPos-=2; //If you want trees to stop put at -= 0 or just xPos // for end game situation
if (xPos <0)
xPos = 800;
}
}