-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
136 lines (128 loc) · 4.36 KB
/
index.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>Félix López Luis - CV</title>
<meta name="viewport" content="width=device-width">
<script src="sprite.js" type="text/javascript"></script>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="state-machine.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="css3.css">
</head>
<script>
var texts= ["Hi!, I'm Felix Lopez", "I'm a developer",
"that's why my drawings are so bad :)",
"what you're watching it's my live CV",
"ok, ok, it's the begining of what",
"it'll be my live CV",
"Next step are levels and movement",
"Thanks!"];
var currentText = 0;
var timeLastText = 0;
$(document).ready(function(){
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var sprite;
var smashed_glass;
var fsm = StateMachine.create({
initial: 'introduction',
events: [
{ name: 'play', from: 'introduction', to: 'start_speaking' },
{ name: 'break', from: 'start_speaking', to: 'break_screen' },
{ name: 'quit', from: 'break_screen', to: 'broken_screen' }
],
callbacks: {
onenterintroduction: function() { },
onleaveintroduction: function() {
var img = new Image();
img.src = 'stick2.png';
sprite = new Sprite(img, {
walk: { x:0, y:0, frames: 3, duration: 200, height:112, width:41},
hit: { x:0, y:112, frames: 6, duration: 100, height:112, width:41,
finish: function() {
fsm.quit();
}
}
});
sprite.setAnimation('walk');
timeLastText = new Date().getTime();
},
onenterbreak_screen: function () {
sprite.setAnimation('hit');
smashed_glass = new Image();
smashed_glass.src = 'smashed.png';
}
}
});
function drawIntroduction() {
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect (30, 30, 55, 50);
}
function paint() {
ctx.clearRect(0, 0, 479, 319);
switch (fsm.current) {
case 'introduction':
drawIntroduction();
break;
case 'start_speaking':
case 'break_screen':
case 'broken_screen':
sprite.draw(ctx, 20, 319 - sprite.getHeight());
ctx.fillStyle = '#000';
ctx.textBaseline = 'middle';
ctx.font = "normal 24px sans-serif";
ctx.fillText(texts[currentText], 20, 120);
if (fsm.current == 'broken_screen') {
ctx.drawImage(smashed_glass, 0, 319 - smashed_glass.height);
}
break;
}
}
var lastTime = new Date().getTime();
setInterval(function() {
var now = new Date().getTime();
switch (fsm.current) {
case 'introduction':
if (now - lastTime > 3000) {
fsm.play();
}
break;
case 'start_speaking':
if (sprite.nextFrame(now)) {
if (now - timeLastText > 3000) {
timeLastText = now;
if (currentText == texts.length -1) {
fsm.break();
} else {
currentText++;
}
}
}
break;
case 'break_screen':
sprite.nextFrame(now);
break;
}
paint();
}, 50);
});
</script>
<body class="center">
<div>
<section>
<div id="film_scene"><canvas id="canvas" width="479" height="319"></canvas></div>
<div id="footer-boxes" class="group">
<a class="footer-box" id="developer" href="#">
<h5>Developer</h5>
<p>I've been working as a Developer for 9 years</p>
</a>
<a class="footer-box" id="management" href="#">
<h5>Management</h5>
<p>Since my first job I've had management tasks and responsabilities</p>
</a>
</div>
</div>
</body></html>