-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.java
More file actions
82 lines (63 loc) · 1.29 KB
/
Copy pathView.java
File metadata and controls
82 lines (63 loc) · 1.29 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
72
73
74
75
76
77
78
79
80
81
82
/*
Name: Creighton Young
Date: 9/11/2020
Assigment: Make a turtle dance and make a button disappear
*/
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.File;
import javax.swing.JButton;
import java.awt.Color;
class View extends JPanel
{
JButton b1;
BufferedImage tube_image;
Model model;
int scrollPos=0;
BufferedImage[] mario_images;
BufferedImage[] goomba_images;
int marioImage=0;
View(Controller c, Model m)
{
model = m;
c.setView(this);
mario_images = new BufferedImage[5];
}
void removeButton()
{
this.remove(b1);
this.repaint();
}
public void paintComponent(Graphics g)
{
g.setColor(new Color(128, 255, 255));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(new Color(0,204,0));
for (int x=0;x<model.sprites.size();x++)
{
model.sprites.get(x).drawYourself(g);
}
g.fillRect(0, 445, this.getWidth(),this.getHeight());
}
void setModel(Model m)
{
model = m;
}
static BufferedImage loadImage(String imageFile)
{
BufferedImage loadedImage=null;
try
{
loadedImage=ImageIO.read(new File(imageFile));
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.exit(1);
}
return loadedImage;
}
}