ajout fonction recup position comme spacetrader

Daniel-alias-la-puissance
Melro Serdoura Daniel ago%!(EXTRA string=1 year)
parent 9f3104d8ff
commit 37c2813315
  1. 5
      css/style.css
  2. 7
      index.html
  3. 33
      js/main.js
  4. 33
      test.js

@ -0,0 +1,5 @@
canvas {
width: 50%;
border: 2px solid black;
border-radius: 5px;
}

@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
@ -11,6 +12,10 @@
<title>Document</title>
</head>
<body>
<main class="main-window">
<input id="token" type="text">
<br>
<canvas id="canvas"></canvas>
</main>
</body>
</html>

@ -1,4 +1,4 @@
let token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGlmaWVyIjoiQU5OTk5VTEFYMTIyNSIsInZlcnNpb24iOiJ2Mi4xLjEiLCJyZXNldF9kYXRlIjoiMjAyMy0xMS0wNCIsImlhdCI6MTcwMDIyNDU5MSwic3ViIjoiYWdlbnQtdG9rZW4ifQ.r05mWtD5FjC4s6Td-ycmHdzL7C2s75lz3q7OBmWeCqUUZ1ejPsRGQRWJDPmIh1kAqO4D9FFs3GCTPZUn1KsnQ-xmDvsIi_mqC1gJV-Q0irI7gwfsGXbfLaVCXo-Q98C_QWRh-O_xkrbhJkCcvnwdEhZm7FnZ3PL4XXKrG0XNa98JrnmG0qlz0cv8V9Q0sSIwXZbvA9BrhuV8PK7_YzPc6LZuNqgPeKiX_B-tSIHHl6Sr1EzuydnczmuS-xKQnbhmcqnpaCXzQmJr7tA8KLgu70KqpPCvA8AI6PLmBlvPWtZ20RdzezqlBh6S9SrBzQ9R0zr_9RyJxq28ws2jnHpVPw";
let token = "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGlmaWVyIjoiQU5OTk5VTEFYMTIyNSIsInZlcnNpb24iOiJ2Mi4xLjEiLCJyZXNldF9kYXRlIjoiMjAyMy0xMS0wNCIsImlhdCI6MTcwMDIyNDU5MSwic3ViIjoiYWdlbnQtdG9rZW4ifQ.r05mWtD5FjC4s6Td-ycmHdzL7C2s75lz3q7OBmWeCqUUZ1ejPsRGQRWJDPmIh1kAqO4D9FFs3GCTPZUn1KsnQ-xmDvsIi_mqC1gJV-Q0irI7gwfsGXbfLaVCXo-Q98C_QWRh-O_xkrbhJkCcvnwdEhZm7FnZ3PL4XXKrG0XNa98JrnmG0qlz0cv8V9Q0sSIwXZbvA9BrhuV8PK7_YzPc6LZuNqgPeKiX_B-tSIHHl6Sr1EzuydnczmuS-xKQnbhmcqnpaCXzQmJr7tA8KLgu70KqpPCvA8AI6PLmBlvPWtZ20RdzezqlBh6S9SrBzQ9R0zr_9RyJxq28ws2jnHpVPw";
let offset = {
x: 10,
y: 10
@ -15,7 +15,7 @@ function initGame() {
Accept: 'application/json'
},
processData: false,
data: '{\n "faction": "COSMIC",\n "symbol": "ANNNNulax1225",\n "email": ""\n}'
data: '{\n "faction": "COSMIC",\n "symbol": "Daniel123",\n "email": ""\n}'
};
$.ajax(settings).done(function (response) {
@ -31,7 +31,7 @@ function getAgent() {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`
Authorization:token
}
};
$.ajax(settings).done(function (reponse) {
@ -82,32 +82,5 @@ function getSystem(system) {
});
}
function drawSystem(wayPoints) {
const canvas = document.getElementById("canvas");
let w = canvas.width;
let h = canvas.height;
const ctx = canvas.getContext("2d");
wayPoints.forEach(wayPoint => {
switch (wayPoint.type) {
case "PLANET":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'green');
break;
case "ASTEROID":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'blue');
break;
case "GAS_GIANT":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'red');
break;
}
});
}
function drawWaypoint(wayPoint, ctx, w, h, color) {
ctx.beginPath();
ctx.fillStyle = color;
ctx.arc(wayPoint.x/offset.x + w, wayPoint.y/offset.y + h, 1, 0, 2 * Math.PI);
ctx.fill()
}
getAgent();

@ -1,7 +1,18 @@
'use strict'
//lister vaisseau
const token="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGlmaWVyIjoiSEFNRE9VTEFITCIsInZlcnNpb24iOiJ2Mi4xLjEiLCJyZXNldF9kYXRlIjoiMjAyMy0xMS0wNCIsImlhdCI6MTcwMDIyNDI3MSwic3ViIjoiYWdlbnQtdG9rZW4ifQ.LNKY3vcOZIjiHUj-Z9z8kgNDqpQgB63u_6ceibfHQX-U1ox2bRjQqlSMnSjvUsXkx1G8qIDQUP9Sl-uuiHNzdtq1TmQD4x6c0nIEPNrP_OUbQSP98JZ2-xrp6h4TfXnK_o8OPqhpbRIH9iklnSrXswUZg6H2Cy78yS4sVaftiq0nBH5TLK4k5sEe5MVvhLiAuPAlNhYHUZdXP-T1y6PmmIim5d-0fwetkuC4Q2PLZp5Qg3b_2Bfy2GIUj4nI9m1e6ukaeuIF6VMYrsDUiBXD7jGrdFj2J2ZBrXKJQdQRfMKcUNpMqKdwM606S8VFDo6QHUxB5Rgi9GHFWGEKEMyBCQ"
const token="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGlmaWVyIjoiREFOSUVMMTIzNCIsInZlcnNpb24iOiJ2Mi4xLjIiLCJyZXNldF9kYXRlIjoiMjAyMy0xMS0xOCIsImlhdCI6MTcwMDgzMjc4MSwic3ViIjoiYWdlbnQtdG9rZW4ifQ.JIOfLaTzMeV4nrZ4tI8jdwrLyuNiqbMdXvXcNQfr1swHRBoIz39ozF6n33NOA7Zhp6frCXO8lflrDH2BTobOes5e2Q0BqNTj0Xq3MJeCc6QDsywv_doiIenDbf3gY7Aju_gC3z3u0uw0IqLhgxFIurlFgdXhsXX466i71sPrK8PPtGezTqB7_b7umAh3AknAuAaGi5no5VsvhCDJjH_Sb5HNkCYCvkENTm_INY5cprizOXjwYJd_91-b3ChMyJwMKJH9t68_rmDtZrU757sqSpDWE6ugh2auXEQXh3Am-BjBP1W6hlPjrOsxodD4mGYMgX8uYmZMRubIze0eu8FiNA"
$('#canvas').on('click',function(e){
console.log(getMousePosition(e, $('#canvas')));
function getMousePosition(e, canvas) {
let rect = canvas.offset();
return {
x: (e.clientX - rect.left) - canvas.width()/2,
y: (e.clientY - rect.top) - canvas.height()/2
};
}
})
const ListMyShips = {
async: true,
crossDomain: true,
@ -17,8 +28,7 @@ const ListMyShips = {
});
//recuperer le systeme ou on est
getAgent();
function getAgent() {
function getSystem() {
const settings = {
async: true,
crossDomain: true,
@ -26,7 +36,7 @@ getAgent();
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: token
Authorization:token
}
};
$.ajax(settings).done(function (reponse) {
@ -35,6 +45,8 @@ getAgent();
});
}
getSystem();
//lister les points du systeme
function getListWaypoint(system) {
const settings = {
@ -46,14 +58,14 @@ function getListWaypoint(system) {
Accept: 'application/json'
},
data:{
limit:1,
page:5
limit:20,
page:1
}
};
$.ajax(settings).done(function (response) {
console.log(response);
let waypoint = "X1-FH15-EB4C"
let waypoint = "X1-DZ90-EZ5C"
console.log(waypoint)
travel(waypoint)
});
@ -78,7 +90,8 @@ function travel(waypoint)
$.ajax(travelShip).done(function (response) {
console.log(response);
});
}
function clickTest(MouseX,MouseY){
console.log(MouseX);
console.log(MouseY);
}

Loading…
Cancel
Save