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 / Objects in darkbasic

Author
Message
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Oct 2004 20:59
Heres the deal... in my game im going to use some monsters. All of them are going to have the same basic attributes. Like health points strength stamina speed and so on. In c++ you can do this with objects, structs and classes. My question is can you do the same thing in darkbasic? Is there a such thing as classes?

If i know c++ why do i use darkbasic you may ask... well... i know c++ but not directx ...

Thanks in advance.

Dreaming of creating a highly advanced AI mind
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Oct 2004 00:19 Edited at: 7th Oct 2004 00:19
You could create a User Defined Type, and then make an array of that type...

TYPE Monster
health as integer
stamina as integer
speed# as float
ENDTYPE

Dim Monsters(10) as Monster


BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Oct 2004 00:30
Ok thanks... but how do i access the different elements of the array?

monster[5].health=5 ?

Dreaming of creating a highly advanced AI mind
Zokomoko
22
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 7th Oct 2004 17:03
yes.

monster(5).health=5
monster(5).speed#=10

monster(6).health=10
monster(6).speed#=20
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Oct 2004 19:23
Thanks a bunch! I understand now. Think ill do those declearations in a loop though

Dreaming of creating a highly advanced AI mind
Attreid
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 7th Oct 2004 19:44
why are you still using # and $ with DBP ?!
When you write "as float", you don't need anymore to put the #, and your code is cleaner without it

"He will come...the voice from the outer world,
bringing the holy war, the Jihad, which will cleanse the Universe and bring us out of darkness."
bibz1st
21
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 10th Oct 2004 02:12
but surely its easier tosee what variables are floats when looking through a lot of code, innit?

Login to post a reply

Server time is: 2024-11-27 12:23:58
Your offset time is: 2024-11-27 12:23:58