Latest Uploads
Extraterre ... .0.1 (zip)

dantheman363

Monty Teas ... Screenie 1

steve_ancell

Santa Clau ... ed his bag

waroffice

manic_platdude.png

spinal

Tetris Clone

steve_ancell

Super blues bros.

spinal

Code Snippets > AI and Movement ( Created 13 June 2007 | Last Edited 13 June 2007)

AI game Tutorial by Hotshot | No Votes
For general use
-->


Latest Comments

Posted : Wednesday, 13 June 2007, 05: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.

Posted : Wednesday, 13 June 2007, 06:03
Hotshot


thanks for commets and it is learn from people like you.

cheers

Posted : Wednesday, 13 June 2007, 06: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..)

Posted : Wednesday, 13 June 2007, 06: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.

Posted : Wednesday, 13 June 2007, 08: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.

Posted : Thursday, 14 June 2007, 08:32
Hotshot


it is very old code!
Thanks teasy and everyone too

Posted : Thursday, 14 June 2007, 13:42
iusinbello


Where is the AI??? I see only a quad followed by another quad... O_o

Latest Posts
Coder's Block
Jayenkai Thu 09:01
Consumer Lockout
9572AD Thu 06:09
Professor Oak, Honest!!
spinal Wed 23:24
Position in Mind
steve_ancell Wed 20:11
Sonic Adventure v0.x
Jayenkai Wed 07:08
FIRST!!!
steve_ancell Wed 03:55
Noel's Graduation
waroffice Wed 02:55
Monkey vs iOS tweaks
spinal Tue 22:51
Fucking Pound Sign Unicode Bullshit Bollocks
Dabz Tue 13:00
Progress / Location Bars
dna Tue 08:55
More

Latest Items
News : Newsletter #176
Jayenkai Sat 04:49
News : Newsletter #175
Dabz Tue 09:38
Blog : Snow: More Material Junk
Cower Sat 23:17
Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversion
rockford Fri 13:14
Techy : AppleTV
Jayenkai Thu 09:40
Blog : Graphviz
steve_ancell Sat 14:17
Pets : Top-Down Shadow Hack
Jayenkai Tue 05:52
Snippet : JNKrunch v1.0
Jayenkai Sat 07:20
News : Newsletter #173
waroffice Fri 04:47
Blog : Material Loading
Cower Fri 02:08
Pets : I Done Won A Thing
shroom_monk Sun 11:31
Pets : Repurposing A Lexer
Cower Mon 22:06
Bah : Feeling a Little Angry
spinal Mon 11:26
News : Newsletter #170
Dabz Sat 00:34
Showcase : sbfgen
Cower Sat 16:57
More

Who's Online
Jayenkai
Fri, at 03:45
CodersRule
Fri, at 03:05
rockford
Fri, at 01:24
spinal
Fri, at 01:03
Mog
Fri, at 00:37
Dabz
Thu, at 23:11
HoboBen
Thu, at 18:50
Cower
Thu, at 18:21
Evil Roy Ferguson
Thu, at 17:34
dna
Thu, at 17:30
Link to this page
Site : Jayenkai 2006-Infinity |
MudChat's origins, BBCode's former life, Image Scaler.