1 package sample;
2
3 import java.awt.Color;
4
5 import fi.jyu.mit.graphics.Circle;
6 import fi.jyu.mit.graphics.ControlButtons;
7 import fi.jyu.mit.graphics.ControllerFrame;
8 import fi.jyu.mit.graphics.DrawableCollection;
9 import fi.jyu.mit.graphics.Line;
10 import fi.jyu.mit.graphics.Polygon;
11 import fi.jyu.mit.graphics.TouchPad;
12 import fi.jyu.mit.graphics.Window;
13 import sample.UkkoSample.Ukko;
14
15
20 public class CarSample {
21
22
26 public static class Car extends DrawableCollection {
27
28
34 public Car(double x, double y, double z) {
35 super();
36 move(x, y, z);
37 add(new Circle(-2, 0, 1, 0.5));
38 add(new Circle(-2, 0, -1, 0.5));
39 add(new Circle(2, 0, 1, 0.5));
40 add(new Circle(2, 0, -1, 0.5));
41 add(new Line(-2, 0, -1, -2, 0, 1));
42 add(new Line(2, 0, -1, 2, 0, 1));
43 add(new Line(-2, 1, 1, -2, 1, -1)).setColor(0, 0, 255);
44 add(new Line(-0.5, 1, 1, -0.5, 1, -1)).setColor(0, 0, 255);
45 add(new Line(0.5, 2, 1, 0.5, 2, -1)).setColor(0, 0, 255);
46 add(new Line(2, 2, 1, 2, 2, -1)).setColor(0, 0, 255);
47 add(new Line(3, 1, 1, 3, 1, -1)).setColor(0, 0, 255);
48 add(new Line(-0.5, 1, 1, 3, 1, 1)).setColor(0, 0, 255);
49 add(new Line(-0.5, 1, -1, 3, 1, -1)).setColor(0, 0, 255);
50 add(new Line(-0.25, 0.2, 1, 0.25, 0.7, 1)).setColor(255, 0, 0);
51 add(new Line(-0.25, 0.7, 1, 0.25, 0.2, 1)).setColor(255, 0, 0);
52 double[][] points1 = {
53 { -3, 0, 1},
54 { -3, 0, -1},
55 { -2, 1, -1},
56 { -0.5, 1, -1},
57 { 0.5, 2, -1},
58 { 2, 2, -1},
59 { 3, 1, -1},
60 { 3, 0, -1},
61 { 3, 0, 1},
62 { 3, 1, 1},
63 { 2, 2 , 1},
64 { 0.5, 2 , 1},
65 { -0.5, 1 , 1},
66 { -2, 1, 1},
67 { -3, 0 , 1}
68 };
69 add(new Polygon(points1)).setColor(0, 0, 255);
70 double[][] points2 = {
71 { -3, 0, 1},
72 { -3, 0, -1},
73 { 3, 0, -1},
74 { 3, 0, 1},
75 };
76 add(new Polygon(points2)).setColor(0, 0, 255);
77 }
78 }
79
80
84 @SuppressWarnings("unused")
85 public static void main(String[] args) {
86 Window window = new Window();
87 Car car = new Car(0, 0, 0);
88
89 window.add(car);
90 window.scale(-4, -4, 4, 4);
91 window.showWindow();
92
93 window.setTouchPad(true, true);
94 window.setControlButtons(true);
95
96 Ukko ukko = new Ukko(-3,3,0.01,180,Color.RED); window.add(ukko);
97 new ControllerFrame(new TouchPad(ukko),300,350,150,150);
98 new ControllerFrame(new ControlButtons(ukko),450,350,150,150);
99 }
100 }
101