Live data from Hacker News

Draggable objects

redblobgames.com

61–70 of 147 posts

Re: Draggable objects

#61
post #38

Thank you everyone! What a surprise to be on HN today. Happy to answer questions!

Very neat! The way that you precisely get to the point and then snippets are presented and discussed is fantastic. I wish to see more of these kind of detailed explanations everywhere. Code is read and understood effortlessly!

Re: Draggable objects

#62

Do graph search algorithms have applications for strategy? https://www.redblobgames.com/pathfinding/a-star/introduction... Consider a game like age of empires. The cost of attacking a village goes up when a wall is built around it. But when canon are invented, the cost goes down. Can we model each map (before and after invention of canon) and use it to plan a strategy? Same for building a port , portal or airport.

I would guess it's probably not worth it because "how much do cannons improve my overall position" is a tricky question, and making a really intelligent and sophisticated answer is not really visibly distinct to players from a stupid heuristic like a sigmoid function of how many walls the player has built. It's an amusing curiosity that you can build stupid walls and trick the AI into researching the tech, but it's better to make those walls you're paying for useful, so you can rely on that being generally true.

I think a lot about some advice I heard from the creator of Brogue. Essentially players have a tough time figuring out how AIs make their decisions and often assign complex motives to them when they don't exist. His example was he coded archers to try to maintain a position in some range band from the player as their primary motivation in a vacuum. The community would assign all sorts of supposed logic to archer behavior because in real-world environments with extra geometry or extra situational AI routines they couldn't see behind the curtain. Additionally, that most game AI exists to create a fun experience for the player, we only make it try to play well in service of that goal.

Re: Draggable objects

#63
post #38

Thank you everyone! What a surprise to be on HN today. Happy to answer questions!

That is a fantastic discussion on dragging with Javascript. Really appreciate the information.

I've a quick question. How do you restrict the dragging movement to an axis using the built-in DOM events like dragstart/etc. I had a drag & drop feature implemented using the dragstart/dragenter/dragover/drop/etc events. I couldn't find a quick way to restrict the dragging movement to the x-axis. JQuery's drag and drop API used to support it. I'm trying to use the native DOM events/api only. Any information or pointers are greatly appreciated.

Re: Draggable objects

#67
This article is about dragging, and I've run into all of the pitfalls and come to the same solutions that Amit talks about. Excellent article!

One of the hardest things I have needed to code from scratch is drag-to-reorder. It seem so natural from a user perspective, but when you get into inconsistently sized items, having to create placeholders between items, detecting edges, going down rabbitholes of box-fitting algorithms... it's a fun challenge :)

Re: Draggable objects

#68
post #38

Thank you everyone! What a surprise to be on HN today. Happy to answer questions!

Have you looked at html's built-in draggable="true" attribute and drag events?

Are there shortcomings with the built-in feature compared to your code?

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement...

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement...

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...

Re: Draggable objects

#69

The page reminded me of Ken Perlins' page: https://cs.nyu.edu/~perlin/ Yes, the Perlin noise guy among many other things.

I always wish there was more specification surrounding his Perlin noise algorithm he has on his website. For example, asking what the range of output values is does not have an easy answer.

Re: Draggable objects

#70
post #38

Thank you everyone! What a surprise to be on HN today. Happy to answer questions!

Does redblobgames.com have its own RSS/Atom feed? In its footer there is a link to the feed for your other blog, simblob.blogspot.com. I'd love to keep tabs on both of these blogs in my feed reader.

Big fan of your writing, btw!

Post reply on HN