A brand new game
for Windows, Linux, Mac, HTML5, 3DS Homebrew and more
every week,
unless exhausted!
About Games Music Pixelart Poetry Home Patreon Scores JNKPlat Petit Switch
What a Bizarre Bug
  30th April, 2019
v0.945 : Fixed a bug in the touchscreen code.


When I was playing Golf Solitaire in my android chrome browser found an odd issue where the drag and drop card gets placed in the top left of the screen as seen in the attached screenshot.


I grabbed my Android test device, and sure enough, there it was..
For some really obscure reason, any dropped card ends up stuck in the top left corner.
I opened up Firefox, Edge and most notably, Chrome for testing on the PC, but .. Nope.. Worked fine!

I then hit F12 in chrome to open the debug/console thing, and was getting no errors..
Then I hit the little "Mobile View" button..

I mean, I really wasn't expecting that to do anything, but .. Worth a try, surely..
All that "Mobile View" does is change the resolution, right?
Huh! Look at that!
The bug was suddenly occurring on my desktop, too!

Seems that switching to "Mobile View" changes any Mouse events to act as if they're Touch events, and the bug was in my Touch code.

Letting go of the touchscreen incorrectly tries to set "Mouse X and Y" co-ordinates of the last touch.. But there's no co-ordinates, because there's nothing touching the screen, resulting in the X and Y values being "N/A".

When I then tried to "drop" the card at "Mouse X,Y", it was moving the card to "N/A,N/A", which then broke the maths, because N/A obviously isn't a number. The card gets stuck at "N/A,N/A", which the system then assumes is 0,0 because.. What else could it be? So that's where the card ends up being drawn.

This is a bug that's been in the engine this entire time, and that I hadn't ever noticed because..


Because that's not what happens on iOS!!

Which begs the question : Why does it not happen on iOS?!
Maybe iOS retains the position of the previous touch?


But hey, that's one less bug to worry about!
Only another million or so to go

Thanks for the tip, @RSKGames!

Views 32, Upvotes 2
Site credits : Site built from the ground up, in php, using Programmer's Notepad 2, and a very bored Jayenkai.
(c) Jayenkai 2017 and onwards. RSS feed
Blog - What a Bizarre Bug - AGameAWeek