Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / help with arrays

Author
Message
pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 21st Jun 2007 19:58 Edited at: 21st Jun 2007 20:38
i made a game and loaded 20 enemies..i am trying to give each enemy 10 hit points by using arrays...this is the code for my array


thanks for any help
pirate

aaarg!
pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 21st Jun 2007 23:41
i sure would appreciate any help that i can get..i have looked at almost all of the posts on arrays but i am still having problems.. i would hate to have to rewrite the whole program...even if you can just give me a few pointers it would be great...
pirate

aaarg!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 23rd Jun 2007 08:08
What specifically is wrong with it? Just by glancing at it I don't see any problems.


Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Jun 2007 03:58
Here's another Array Tutorial. However I really can't see what's wrong with the code. What error(s) is it returning?

pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 26th Jun 2007 05:25
it has something to do with the object=intersect objectand the way the code is used with the enemyhp((object-16000)+1...etc
the error is array is out of bounds or does not exist..

the code that i got most of this from used the pick object command instead of the intersect object..but i did not like just clicking on the enemy to shoot them it was not realistic....

i really appreciate you taking the time to try to help.
pirate

aaarg!
pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 26th Jun 2007 19:33
i appreciate your help windowskiller but i still get the same error message..if you know of a good way to load multiple enemies and kill each one indevidually by reducing their health, i would appreciate any guidance you can give me..i have only been programming with dbp a couple of years and this is my biggest project...my wife changed computers and somehow this program was lost, i had it working before but i cannot remember how i did it
have a good day, pirate

aaarg!
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 27th Jun 2007 01:34 Edited at: 27th Jun 2007 01:34
Here's an example I just made for ya. It handles 20 enemies, each with 100 health getting reduced by 10 when you are hitting them. Ignore the "on screen display" stuff, for it is there so you can view the instructions and has nothing to do with the enemy health stuff. It may look confusing but read carefully...



pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 27th Jun 2007 02:53
thank you sixtysquares this is what i needed and i got it modified to work in my program now everything is working like its supposed to....you rock!!
pirate


thanks to everyone, i appreciate it...

aaarg!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Jun 2007 06:53
pirate

I have to ask this...

Do you understand all about arrays now, or did you just bodge the code you were given to make it work in your program?

If it's the first, then great. If it's the second, then you are no better off now than you were before. The next time you have a problem with arrays you will be back here asking for more code.

That's why I try to avoid answering questions with code if at all possible with complete newcomers. All it teaches someone is how to copy and paste in Windows!

It's much, much better to point someone in the right direction so they can go away and learn how to do something themselves - and come back here if they are stuck on something.

TDK_Man

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 27th Jun 2007 14:37
@pirate: You're welcome

@TDK: You make a good point. Hopefully he understands the code that I wrote for him and why it works...

pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 27th Jun 2007 18:28
lets put it this way tdk i don't know if i understand everything about arrays but i certainly know a lot more thanks to all you guys that took the time to help me..i saved all the tutorials and code so maybe i got all i need...sometimes i can learn faster by looking at code that is right and comparing it to mine which is usually wrong and see what i did wrong..i am usually pretty close but i make tiny mistakes..in programming its the little things that will get you. the way my array was set up was perfect, the problem was the way i used the word object with the intersect object command it should have been this way....

if INTERSECT OBJECT (x, LIMB POSITION X(player,1), LIMB POSITION Y(player,1), LIMB POSITION Z(player,1), OBJECT POSITION X(player),OBJECT POSITION Y(player), OBJECT POSITION Z(player))>0
if object>0 and mouseclick()=1 and fire=1
object=x
enemyhp((object-16000)+1)=enemyhp((object-16000)+1)-1
if enemyhp((object-16000)+1)<=0
thanks a lot for your help, pirate

aaarg!

Login to post a reply

Server time is: 2024-09-27 01:14:54
Your offset time is: 2024-09-27 01:14:54