-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBallUppAndDown.html
118 lines (106 loc) · 3.69 KB
/
BallUppAndDown.html
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
<!DOCTYPE html>
<html>
<head>
<title>Games - Ball Up and Down </title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.0/processing.min.js"></script>
<link href="style.css" rel="stylesheet">
</head>
<body>
<!-- ================================
Start Navigation Bar
================================= -->
<header>
<div class="headerCol">
<div class="container-fluid">
<div class="row align-items-center">
<div class="col">
<div class="navCollapseCol">
<div class="navCol">
<ul>
<li><a href="index.html">Mustachio</a></li>
<li><a href="drop.html">Drop</a></li>
<li><a href="BallUppAndDown.html">Ball Upp and Down</a></li>
<li><a href="aquarium.html">Aquarium</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- ================================
End Navigation Bar
================================= -->
<div class="row align-items-center"></div>
<h1>Boll Upp och Ner</h1>
<p>En Boll som Hoppar Upp och Ner</p>
<script type="application/processing">
var y =0;
var k=1;
var x=0;
var move = 0;
var bollstandard = 200;
var jumpHight = -62;
var grass = loadImage("GrassBlock.png");
var xCloud = 0;
void setup() {
size(450, 400);
}
void keyPressed() {
if (keyCode === LEFT) {
x=x-3;
}
if (keyCode === RIGHT) {
x=x+3;
}
}
var rektangel = function(xposition,yposition,rektbredd,rektlangd,rotera) {
fill(17, 219, 24);
rect(xposition+move,yposition,rektbredd,rektlangd);
if(((200+x)>xposition+move) && ((xposition+rektbredd+move)>(200+x))&&((yposition)<(bollstandard-y+35/2))&&k<0){
bollstandard = yposition-rektlangd-35/2;
k=1;
y=jumpHight;
println(yposition);
println(bollstandard-y+35/2);
}
//clouds
noStroke();
fill(255, 255, 255);
ellipse(xCloud + 10, 100,115,55);
ellipse(xCloud + 17, 96,62,27);
ellipse(xCloud + 9,80,50,35);
ellipse(xCloud + 300,80,43,30);
ellipse(xCloud + 317,67,70,50);
ellipse(xCloud + 347,77,80,30);
xCloud++;
if (xCloud > 500) {
xCloud = -400;
}
};
draw = function() {
move -= 1;
image(grass,0,200,50,50);
background(33, 122, 255);
//rect(0,200+62+35/2,415,159);
rektangel(376,237,100,60,0);
fill(255, 0, 0);
stroke(0,0,0);
ellipse(200+x, bollstandard-y, 35, 35);
y = y+k;
for(var flytta = 0; 20>flytta; flytta++) {
image(grass,92*flytta,207,93,244);
}
if(y>0){
k-=1;
}
if(y<jumpHight){
k=k+2;
}
};
</script>
<canvas> </canvas>
</div>
</body>
</html>