Menu

I'm trying to make an in-browser tile editor from an array for an in-browser raycast engine.

Reading 0:00
15s threshold

Code thus far: https://jsfiddle.net/drkc8te5/ (its broken because it needs images which I seemingly can't provide since they're local)

I'm making an in-browser raycast engine. The current mapsize I have right now is small, only 256 pixels.

The issue is I'm already having a hard time navigating the array and changing values. So, I figured I'd make an in browser level-editor. Thing is, I'm not sure how I'd get the current index of [map] that the mouse is hovering over.

The map array renders a grid of 16x16 (256) tiles to the screen. 0 is a black space, anything else is a texture. To complicate matters I've implemented a way to move the grid around with WASD, and a way to zoom in and out with Q and E so that map editing is more convenient.

How do I detect what tile the mouse is hovering over and then translate that to the maps index.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.