-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJeuVideo_01
More file actions
111 lines (94 loc) · 1.96 KB
/
JeuVideo_01
File metadata and controls
111 lines (94 loc) · 1.96 KB
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
<html>
<head>
<style>
body{
background-color: #333;
}
#main-content
{
display: block;
overflow: hidden;
color: white;
}
#comments
{
color: #E74C3C;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
var monsterLife = 10;
var monsterExist = true;
var comments = "";
var healPower = 1;
var attackPower = 3;
$(document).ready(function()
{
refreshDisplay();
});
function refreshDisplay()
{
$("#monsterLife").text(monsterLife);
}
function attackMonster()
{
if(monsterExist)
{
monsterLife = monsterLife - attackPower;
if(monsterLife <= 0)
{
monsterLife = 0;
monsterExist = false;
comments = "Le monstre est mort X_X argh.";
}
else
{
comments = "Le monstre a pris" + attackPower + " points de dégats.";
}
refreshDisplay();
}
$("#comments").text(comments);
}
function healMonster()
{
//le monstre est ressuscité
if(monsterLife <= 0)
{
monsterLife = 1;
monsterExist = true;
comments = "Le monstre est revenu, il est blessé !";
}
//le monstre ne doit pas avoir plus de 10 points de vie
else if(monsterLife >= 10)
{
monsterLife = 10;
comments = "Le monstre est en pleine santé.";
}
//le monstre est soigné
else
{
monsterLife = monsterLife + healPower;
comments = "Le monstre a reçu " + healPower + " points de vie.";
}
refreshDisplay();
$("#comments").text(comments);
}
</script>
</head>
<body>
<div><img src="http://coderdojo-liege.be/wp-content/uploads/2015/06/logo2.png" /></div>
<br />
<div id="main-content">
<p>
Vie du monstre / Monster life: <span id="monsterLife"></span>
</p>
<p>
<button onclick="attackMonster();">Attack</button>
<button onclick="healMonster();">Heal</button>
</p>
<p>
Commentaire: <span id="comments"></span>
</p>
</div>
</body>
</html>