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.

2D All the way! / DBPro question, a VB indexy method?

Author
Message
Snafu
20
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 21st Nov 2003 12:08
Greetings,

Slap me upside the head if this is an obvious question to ask - I do the majority of my forum posting from work, dont have DB installed, or a manual.. so ideas just pop in to my head.

Anyone who has ever coded anything in VB, will know that you can create a control array for objects, meaning you can have numerous objects of the same name loaded, and address them by index. This makes handling AI in top down shooter games (or anything with an arcady mass enemy kinda play for that matter) really easy.

I posted a few sprites the other day, the game currently under production, is a bit of a Bubble Bobble clone. Currently got a lil flow diagram in my head, of how the enemies are going to work. I need to do something like this, in DB:

[QUOTE]
global number_of_enemies as integer
dim enemy_count as integer

for enemy_count = 0 to number_of_enemies
--insert enemy AI of enemy(enemy_count) here--
next number_of_enemies
[/QUOTE]

Are control arrays like this possible in DB? If possible, I need to assign flags to each enemy too.. including it's current direction, is it jumping, is it p**sed off yet, is it out of play etc..

If I were VB'ing this, I could do something sloppy and have captions loaded with each enemy.. or create a complex array (make this dynamic depending on the number of enemies on screen)

Feel free to shout RTFM if necessary.. it just helps if I write these kinda things down as a reminder when I get home

Cheers,
- Steve
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 21st Nov 2003 14:44 Edited at: 21st Nov 2003 14:45
IF you have dbpro you can use types in arrays. I think this do what you want.
example

type enemy_t
direction as integer
pissed as integer
in_play as integer
endtype

number_of_enemies = 10
dim enemy(number_of_enemies) as enemy_t
Would create space for 11 enemies (0 - 10) in the enemy array.
Access them like this,

for enemy_count to number_of_enemies
if enemy(enemy_count).in_play = 1
if enemy(enemy_count).pissed = 1
`do stuff
endif
endif
next enemy_count

dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard
Snafu
20
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 21st Nov 2003 15:44
aha, complete and utter brilliance. as for handling the enemies on screen, I'd just store that enemies object number as something like enemy_t.objectnumber .

cheers winch.

- Steve

Login to post a reply

Server time is: 2024-05-08 05:20:08
Your offset time is: 2024-05-08 05:20:08