ID:166367
![]() Aug 14 2006, 5:39 pm
|
|
I'm just making random programs to see if I know what I'm doing, and I'm having a problem with one. I have it set up so there's one group of Archers at the top of the screen, and a bunch of blobs at the bottom. The Archers stay still, but the blobs move around randomly. I have it so that every time the blobs move, each archer's checkenemy() is called, which basically sees if any blob is within 3 squares. If one is, then an arrow is created on the archer, and the arrow's Shoot() is called. Shoot() is passed the mob as an argument, and then while the arrow exists, it steps towards locate(blob). When the arrow Bump()s the blob, it deleted both. The problem I'm having is apparently an infinite loop. I'm new to programming, so I can't figure it out. If you need to see my code, just ask.
|
Ok, now I want it so arrows don't collide with eachother. Also, when too many enemies are within range, they just stop moving, until they are all killed. How would I fix this?
|
The code could potentially cause problems in ways I am not up to explaining at the moment and is just plain horrible.
mob You could use that, but it won't give you the full effect you want. I used missile() because if you used step_towards(), that could look pretty funky since it'll look how most mobs do when they walk to you in games. Well I made up a few procs in there like RemoveFromGame(), and that was just to fill in some crap, but if you want GOOD arrow movement that only takes away damage when it actually hits a target, then you should probably try pixel movement for arrows. |
It involves the use of sin() and cos(), but I don't feel like getting into it. You'll also probably need to have a custom get_dir() for pixel movement to tell you which way the arrows should go in degrees. You can look at a demo by Theodis that shows alternate movement using pixel movement, and it's in the demos section so you could either go there or do a search on it. You will also want pixel detection, which is a whole other story. :P
-Exophus |
This is the basic outline I made using bits and pieces of shoot and attack codes. It can be modified to your needs, but it should work for your needs. You may need to mod your existing code to make this work with what you have, but i garuntee it will work.