mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 19:59:38 +00:00
Offset start menu according to bird location
This commit is contained in:
12
birb.js
12
birb.js
@@ -603,7 +603,7 @@ function insertStartMenu() {
|
|||||||
}
|
}
|
||||||
let x = birdX;
|
let x = birdX;
|
||||||
let y = window.innerHeight - birdY;
|
let y = window.innerHeight - birdY;
|
||||||
const offset = 30;
|
const offset = 20;
|
||||||
if (x < window.innerWidth / 2) {
|
if (x < window.innerWidth / 2) {
|
||||||
// Left side
|
// Left side
|
||||||
x += offset;
|
x += offset;
|
||||||
@@ -613,7 +613,7 @@ function insertStartMenu() {
|
|||||||
}
|
}
|
||||||
if (y > window.innerHeight / 2) {
|
if (y > window.innerHeight / 2) {
|
||||||
// Top side
|
// Top side
|
||||||
y -= startMenu.offsetHeight + offset;
|
y -= startMenu.offsetHeight + offset + 10;
|
||||||
} else {
|
} else {
|
||||||
// Bottom side
|
// Bottom side
|
||||||
y += offset;
|
y += offset;
|
||||||
@@ -629,6 +629,10 @@ function removeStartMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isStartMenuOpen() {
|
||||||
|
return document.querySelector(".birb-window") !== null;
|
||||||
|
}
|
||||||
|
|
||||||
function makeDraggable(windowHeader) {
|
function makeDraggable(windowHeader) {
|
||||||
let isMouseDown = false;
|
let isMouseDown = false;
|
||||||
let offsetX = 0;
|
let offsetX = 0;
|
||||||
@@ -695,7 +699,7 @@ let petStack = [];
|
|||||||
function update() {
|
function update() {
|
||||||
ticks++;
|
ticks++;
|
||||||
if (currentState === States.IDLE) {
|
if (currentState === States.IDLE) {
|
||||||
if (Math.random() < 1 / (60 * 3)) {
|
if (Math.random() < 1 / (60 * 3) && !isStartMenuOpen()) {
|
||||||
hop();
|
hop();
|
||||||
}
|
}
|
||||||
} else if (currentState === States.HOP) {
|
} else if (currentState === States.HOP) {
|
||||||
@@ -767,7 +771,7 @@ function draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (focusedElement === null) {
|
if (focusedElement === null) {
|
||||||
if (Date.now() - timeOfLastAction > AFK_TIME) {
|
if (Date.now() - timeOfLastAction > AFK_TIME && !isStartMenuOpen()) {
|
||||||
// Fly to an element if the user is AFK
|
// Fly to an element if the user is AFK
|
||||||
focusOnElement();
|
focusOnElement();
|
||||||
timeOfLastAction = Date.now();
|
timeOfLastAction = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user