This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
157 lines (100 loc) · 2.21 KB
/
sketch.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
var x = 250;
var y = 250;
var speedx = 6;
var speedy = -6;
var farge = 255;
var telling = 0;
var vor = 0;
var speed = 6;
var a = 0;
var locx = 200;
//1 = muskontroll og 2 = pilkontroll
var system = 1;
function setup() {
createCanvas(500, 500);
}
function draw() {
background(200);
noFill();
strokeWeight(2);
rect(0, 0, 500, 500);
fill(0);
rect(480, 480, 20, 20);
fill(255);
rect(460, 480, 20, 20);
if(system == 1){
Spiller();
}else if(system == 2){
Spiller2();
}
if (keyIsDown(LEFT_ARROW))
locx = locx - 10;
if (keyIsDown(RIGHT_ARROW))
locx = locx + 10;
if(telling > 10 && telling < 19){
speed = 9;
} else if (telling > 20 && telling < 30){
speed = 12;
}
Ball();
textSize(50);
strokeWeight(2);
text(telling, 5, 50);
if(vor == 1){
stroke(0);
line(75, 258, 425, 258);
}
}
function mouseClicked(){
if(mouseX > 200 && mouseX < 300 && mouseY > 250 && mouseY < 300 && vor == 1){
window.location=document.URL
}
if(mouseX > 460 && mouseX < 480 & mouseY > 480 & mouseY < 500){
system = 1;
}else if(mouseX > 480 && mouseX < 500 && mouseY > 480 && mouseY < 500){
system = 2;
}
}
function Ball(){
x = x + speedx;
y = y + speedy;
if(x > width ){
speedx = - speed;
} else if (x < 0){
speedx = + speed;
} else if (y > height){
speedy = 1;
speedx = 0;
textSize(50);
fill(255);
text("GAME OVER", 100, 250);
vor = 1;
textSize(50);
fill(0);
text("start", 200, 300);
}else if (y < 0){
speedy = +speed;
}
fill(255);
strokeWeight(4);
ellipse(x, y, 20, 20);
}
function Spiller(){
rect( mouseX, 400, 50, 10);
if(y + 20 > 400 && y - 20 < 403 && x + 20 > mouseX && x - 20 < mouseX + 50){
speedy = - speed;
telling = telling + 1;
if( mouseX < 0){
mouseX = 0;
}else if( mouseX + 50 > 500){
mouseX = 500;
}
}
}
function Spiller2(){
rect(locx, 400, 50, 10)
if(y + 20 > 400 && y - 20 < 403 && x + 20 > locx && x - 20 < locx + 50){
speedy = - speed;
telling = telling + 1;
}
}