|
1 |
| -float [][] position; |
2 |
| -import ddf.minim.*; |
3 |
| -Minim minim; |
4 |
| -AudioPlayer player; |
5 |
| -PImage bild; |
6 |
| -PImage bild2; |
7 |
| -float x = 0; |
8 |
| -float x5 = -50; |
9 |
| -float y5 = -50; |
10 |
| -float y = 0; |
11 |
| -float copies = 200; |
12 |
| -float size = 50; |
13 |
| -float speedX = 0; |
14 |
| -float speedY = 0; |
15 |
| -float spelplanX = 0; |
16 |
| -float spelplanY = 0; |
17 |
| -float enemySpeedX = 1; |
18 |
| -float enemySpeedY = 1; |
19 |
| -float eyeX = x; |
20 |
| -float eyeY = y; |
21 |
| -float eX = 0; |
22 |
| -float eY = 0; |
23 |
| -boolean[] keys; |
24 |
| -void setup() |
25 |
| -{ |
26 |
| - minim = new Minim(this); |
27 |
| - player= minim.loadFile("t.mp3"); |
28 |
| - bild2 = loadImage("mus.png"); |
29 |
| - noCursor(); |
30 |
| - fullScreen(); |
31 |
| - x = width / 2 - 25; |
32 |
| - y = height / 2 - 25; |
33 |
| - eyeX = x + 15; |
34 |
| - eyeY = y + 15; |
35 |
| - bild = loadImage("grass.png"); |
36 |
| - keys = new boolean[2048]; |
37 |
| - position = new float[64][5]; |
38 |
| - for(int i=0;i<position.length;i++){ |
39 |
| - position[i][2]=0; |
40 |
| - } |
41 |
| - /* |
42 |
| - [i][0] = X |
43 |
| - [i][1] = Y |
44 |
| - [i][2] = Draw? |
45 |
| - [i][3] = Width |
46 |
| - [i][4] = Height |
47 |
| - */ |
48 |
| -} |
49 |
| -void draw() |
50 |
| -{ |
51 |
| - player.play(); |
52 |
| - if (spelplanX > 0) spelplanX-= 100; |
53 |
| - if (spelplanX + width / 10 < 0) spelplanX += 100; |
54 |
| - if (spelplanY > 0) spelplanY-= 100; |
55 |
| - if (spelplanY + width / 10 < 0) spelplanY += 100; |
56 |
| - if (eX < x + 25) eX = eX + 1; |
57 |
| - if (eX > x + 25) eX = eX - 1; |
58 |
| - if (eY > y + 25) eY -= 1; |
59 |
| - if (eY < y + 25) eY += 1; |
60 |
| - fill(0, 180, 0); |
61 |
| - if (dist(eX, eY, x + 25 , y + 25) < 50) exit(); |
62 |
| - stroke(0, 255, 0); |
63 |
| - fill(255, 255, 255); |
64 |
| - |
65 |
| - fill(255, 0, 0); |
66 |
| - image(bild, spelplanX, spelplanY); |
67 |
| - ellipse(eX, eY, 50, 50); |
68 |
| - for (int i = 0; i > 200; ++i) |
69 |
| - { |
70 |
| - ellipse(spelplanX, spelplanY, 100, 100); |
71 |
| - spelplanX += 100; |
72 |
| - } |
73 |
| - player.play(); |
74 |
| - fill(0, 0, 0); |
75 |
| - rect(x, y, size , size); |
76 |
| - fill(255, 0, 0); |
77 |
| - fill(255, 255, 255); |
78 |
| - ellipse(eyeX, eyeY, 20, 20); |
79 |
| - fill(0, 0, 0); |
80 |
| - ellipse(eyeX, eyeY, 10, 10); |
81 |
| - makeRect(x5,y5,150,150); |
82 |
| - |
83 |
| - for(int i=0;i<position.length;i++){ |
84 |
| - if(position[i][2]==1){ |
85 |
| - rect(position[i][0], position[i][1], position[i][3], position[i][4]); |
86 |
| - } |
87 |
| - |
88 |
| - position[i][2]=0; |
89 |
| - } |
90 |
| - image(bild2, mouseX, mouseY); |
91 |
| - k(); |
92 |
| -} |
93 |
| -void makeRect(float X, float Y, float Width, float Height){ |
94 |
| - int i=0; |
95 |
| - for(i=0;i<position.length-1&&(position[i][2]==1);i++){ |
96 |
| - } |
97 |
| - position[i][0]=X; |
98 |
| - position[i][2]=1; |
99 |
| - position[i][3]=Width; |
100 |
| - position[i][4]=Height; |
101 |
| -} |
102 |
| -void keyPressed(){ |
103 |
| - keys[keyCode]=true; |
104 |
| - println(keyCode); |
105 |
| -} |
106 |
| -void keyReleased(){ |
107 |
| - keys[keyCode]=false; |
108 |
| -} |
109 |
| -void k() |
110 |
| -{ |
111 |
| - if (keyPressed) |
112 |
| - { |
113 |
| - if (key == 'e') |
114 |
| - { |
115 |
| - exit(); |
116 |
| - } |
117 |
| - if (keys[38]) |
118 |
| - { |
119 |
| - y5 += 3; |
120 |
| - spelplanY = spelplanY + 3; |
121 |
| - eyeY = height / 2 - 10; |
122 |
| - eyeX = width / 2; |
123 |
| - eY += 2; |
124 |
| - if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
125 |
| - spelplanY -= 3; |
126 |
| - y5 -=3; |
127 |
| - } |
128 |
| - } |
129 |
| - if (keys[40]) |
130 |
| - { |
131 |
| - spelplanY = spelplanY - 3; |
132 |
| - eyeY = height / 2 + 10; |
133 |
| - eyeX = width / 2; |
134 |
| - eY -= 2; |
135 |
| - y5 -= 3; |
136 |
| - if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
137 |
| - spelplanY += 3; |
138 |
| - y5 += 3; |
139 |
| - } |
140 |
| - } |
141 |
| - if (keys[37]) |
142 |
| - { |
143 |
| - x5 += 3; |
144 |
| - spelplanX = spelplanX + 3; |
145 |
| - eyeX = width / 2 - 10; |
146 |
| - eyeY = height / 2; |
147 |
| - eX += 2; |
148 |
| - if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
149 |
| - spelplanX -= 3; |
150 |
| - x5 -= 3; |
151 |
| - } |
152 |
| - } |
153 |
| - if (keys[39]) |
154 |
| - { |
155 |
| - x5 -= 3; |
156 |
| - if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
157 |
| - spelplanX += 3; |
158 |
| - x5 += 3; |
159 |
| - } |
160 |
| - spelplanX = spelplanX - 3; |
161 |
| - eyeX = width / 2 + 10; |
162 |
| - eyeY = height / 2; |
163 |
| - eX -= 2; |
164 |
| - } |
165 |
| - } |
166 |
| -} |
| 1 | +float [][] position; |
| 2 | +import ddf.minim.*; |
| 3 | +Minim minim; |
| 4 | +AudioPlayer player; |
| 5 | +PImage bild; |
| 6 | +PImage bild2; |
| 7 | +float x = 0; |
| 8 | +float x5 = -50; |
| 9 | +float y5 = -50; |
| 10 | +float y = 0; |
| 11 | +float copies = 200; |
| 12 | +float size = 50; |
| 13 | +float speedX = 0; |
| 14 | +float speedY = 0; |
| 15 | +float spelplanX = 0; |
| 16 | +float spelplanY = 0; |
| 17 | +float enemySpeedX = 1; |
| 18 | +float enemySpeedY = 1; |
| 19 | +float eyeX = x; |
| 20 | +float eyeY = y; |
| 21 | +float eX = 0; |
| 22 | +float eY = 0; |
| 23 | +boolean[] keys; |
| 24 | +void setup() |
| 25 | +{ |
| 26 | + minim = new Minim(this); |
| 27 | + player= minim.loadFile("t.mp3"); |
| 28 | + bild2 = loadImage("mus.png"); |
| 29 | + noCursor(); |
| 30 | + fullScreen(); |
| 31 | + x = width / 2 - 25; |
| 32 | + y = height / 2 - 25; |
| 33 | + eyeX = x + 15; |
| 34 | + eyeY = y + 15; |
| 35 | + bild = loadImage("grass.png"); |
| 36 | + keys = new boolean[2048]; |
| 37 | + position = new float[64][5]; |
| 38 | + for(int i=0;i<position.length;i++){ |
| 39 | + position[i][2]=0; |
| 40 | + } |
| 41 | + /* |
| 42 | + [i][0] = X |
| 43 | + [i][1] = Y |
| 44 | + [i][2] = Draw? |
| 45 | + [i][3] = Width |
| 46 | + [i][4] = Height |
| 47 | + */ |
| 48 | +} |
| 49 | +void draw() |
| 50 | +{ |
| 51 | + player.play(); |
| 52 | + if (spelplanX > 0) spelplanX-= 100; |
| 53 | + if (spelplanX + width / 10 < 0) spelplanX += 100; |
| 54 | + if (spelplanY > 0) spelplanY-= 100; |
| 55 | + if (spelplanY + width / 10 < 0) spelplanY += 100; |
| 56 | + if (eX < x + 25) eX = eX + 1; |
| 57 | + if (eX > x + 25) eX = eX - 1; |
| 58 | + if (eY > y + 25) eY -= 1; |
| 59 | + if (eY < y + 25) eY += 1; |
| 60 | + fill(0, 180, 0); |
| 61 | + if (dist(eX, eY, x + 25 , y + 25) < 50) exit(); |
| 62 | + stroke(0, 255, 0); |
| 63 | + fill(255, 255, 255); |
| 64 | + |
| 65 | + fill(255, 0, 0); |
| 66 | + image(bild, spelplanX, spelplanY); |
| 67 | + ellipse(eX, eY, 50, 50); |
| 68 | + for (int i = 0; i > 200; ++i) |
| 69 | + { |
| 70 | + ellipse(spelplanX, spelplanY, 100, 100); |
| 71 | + spelplanX += 100; |
| 72 | + } |
| 73 | + player.play(); |
| 74 | + fill(0, 0, 0); |
| 75 | + rect(x, y, size , size); |
| 76 | + fill(255, 0, 0); |
| 77 | + fill(255, 255, 255); |
| 78 | + ellipse(eyeX, eyeY, 20, 20); |
| 79 | + fill(0, 0, 0); |
| 80 | + ellipse(eyeX, eyeY, 10, 10); |
| 81 | + makeRect(x5,y5,150,150); |
| 82 | + |
| 83 | + for(int i=0;i<position.length;i++){ |
| 84 | + if(position[i][2]==1){ |
| 85 | + rect(position[i][0], position[i][1], position[i][3], position[i][4]); |
| 86 | + } |
| 87 | + |
| 88 | + position[i][2]=0; |
| 89 | + } |
| 90 | + image(bild2, mouseX, mouseY); |
| 91 | + k(); |
| 92 | +} |
| 93 | +void makeRect(float X, float Y, float Width, float Height){ |
| 94 | + int i=0; |
| 95 | + for(i=0;i<position.length-1&&(position[i][2]==1);i++){ |
| 96 | + } |
| 97 | + position[i][0]=X; |
| 98 | + position[i][1]=Y; |
| 99 | + position[i][2]=1; |
| 100 | + position[i][3]=Width; |
| 101 | + position[i][4]=Height; |
| 102 | +} |
| 103 | +void keyPressed(){ |
| 104 | + keys[keyCode]=true; |
| 105 | + println(keyCode); |
| 106 | +} |
| 107 | +void keyReleased(){ |
| 108 | + keys[keyCode]=false; |
| 109 | +} |
| 110 | +void k() |
| 111 | +{ |
| 112 | + if (keyPressed) |
| 113 | + { |
| 114 | + if (key == 'e') |
| 115 | + { |
| 116 | + exit(); |
| 117 | + } |
| 118 | + if (keys[38]) |
| 119 | + { |
| 120 | + y5 += 3; |
| 121 | + spelplanY = spelplanY + 3; |
| 122 | + eyeY = height / 2 - 10; |
| 123 | + eyeX = width / 2; |
| 124 | + eY += 2; |
| 125 | + if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
| 126 | + spelplanY -= 3; |
| 127 | + y5 -=3; |
| 128 | + } |
| 129 | + } |
| 130 | + if (keys[40]) |
| 131 | + { |
| 132 | + spelplanY = spelplanY - 3; |
| 133 | + eyeY = height / 2 + 10; |
| 134 | + eyeX = width / 2; |
| 135 | + eY -= 2; |
| 136 | + y5 -= 3; |
| 137 | + if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
| 138 | + spelplanY += 3; |
| 139 | + y5 += 3; |
| 140 | + } |
| 141 | + } |
| 142 | + if (keys[37]) |
| 143 | + { |
| 144 | + x5 += 3; |
| 145 | + spelplanX = spelplanX + 3; |
| 146 | + eyeX = width / 2 - 10; |
| 147 | + eyeY = height / 2; |
| 148 | + eX += 2; |
| 149 | + if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
| 150 | + spelplanX -= 3; |
| 151 | + x5 -= 3; |
| 152 | + } |
| 153 | + } |
| 154 | + if (keys[39]) |
| 155 | + { |
| 156 | + x5 -= 3; |
| 157 | + if (dist(x5 + 100, y5 + 100, x + 50 , y + 50) < 125){ |
| 158 | + spelplanX += 3; |
| 159 | + x5 += 3; |
| 160 | + } |
| 161 | + spelplanX = spelplanX - 3; |
| 162 | + eyeX = width / 2 + 10; |
| 163 | + eyeY = height / 2; |
| 164 | + eX -= 2; |
| 165 | + } |
| 166 | + } |
| 167 | +} |
0 commit comments