Commit 15668c82 authored by Raphaël Bastide's avatar Raphaël Bastide

Removes unused js lib + hashchange

parent a0baf220
......@@ -25,18 +25,9 @@
<!-- Matter -->
<script src="lib/matter.min.js"></script>
<!-- MatterTools -->
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script src="lib/matter-tools.gui.js"></script>
<script src="lib/matter-tools.inspector.js"></script>
<script src="lib/matter-tools.demo.js"></script>
<script src="lib/matter-wrap.js"></script>
<!-- Sound -->
<script src="lib/tone.js"></script>
<script src="js/sound.js"></script>
<!-- Car -->
<!-- <script src="js/car.js"></script>
<script src="js/launcher.js"></script> -->
<!-- <script src="lib/tone.js"></script>
<script src="js/sound.js"></script> -->
<script src="js/launch.js"></script>
<script src="js/functions.js"></script>
<script src="js/world.js"></script>
......
......@@ -36,3 +36,10 @@ function title(){
var t = d.getElementsByTagName('h1')[0]
window.setTimeout(function(){t.classList.add('hidden')},1000)
}
function testURL(){
// if (unit === undefined) {
// notifAlert('You have an undefined character in the URL')
// }else if(unit.length == null) {
// notifAlert('Try adding #bf at the end of this URL')
// }
}
......@@ -6,7 +6,7 @@ request.onload = function() {
if (request.status >= 200 && request.status < 400) {
data = JSON.parse(request.responseText);
console.log('request success');
launch(data)
launch(data, false)
} else {
console.log('json not found');
}
......
var Engine = Matter.Engine,
Render = Matter.Render,
Runner = Matter.Runner,
Composite = Matter.Composite,
Composites = Matter.Composites,
Constraint = Matter.Constraint,
MouseConstraint = Matter.MouseConstraint,
Mouse = Matter.Mouse,
World = Matter.World,
Bodies = Matter.Bodies,
Body = Matter.Body,
Events = Matter.Events;
var debug = false,
startX = 100,
startY = 200,
nextPos = 0,
lastDir = 0,
strokeWidth = 5,
w = 400,
h = 30,
rw = w + strokeWidth * 2,
rh = h + strokeWidth * 2,
alpha = "77",
ballColor = "#ec82be",
zoom = false,
timeScaleTarget = 1,
zoom = 500,
zoomTarget = 500,
counterBonus = counterTime = counterZoom = 0,
bulletTime, bonusTime, isBackInTime, checkPoint, lastCollided = false,
terrain = window.location.hash.substr(1)
function launch(units){
if (!debug) {
function launch(units, isRefresh){
var Engine = Matter.Engine,
Render = Matter.Render,
Runner = Matter.Runner,
Composite = Matter.Composite,
Composites = Matter.Composites,
Constraint = Matter.Constraint,
MouseConstraint = Matter.MouseConstraint,
Mouse = Matter.Mouse,
World = Matter.World,
Bodies = Matter.Bodies,
Body = Matter.Body,
Events = Matter.Events;
var debug = false,
startX = 100,
startY = 200,
nextPos = 0,
lastDir = 0,
strokeWidth = 5,
w = 400,
h = 30,
rw = w + strokeWidth * 2,
rh = h + strokeWidth * 2,
alpha = "77",
ballColor = "#ec82be",
zoom = false,
timeScaleTarget = 1,
zoom = 500,
zoomTarget = 500,
counterBonus = counterTime = counterZoom = 0,
bulletTime, bonusTime, isBackInTime, checkPoint, lastCollided = false
if (!debug || isRefresh) {
title()
}
if (isRefresh) {
console.log('clear');
var c = d.getElementsByTagName('canvas')[0]
c.parentElement.removeChild(c)
}
//
// if ("onhashchange" in window) {
// alert("Le navigateur prend en charge l'événement hashchange!");
// }
window.onhashchange = locationHashChanged;
function locationHashChanged() {
launch(units, true)
}
// create engine
var engine = Engine.create(),
world = engine.world;
......@@ -51,6 +68,21 @@ function launch(units){
}
});
var terrain = window.location.hash.substr(1)
// Extracting URL characters to build the terrain
if (terrain.includes('%E')) {
urlshapes = true
terrain = terrain.split('%E')
}else {
terrain = terrain.split('')
}
for (var i = 0; i < terrain.length; i++) {
c = terrain[i]
if (!nextPos){nextPos = {x:startX,y:startY}}
buildUnit(c, nextPos)
}
// Building common objects
var ball = Bodies.circle(100, 100, 100, { friction:1, frictionAir:.003, restitution: 0.2})
ball.render.sprite.texture = 'img/ball.svg'
......@@ -69,21 +101,6 @@ function launch(units){
}
// Adding common objects to the world
// Extracting URL characters to build the terrain
if (terrain.includes('%E')) {
urlshapes = true
terrain = terrain.split('%E')
}else {
terrain = terrain.split('')
}
for (var i = 0; i < terrain.length; i++) {
c = terrain[i]
if (!nextPos){nextPos = {x:startX,y:startY}}
buildUnit(c, nextPos)
}
var posY = nextPos.y
// Building terrain from the character array
......@@ -250,4 +267,5 @@ function launch(units){
runner.isFixed = true
Engine.run(engine);
Render.run(render);
} // end launch()
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment