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 / Strange array problem...

Author
Message
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 25th Apr 2007 03:13
Hi

I am making an enemy system for my game and there seems to be a trouble with the enemy object array.

Here is the code which initialises it:



It returns an error that OBJ_ENEMY_A is not a declared variable. It seems to think the OBJ_ENEMY_A array is a variable...

Could anyone help?

Thanks!

~ z_man ~
programmer ML
19
Years of Service
User Offline
Joined: 1st Jun 2005
Location:
Posted: 25th Apr 2007 03:24
You need to set a value to CAP_ENEMY_A (like 1000 or w.e number you want it to go to) unless you did this earlier in your'e program and just did not include that part.
I hope that helps
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 25th Apr 2007 03:47
Yeah, all the constants have been previously set.

~ z_man ~
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2007 04:14
The following snippet compiles and runs in DBP for me with no errors:



TDK_Man

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 25th Apr 2007 04:41 Edited at: 25th Apr 2007 04:43
Hmm, that is strange. I have uploaded a screenshot of the error, maybe that could help explain more.

Thanks!

~ z_man ~

Attachments

Login to view attachments
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2007 07:31 Edited at: 25th Apr 2007 07:32
I noticed that on many of the lines which you have Rems on, you don't put a colon in before the rem - as you should do. Eg:

DIM OBJ_EMEMY_A(1000)[b]: Rem Enemy type 1 array make it possible to have up to 1000 enemies[/b]

The colon in that line I inserted myself - it's missing in your code.

Might be the problem...

TDK_Man

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 25th Apr 2007 10:14 Edited at: 25th Apr 2007 10:18
I re-wrote the code without comments and it seems to be working now. It probably was the : giving me the problem. Thanks TDK!

I may as well ask one more question. What would be the best way to do the enemy system without putting a big load on the computer. Am I doing the right thing using an array? I noticed the help file had something about lists, stacks etc...would they be better to use? Thanks!

~ z_man ~
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 25th Apr 2007 13:28 Edited at: 25th Apr 2007 13:37
Problem was that you wrote DIM obj_eMemy_a(1000) and then used DIM obj_eNemy_a(), mistook the M for an N, or the other way around. Just typo.
Also, TDK is right about colons.

Further on my stuff at...
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 25th Apr 2007 13:59
Ah lol, it was that simple! I must of read over it because M looks a lot like N, and maybe because I was a bit tired. Thanks,

z_man

~ z_man ~
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2007 18:22
Lol

I missed that too! I copied and pasted your code and actually renamed the variables before I noticed the missing colons. In the process of renaming I inadvertantly corrected the incorrect letter M.

When I spotted the Rem problem, I'd already fixed the problem and didn't know it!

TDK_Man

Login to post a reply

Server time is: 2024-09-25 21:17:54
Your offset time is: 2024-09-25 21:17:54