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