Skip to content

Commit

Permalink
2 file edited
Browse files Browse the repository at this point in the history
  • Loading branch information
Croc-Prog-github committed Jul 11, 2024
1 parent 7b208a8 commit 7c84238
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 3 additions & 1 deletion game/GameMood/BattleRoyal/bots/Movement-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ class MoverTS {

constructor(element: HTMLElement) {
this.element = element;
this.element.style.position = 'absolute'; // Imposta position: absolute
document.addEventListener('DOMContentLoaded', () => {
this.element.style.position = 'absolute'; // Imposta position: absolute
})
}

achieve = {
Expand Down
25 changes: 21 additions & 4 deletions game/GameMood/BattleRoyal/bots/bot1/bot1B.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const bot1 = document.getElementById('bot1');
const mover = new MoverTS(bot1);
document.addEventListener('DOMContentLoaded', () => {
const bot1 = document.getElementById('bot1');
const mover = new MoverTS(bot1);
})

//Calcola la distanza tra i 2 elementi in argomento
function getDistance(rect1, rect2) {
Expand Down Expand Up @@ -36,16 +38,31 @@ function RadarMode() { //Cerca in un raggio di 100px gli id: player || PwUP
}

if (foundElement) {
console.info("Elemento più vicino trovato nel raggio: "+radius+"): ", foundElement.id);
console.info("Elemento più vicino trovato nel raggio: "+radius+"): " + foundElement.id);
return (foundElement.id);
} else {
console.warn("RadarMode(): Nessun elemento nel raggio di: "+radius+"px");
mover.glideAt(mover.getRandomX, mover.getRandomY, 3); // Va in una posizione a caso
RadarMode();
return false;
}
}

document.addEventListener('DOMContentLoaded', () => {

// Si sposta verso la cassa più vicina
mover.glideAtIdElement('PwUP', 3)
//mover.glideAtIdElement('PwUP', 3)

RadarMode();
switch (RadarMode()) {
case 'player':

break;
case 'PwUP':

break;
default:
console.warn("MainFlow: Nessun elemento definito rilevato da RadarMode()")
break;
}
})

0 comments on commit 7c84238

Please sign in to comment.