jakmeier / paddlers-browser-game

A multi-player real-time strategy browser game
Other
52 stars 3 forks source link

Sometimes the pointer input area is shifted #68

Open jakmeier opened 1 year ago

jakmeier commented 1 year ago

Sometimes, not quite clear under what conditions, clicking buttons doesn't work as expected. The input area is higher up on screen than the displayed area. I observed it myself once and it was also reported in https://github.com/jakmeier/paddlers-browser-game/issues/66#issuecomment-1776824240 with this helpful image:

image

jakmeier commented 1 year ago

I was able to reproduce this now. The displayed image was not always scaled true to the game coordinate ratios, which then caused wrong coordinate transformations in several places. One of them was input <-> hit box checks. The fix was in the paddle lib (https://github.com/jakmeier/paddle/pull/7)

At least this instance of the problem seems to be solved now.

@fadeevab if you have a moment to check if it is fixed for you as well, please let me know about the result. The fix should be deployed on https://demo.paddlers.ch

fadeevab commented 1 year ago

@jakmeier Okay, fix works... Many bugs though :)

  1. I had no resources for some reason at the first try. And the paddler didn't wanna move... Refreshed the screen, it helped.

  2. Invisible duck: image

  3. Resources are not being rendered correctly

image

jakmeier commented 1 year ago

Awesome, thanks for the feedback!

Many bugs though :)

Yeah I'm afraid that is the state of affairs :grimacing:

  1. I had no resources for some reason at the first try. And the paddler didn't wanna move... Refreshed the screen, it helped.

Not sure what this was. I think resource loading is naturally async and sometime delayed. Maybe there is also a bug that it gets missed completely... Resource display is very also buggy on mobile, it requires deeper investigation.

2 . Invisible duck:

Right, thanks for spotting! This problem only happens when you place the stones to the left, I missed it in my recent tests because I mechanically always place it to the right. It should be fixed now. Another case of 2D tranformations being applied wrong. (When going left to right, the image is flipped horizontally and the math to apply this transform was off.

  1. Resources are not being rendered correctly

I don't understand this one. Sticks (which you have 50) and logs (which you have 0) are different resources, perhaps that is confusing? (Resources, as they are in the game now, are generally thought through very poorly, yet.) Or was the problem that you were able to buy an upgrade even without logs? There should be a trigger that adds enough logs to buy one upgrade somewhere in the quest, it's possible there was a race condition between the logs being added and the display being updated... Again, not quite sure :shrug:

jakmeier commented 1 year ago

Oh, another funky thing you will notice when playing with the stones to the left: ducks swim backwards when the are leaving. Not really intended but it won't stop you from progressing further.

fadeevab commented 1 year ago

@jakmeier I didn't realize those are different resources :), logs and sticks. Also, overall, I would've used some game engine that would've taken off the burden of rendering the graphics so that I could've concentrated on game logic (not sure what is used now).

jakmeier commented 1 year ago

@fadeevab Very true, if my goal was to create a game rather than learning about how games are built :D

The only game engine used in Paddlers today is my own which was created by pulling out all the generic rendering code (WebGL, triangle meshes, user input, etc) which was previously part of Paddlers itself. I've reused the same game engine in a couple of other projects and kept improving small pieces of it in the past few year. Those "improvements" included breaking API changes and this is actually the source for many of the visual bugs in Paddlers today.

The history is that I started using quicksilver, which was literally the only game engine in Rust supporting WASM back in 2019. Quicksilver stopped active maintenance soon after. To allow touch input to work at all on mobile Firefox I had to fork it and the upstream PR never got merged. And as time progressed, I replaced virtually every bit of the original code with my own implementations. It was a lot of fun and a hell of a learning experience for sure. :grimacing:

In general, you will find that actual game logic and graphics are only a small fraction of the time I've put into this project. Hence, you will see poor graphics, terrible writing, unsatisfying game play, all kinds of visual bugs and so on. This is just a reflection of my personal prioritization for this project. If my primary goal would have been to create a decent game, I wouldn't have used Rust. The language simply wasn't ready for WASM gamedev in 2019, unless you really wanted to write the game-engine yourself. Also, my Rust programming skills at the time were much poorer then let's say my C++, Java, or even JS skills, which would have arguably all been better choices to create a game at the time.