Skip to content

Commit

Permalink
queryyyy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tunguso4ka committed Aug 12, 2024
1 parent ccc2c13 commit e66e40a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
>-</button>
</div>
<ul id="mapsbar" hidden>
<button class="selector" onclick="map_path='maps/Savannah-0.png'">Savannah</button>
<button class="selector" onclick="map_path='maps/Solaris-0.png'">Solaris</button>
<button class="selector" onclick="map_path='maps/Shiva-0.png'">Shiva</button>
<button class="selector" onclick="map_path='maps/Prison-0.png'">Fiorina</button>
<button class="selector" onclick="location.href='?map=Savannah'">Savannah</button>
<button class="selector" onclick="location.href='?map=Solaris'">Solaris</button>
<button class="selector" onclick="location.href='?map=Shiva'">Shiva</button>
<button class="selector" onclick="location.href='?map=Prison'">Fiorina</button>
</ul>
</div>
<body/>
Expand Down
34 changes: 23 additions & 11 deletions scripts/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@

// TODO rewrite it all, add more comments, add map buttons from json file

var map_path = "maps/Solaris-0.png";

const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});

let selected_map = params.map;

if (!selected_map)
{
selected_map = "Solaris";
}

selected_map = "maps/" + selected_map + "-0.png" // TODO unshitify this

console.log(selected_map);

let canvas;
let ctx;
Expand All @@ -26,7 +40,7 @@ window.onload = () =>
}

let cameraOffset = { x: window.innerWidth/2, y: window.innerHeight/2 }
let cameraZoom = 1
let cameraZoom = 0.1
let MAX_ZOOM = 3
let MIN_ZOOM = 0.05
let SCROLL_SENSITIVITY = 0.002
Expand All @@ -46,7 +60,7 @@ function draw()

var image = new Image();

image.src = map_path;
image.src = selected_map;

ctx.drawImage(image, 0, 0);

Expand Down Expand Up @@ -85,13 +99,13 @@ function onPointerUp(e)

function onPointerMove(e)
{
if (!isDragging)
{
return;
}
if (!isDragging)
{
return;
}

cameraOffset.x = getEventLocation(e).x/cameraZoom - dragStart.x;
cameraOffset.y = getEventLocation(e).y/cameraZoom - dragStart.y;
cameraOffset.x = getEventLocation(e).x/cameraZoom - dragStart.x;
cameraOffset.y = getEventLocation(e).y/cameraZoom - dragStart.y;
}

function handleTouch(e, singleTouchHandler)
Expand Down Expand Up @@ -150,8 +164,6 @@ function adjustZoom(zoomAmount, zoomFactor)

cameraZoom = Math.min( cameraZoom, MAX_ZOOM )
cameraZoom = Math.max( cameraZoom, MIN_ZOOM )

console.log(zoomAmount, cameraZoom)
}

function toggleMapsbarHidden()
Expand Down

0 comments on commit e66e40a

Please sign in to comment.