-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGamePanelTest.java
More file actions
63 lines (55 loc) · 1.72 KB
/
Copy pathGamePanelTest.java
File metadata and controls
63 lines (55 loc) · 1.72 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
package uk.ac.cam.efxlb2.oop.tick5;
import java.awt.Color;
import javax.swing.*;
public class GamePanelTest extends JPanel {
private World world = null;
private int h;
private int w;
public void setWorld(World input) {//TESTER
world=input;
}
/*public GamePanel() {
super();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(972,768);//1024 wanted*/
@Override
protected void paintComponent(java.awt.Graphics g) {
// Paint the background white
g.setColor(java.awt.Color.WHITE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());//happens every time
h=this.getHeight();
w=this.getWidth();
if (world==null) {}
//else {
int pixperheight = (h-20)/19;//CHANGED from using world data
int pixperwidth = w/19;//CHANGED from using world data
int pixperbox = 0;
if (pixperheight>pixperwidth){
pixperbox=pixperwidth;
}
else {
pixperbox=pixperheight;
}
System.out.println(pixperbox);//TESTER this returns the value, but somewhere along the line somehting crashes
g.setColor(Color.LIGHT_GRAY);
//g.drawRect(0,20,pixperbox,pixperbox);
for (int i=0;i<19;i++){//CHANGED from using world data
System.out.println("Problem is here");//TESTER
for (int j=0;j<19;j++) {//CHANGED from using world data
g.drawRect(i*pixperbox,(j*pixperbox)+20,pixperbox,pixperbox);
/*if ((i*j/2)==0) {//CHANGED from using world data
g.setColor(Color.BLACK);
g.fillRect(pixperbox,pixperbox,j*pixperbox,i*pixperbox);
}*/
}
}
g.drawString("Generation :"+2,(w*1/10),(h*9/10));
//}
}
public void display(World wo) {
world = wo;
repaint();
}
/*public static void main(String[] args) {
GamePanel gamePanel*/
}