We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am creating a game that uses an Arduino/IMU as a controller input, and am interested in figuring out the best way to create a good way to 'map' a score that is calculated based off the distance from a point to a reference line.
I do have a section of some code, this is what I'm working with at the moment (writing in Python):
x_avgVal = (x_total / len(lx))/10000 # X input value y_avgVal = (y_total / len(ly))/10000 # Y input value if(posY < 700): # Reference line only drawn if level hasn't been completed. Very hacky... stroke(255) noFill() line(width/2,height/2-200,width/2,height/2+200) noStroke() fill(255) posX = posX - x_avgVal posY = posY + y_avgVal ellipse(posX ,posY,3,3) posScore = (500 - posX) / 300 #Calculating score cScore = cScore - abs(posScore) if(posY >= 700): if(state == True): background(0) text("You scored a " + nf(cScore,2, 2) + "% accuracy", width/2, height/2) text("Press space to play again", width/2, height/2+100) state = False posY = 1000 #Once its hit a trigger it will stay until reset if keyPressed: #Reset the score if key == ' ': cScore = 100 posY = height/2 - 200 posX = width/2 background(0) state = True`
The problem is this is very hacked and the only thing it will work with is a line, as the 'score' is only calculated based of the Y difference. What do you think the best way would be to do this for something like a circle, or a square, triangle, custom shapes etc etc.