artificial coding

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Locked
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

artificial coding

Post by omar_omar »

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
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

Post by omar_omar »

can some body replay ASAP!!!
im not gay
no no ways
JC
Posts: 16
Joined: Fri Jun 02, 2006 9:30 am

Post by JC »

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
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

Post by omar_omar »

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
User avatar
Drakonite
Site Admin
Posts: 989
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

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
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

Post by omar_omar »

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
JC
Posts: 16
Joined: Fri Jun 02, 2006 9:30 am

Post by JC »

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.
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

Post by omar_omar »

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
JC
Posts: 16
Joined: Fri Jun 02, 2006 9:30 am

Post by JC »

Yep, that's correct.

Check out these links, they are pretty usefully

http://www.lua.org/pil/
http://www.lua.org/manual/5.0/manual.html
Remember, don't sweat the petty things
and don't pet the sweaty things.......
omar_omar
Posts: 6
Joined: Fri Jul 21, 2006 5:31 am
Location: Ontario

Post by omar_omar »

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
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

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
Locked