-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|520|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> AI and Movement


 
Hotshot
Created : 13 June 2007
Edited : 13 June 2007

AI game Tutorial






 

Comments


Wednesday, 13 June 2007, 06:30
JL235
That's not really AI, it's just following the player continuously. AI is suppost to have decisions, so it might track the player but be off at some point. This helps to give the illusion (if only minor) that you are playing against someone.

Even then, it only moves in eight directions. You should find the angle between the computer and the player, then move along the x and y axis using sin and cos. This will also fix the bug that the computer moves faster diagonally then when moving vertically or horizontally (as it's moving both vertically and horizontally).

You should NOT capitalize a non-constant. This is because by capitalizing a constant it helps to show it's a constant. If I wrote 'SPEED' and 'angle' in my code, you can then know instinctively that SPEED is a constant and angle isn't.

Finally, there are tags for code, [ code ] and [ /code ] (with the spaces removed). There used to be a window explaining those tags.
Wednesday, 13 June 2007, 07:03
Hotshot
thanks for commets and it is learn from people like you.

cheers
Wednesday, 13 June 2007, 07:27
Jayenkai
When properly dealing with Constants*, I prefer to symbolise which is which using a more specific manner, like placing "C_" before the variable name.
Beats having to uncapitalise everything else, anyway.

(* Honestly though, I rarely use constants..)
Wednesday, 13 June 2007, 07:58
JL235
The convention used in the industry, and by the vast majority of programmers, it to fully capitalize constants and not to fully capitalize non-constants.
Wednesday, 13 June 2007, 09:39
Teasy
Or use syntax highlighting where constants, globals and locals all have a different visual representation (note explicitly to read the code with advanced syntax highlighting )

Nice tutorial, Hotshot
It's very clear when reading it.
Thursday, 14 June 2007, 09:32
Hotshot
it is very old code!
Thanks teasy and everyone too
Thursday, 14 June 2007, 14:42
iusinbello
Where is the AI??? I see only a quad followed by another quad... O_o