-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.html
83 lines (76 loc) · 2.47 KB
/
game.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Processing Demo</title>
<script type = "text/javascript" src= "./JAVA/bibat_1.js"></script>
</head>
<body>
<script type="text/processing">
PImage back;
PImage face;
PFont Font1;
int count = 0; int y = 0; int Vy = 0;
int gameState = 0;
void setup(){
size(748,421);
back = loadImage("./image/bg.png");
face = loadImage("./image/plane.png");
Font1 = createFont("Arial Bold Italic", 18);
//image(back,0,0);
}
void draw(){
if (gameState ==0){
image(back, count, 0);
image(back, width + count, 0);
count--;
if (count == -width){
count = 0;
}
image(face, 100, y);
if(count%3 == 0){
Vy += 1;
}
y = y + Vy;
}
if (y < -40 || y > 450){
gameState = 1;
}
if (gameState == 1){
background(0,0,0);
fill(0);
rect(217.5, 168, 275, 55, 5);
fill(255,0,0);
textFont(Font1);
textSize(50);
text("Restart? ;)", 230, 210.5);
if (mouseX > 217.5 && mouseX < 492.5 && mouseY > 168 && mouseY < 218){
background(252,255,244);
fill(0);
rect(217.5, 168, 275, 55, 5);
fill(252,255,244);
textFont(Font1);
textSize(50);
text("Restart? ;)", 230, 210.5);
if(mousePressed){
gameState = 0; y = 50;
}
}
}
}
void keyPressed(){
if (keyCode == UP){
Vy = -10;
}
if (keyCode == DOWN){
Vy = +10;
}
}
void keyReleased(){
if (keyCode == UP || keyCode == DOWN){
Vy = 0;
}
}
</script>
<canvas id = "sketch" style = "border: 1px solid black;"></canvas>
</body>
</html>