Simple coding challenge (maybe) find last touch X,Y


#1

@CreationsOfaNoob @MR.GAM3R @ThinBuffalo and anyone else who reads this and is interested.

I watched a few Numberphile videos and got inspired a little.
The challenge is to code to find the last touch X,Y position without using the last touch blocks/commands.
Only Hopscotch shapes can be used, like the circle,rectangle,square etc.
The shapes must be a minimum of size 200%
Max number of shapes allowed to be displayed at a time are 30

A user must tap the screen, then shapes can be set to different positions,sizes(200%+) angles, go to front or back is allowed.
When a user goes to tap the screen, no sprites can be moving or changing in any way.
The challenge is how many times must a user tap the same spot on the screen for the taps X,Y position to be discovered.
When your code thinks it’s pretty close to finding the tapped position, have an emoji :sunglasses: Set to that position and have the project end.
(The tapped position guessed must be below the home,publish/icons at the screens top.)

I haven’t tried coding is before, if some of you reply saying you’ll try this challenge, then I’ll also try this challenge as well.


#2

This looks interesting :thinking:


#3

I saw some patterns,shapes made with prime numbers and thought these shape patterns could be used for this challenge in a similar way.


#4

Huh

I’m definetely going to try this!


#5

I will now as well :+1:t2:


#6

I can’t at the moment, but i’ll try later.


#8

I’ve found a solution that takes 3 or 4 taps to get a pretty good idea where the the touch location is.
I’ll wait for others i tagged to reply to this challenge.


#9

Hmm, let’s see. Without any fancy patterns, we can simply use the shapes to reduce the area of the screen by 30x with each tap (since we’re allowed 30 shapes). When the starting area (1024 x 768) is reduced to (1 x 1) we’ve found the tapped spot.

(1024 x 768) / (30 ^ n) = 1
n = log(1024 x 768) / log(30)
n = 3.99

So as an baseline, the spot can at least be found in 4 taps (assuming the same spot is tapped)

I’m curious to see how much that can be improved.


Edit: Nevermind. I forgot you said the shapes had to at least be 200% in size. That precludes the simple method I was thinking of as a baseline.


#10

Do you mean that the objects can’t change when “iPad is tapped”?


#11

This seems really cool, and I think that it would be complicated to code, but if anyone can find a solution, could you tag me? I really want to see it.


#12

I may try. It depends on whether I finish another challenge


#13

I mean when a Shape is tapped, the shapes can instantly change size,position and angle.
Just not moving around the screen when the player has to tap again.


#14

My first thought was to get the area of where the user tapped, you can have a grid of 30 rectangles covering the entire screen. However, that’s not very exact.


#15

What if you used a small character like a full stop?


#16

You are on the right track of finding the "area"
This is a clue,

The 8.ball represents where the player taps.
The yellow squares been tapped.
Four other squares then occupy a quarter of the yellow square.
The same place is tapped again. The green squares been tapped and is occupying the bottom right of the yellow square.
So the tap position is somewhere in the yellow squares bottom right corner.


#17

I’ve made this, it gets pretty close to the actual Last Touch.


#18

That’s impressive.
I have to check the code to make sure it doesn’t brake the “rules” when it comes to size.
I’ll tag you again after I check your code.

Just checked.
Your clones shrink in size after a clone is tapped.
So their size ends up less than 200%
This breaks the rules.

I appreciate the effort you put into your project.


#19

Oh yeah, apparently missed that part.


#20

Using overlapping objects to determine positions more exactly would not work, Hopscotch will only count the object at the top.


#21

Yes. So the green square is at the top of the yellow square.
The yellow squares X,Y position is all that’s needed. The yellow square can be sent away or reused again.
When a square’s tapped on the first turn, the other four squares can set their position to the tapped squares X,Y position + or minus. So each of the four squares takes up a quarter of the tapped squares space.
On the second tap when the green squares tapped, you then have four squares take up a quarter of the green squares quarter,

If you can’t understand, reply back to me with some more questions.