123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|640|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> AI Archer

Thu, 17 Dec 2009, 05:19
realtime
trying to create AI for archer.
The archer has to determine the angle and power to shoot moving target.



you'll need this for the code:

the alien image is available on Blitz image folder:



second code:



-=-=-
me blog: fork-garden
Thu, 17 Dec 2009, 06:27
Afr0
This should have gone into 'Code Snippets'
Thu, 17 Dec 2009, 09:00
JL235
It would be more useful if it was a bit more generic. Namely if this was supplied as a library ready to be imported rather then a complete app. Users would need to pick your code apart first before they can use it. Also if the functions had lots of their values passed in rather then getting them themselves, such as the start and target locations for create_bullet. Again these would need to be edited before anyone could use your code.

Nice snippet tho.
Thu, 17 Dec 2009, 16:22
realtime
Main Program



the library


parameter for create_bullet() function

ax = bullet start position
ay = bullet start position
bx = target position
by = target position
time = when you want to hit the target? 30 means you will
hit the target after moving 30 times. if the arrow moves in
30 fps, it will hit the target in 1 second.
you can change time to any value.

for moving target. for example if the target move at 30 fps
and the arrow moves at the same rate and you want to hit the target in 2 second, then you can calculate the position of the enemy in 2 second, then you shoot the arrow with time=60. arrow will get to the target in 2 second and will hit the target.

grav# is global variable for gravitation.



-=-=-
me blog: fork-garden