-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
executable file
·115 lines (92 loc) · 3.69 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
<!DOCTYPE html>
<html>
<head>
<title>Controllable Space Spacecraft</title>
<script src="./js/animacao.js"></script>
<script src="./js/teclado.js"></script>
<script src="./js/fundo.js"></script>
<script src="./js/nave.js"></script>
<script src="./js/tiro.js"></script>
<link rel="stylesheet" type="text/css" href="./css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Audiowide|Quicksand" type="text/css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="content">
<div class="row">
<h1 class="title col-md-12 col-sm-12">Spaceship Controllable</h1>
</div>
<div class="row">
<canvas id="canvas_nave" width="500" height="500 class="col-md-12 col-sm-12"></canvas>
</div>
<div class="row">
<img class="setas" src="./img/setas.png" width="250" height="250"/>
</div>
<hr />
<footer>
<p class="footer_title">Made by Matheus Binotto</p>
<a class="footer_github" href="https://github.com/Binotto/spaceship-app"><i class="fa fa-github"></i> Github</a>
</a>
</br>
<a class="footer_linkedin" href="https://www.linkedin.com/in/matheus-binotto-a51787143/">
<i class="fa fa-linkedin"></i> My Linkedin
</a>
</footer>
</div>
</div>
<script>
var canvas = document.getElementById("canvas_nave");
var context = canvas.getContext("2d");
var teclado = new Teclado(document);
var animacao = new Animacao(context);
var imgNave = new Image();
imgNave.src = "img/nave.png";
var imgEspaco = new Image ();
imgEspaco.src = "img/fundo-espaco.png";
var imgEstrelas = new Image();
imgEstrelas.src = "img/fundo-estrelas.png";
var imgNuvens = new Image();
imgNuvens.src = "img/fundo-nuvens.png";
var nave = new Nave(context, teclado , imgNave);
var carregadas = 0;
var total = 3;
imgEspaco.onload = carregando();
imgEstrelas.onload = carregando();
imgNuvens.onload = carregando();
imgNave.onload = function(){
nave.x = canvas.width / 7 - imgNave.width / 2;
nave.y = canvas.height - imgNave.height;
nave.velocidade=10;
//animacao.ligar();
}
function carregando (){
carregadas++;
if(carregadas == total){
iniciar();
}
}
function iniciar(){
//passo- instanciar o fundo
var fundoEspaco = new Fundo(context, imgEspaco);
var fundoEstrelas = new Fundo(context, imgEstrelas);
var fundoNuvens = new Fundo(context, imgNuvens);
//setando as velocidades
fundoEspaco.velocidade = 3;
fundoEstrelas.velocidade = 7;
fundoNuvens.velocidade = 10;
animacao.novoSprite(fundoEspaco);
animacao.novoSprite(fundoNuvens);
animacao.novoSprite(fundoEstrelas);
animacao.novoSprite(nave);
animacao.ligar();
}
</script>
</body>
</html>