This repository has been archived by the owner on Dec 30, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
66 lines (60 loc) · 2.49 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
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Game in Progress - Bumper Car</title>
<link rel="stylesheet" href="css/style.css" />
<!-- Import JS -->
<script src="http://code.createjs.com/easeljs-0.7.0.min.js"></script>
<script src="libs/Box2dWeb-2.1.a.3.js"></script>
<script src="libs/jquery-1.9.0.min.js"></script>
<script src="js/bumperUtils.js"></script>
</head>
<body>
<div id="divCanvas">
<canvas width="700" height="400" id="bumperCanvas"></canvas>
<script>
var canvas = document.getElementById("bumperCanvas");
var canvasCtx = canvas.getContext('2d');
bumperGame = new BumperGame(); bumperGame.initializeWorld(canvasCtx);
// Paramètrage voiture du joueur
playerCar = new BumperCar(); bumperGame.addBumperCar(playerCar);
ctrl = new PlayerCarControler();ctrl.setBumperCar(playerCar); ctrl.attachEventListeners(document);
// Signalement pour multi-joueur
playerCar.sendCarPos();
// Gestion du rendu graphique
var stage = new createjs.Stage("bumperCanvas");
var imageJoueur = new createjs.Bitmap("img/image.png");
scale = 0.05;
imageJoueur.scaleX = this.scale;
imageJoueur.scaleY = this.scale;
imageJoueur.regX = 300;
imageJoueur.regY = 600;
stage.addChild(imageJoueur);
createjs.Ticker.addEventListener("tick", function (event) {
imageJoueur.x = playerCar.body.GetPosition().x;
imageJoueur.y = playerCar.body.GetPosition().y;
imageJoueur.rotation = (180 * playerCar.body.GetAngle() / Math.PI) + 180 ;
stage.update();
});
bumperGame.start();
</script>
<script>
(function() {
window.b2World = Box2D.Dynamics.b2World;
window.b2Vec2 = Box2D.Common.Math.b2Vec2;
window.b2AABB = Box2D.Collision.b2AABB;
window.b2BodyDef = Box2D.Dynamics.b2BodyDef;
window.b2Body = Box2D.Dynamics.b2Body;
window.b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
window.b2Fixture = Box2D.Dynamics.b2Fixture;
window.b2MassData = Box2D.Collision.Shapes.b2MassData;
window.b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
window.b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
window.b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
window.b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef;
})();
</script>
</div>
</body>
</html>