| View previous topic :: View next topic |
| Author |
Message |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Fri Jul 21, 2006 8:50 am Post subject: artificial coding |
|
|
im making a small shooting game and i want some artificial coding help wut type of codes do i have 2 use and is math.randoomseed(os.time()) needed?
thnx in advance ;) _________________ im not gay
no no ways |
|
| Back to top |
|
 |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Fri Jul 21, 2006 9:29 am Post subject: |
|
|
can some body replay ASAP!!! _________________ im not gay
no no ways |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Fri Jul 21, 2006 9:47 am Post subject: |
|
|
You need the math.randomseed(os.time()) to ensure you random numbers really are random. If you don't seed the random number generator (or if you seed it with a known value) then the number sequences will be the same each time. By using os.time to seed it you use a different number each time the program runs.
As for what type of code you need, I think you'll need to be a bit more specific.
Let us know a bit more detail and I'm sure someone can help.
HTH,
JC |
|
| Back to top |
|
 |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Fri Jul 21, 2006 10:34 am Post subject: |
|
|
ok as i said before i need to code an enemy
so wut exactly this enemy is supposed to do is shoot with a gun at the player
run towards the player if the player is far etc
so do u get the idea :S ? _________________ im not gay
no no ways |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Fri Jul 21, 2006 11:04 am Post subject: |
|
|
This is not an "OMG TEACH ME TO CODZ0R!" forum. This is ps2/psp specific homebrew dev discussion. Learn how to code before you come here, because we are not going to teach you. _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Fri Jul 21, 2006 11:11 am Post subject: |
|
|
i already know how to code but i just need alil help with artificial coding thats all can some one help me with my previous question if thats not a prob.
thnx _________________ im not gay
no no ways |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Fri Jul 21, 2006 12:14 pm Post subject: |
|
|
It's pretty easy once you break down what you want to do:
1) See if you enemy is lined up with your character (check the X or Y setting were appropriate)
2) If he is lined up use a random number to decide whether or not to shoot (if math.random(1,3) = 1 then ......... end)
As far as movement is concerned this is slightly more complicated. You first need to decide if your enemy will 'chase' your character or just move randomly. |
|
| Back to top |
|
 |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Sat Jul 22, 2006 3:20 am Post subject: |
|
|
thnx man that helped
and for the math.random()
the # i pot between the bracets e.g. 2,6
it will chose a random # between 2 and 6 right :S ?? _________________ im not gay
no no ways |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
|
| Back to top |
|
 |
omar_omar
Joined: 21 Jul 2006 Posts: 6 Location: Ontario
|
Posted: Mon Jul 24, 2006 11:24 am Post subject: |
|
|
thnx DC, that was alot of help.
and i know i shoud'nt be askin this but
wuts the definition of
math.pi
math.( dunno diffrent words here )
can somebody answer my question please if thts nnot a prob.
thnx so much ;) _________________ im not gay
no no ways |
|
| Back to top |
|
 |
be2003
Joined: 20 Apr 2006 Posts: 144
|
Posted: Mon Jul 24, 2006 11:50 am Post subject: |
|
|
pi =3.14
pi is a number used when messing with circles, maybe you should take an online geometry review(alot of the math.something is based on geometry and algebra and maybe some trig) _________________ - be2003
blog |
|
| Back to top |
|
 |
|