So yea... i couldn't help myself...
I desided to spent half an hour figuring out a better math form for the basket ball game at onlinegames.com
It is still not a 100% perfect, but now it will also set the aim correctly for basket balls in line with or above the basket.
It scores clean baskets about 95% of the time id guess.
Link:
http://www.onlinegames.com/basketball/Here is how it went when i tested it
Attachment:
BasketFirstPlace.jpg [ 21.69 KiB | Viewed 9636 times ]
And here is the BE code
Code:
begin
Image.Find location of first occurrence on screen("C:\basketBall.png", "25", "ballX", "ballY")
if Variable.Is greater than (Math)("ballY", "600")
begin
Variable.Evaluate (Math)("{basketY} - (({ballY} - {basketY}) / 2)", "resultY")
Variable.Evaluate (Math)("{basketX} + (({ballX} - {basketX}) / 3) + (({ballX} - {basketX}) / 25)", "resultX")
end
if Variable.Is less than (Math)("ballY", "601")
begin
Variable.Set("resultY", "1")
Variable.Evaluate (Math)("{basketX} + 5 + (({ballX} - {basketX}) / 2) - ({ballX} / 85) - (({ballY} - {basketY}) / 8 )", "resultX")
end
Mouse.Click button at coordinate("{resultX}", "{resultY}", "left")
end
Again, you need to create two variables of your baskets position:
(You can find the coordinate using Investigator, just like i did in the earlier basket tutorial video.)
basketX (the X coordinate of the baskets center position)
basketY (the Y coordinate of the baskets center position)
On my machine basketX is 160 and basketY is 410.
Also remember to create a image of the basket ball and save it at C:\basketBall.png (or somewhere else, and change the path in the macro)
How to find the baskets coordinates, and create the image of the basket ball, just do exactly as i did in the first basket ball macro tutorial
(You can see the video tutorial @
YouTube :
http://www.youtube.com/watch?v=kctMU65yxWc)
Here is the
(old and less than perfect) macro as a download (drag it in to your BE main window macros to install)
Attachment:
for fun.basket.bem [13.61 KiB]
Downloaded 825 times
(Remember to update the image of the basketball)
Enjoy
UPDATE:A truly amazing macro has been
posted by Papatsonis.Ive chosen to copy it here, to make sure everyone will see it.
It is by far better than what i managed to come up with.
Great work Papatsonis! And thank you for sharing.
this is the macro he posted, go to page 3 to see his description of the development-process.
Code:
begin
Image.Find location of first occurrence on screen("C:\xxxxx\basketball.png", "25", "ballX", "ballY")
Variable.Evaluate (Math)("({ballY}-{basketY})/({ballX}-{basketX})", "R1")
Variable.Evaluate (Math)("(2*{R1}*{basketX}+{tanF}*({basketX}+{ballX}))/(2*({R1}+{tanF}))", "M")
Variable.Evaluate (Math)("{M}-{basketX}", "p1")
Variable.To power of (Math)("p1", "2")
Variable.Evaluate (Math)("{ballX}-{M}", "p2")
Variable.To power of (Math)("p2", "2")
Variable.Evaluate (Math)("({p1}*{ballY}-{p2}*{basketY})/({p1}-{p2})", "B")
Mouse.Double click button at coordinate("{M}", "{B}", "Left")
end
It requires 3 variables + an image of the basketball (view the video tut, to see how to get them).
These are the variables I'm using (you need to click "Display Variables" inside the wizard, once you edit the macro to fit your screen resolution (I'm running 1440x900)).
tanF = 1
basketX = 160
basketY = 410
Download: (
new and improved version, created by papatsonis)
Attachment:
onlinegames.com.basket.bem [10.79 KiB]
Downloaded 806 times
This is how it went when i tested this one:
Attachment:
rank.png [ 4.82 KiB | Viewed 9435 times ]