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.

DarkBASIC Professional Discussion / Types and Advanced Types..

Author
Message
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 9th Jan 2003 01:28
I am trying to understand the use/uses of Types and what I call advanced types which are Types within Types, I have read and re-read the info on these in the DBPRO help files and although gaining a small idea to how they work I am left still needing some extra assistance with understanding them in both forms, would anyone knowing about the use and uses of types in maybe easier to understand form than the DBPRO help files give, beable to thougherly explain them to a person having difficulty in grasping how to use them efficiently Please?

Along with this request does anyone know how many types within types you can have and how many fields are allowed within each of these types?

Thankyou for any assistance offered, I am determined to get to grips with these one way or another..
1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name
Dr OcCuLt
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 9th Jan 2003 02:01
ok you make a game white a man in 2D space he has a X and Y POSITION so you can make a datatype call man
TYPE
Dr OcCuLt
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 9th Jan 2003 02:12
sorry about that it post on it own were was i

you make a type
Dr OcCuLt
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 9th Jan 2003 02:23
i an vary sorry about this it do it a agan

you at the code u can u the type man for the player and the moster

you can put more fields in for life or IMAGE

as for how many types within types you can have this has no real limet i think
Chroma
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: - Please Select -
Posted: 10th Jan 2003 02:06
Finally, an example of how types work. Cool!
Chroma
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: - Please Select -
Posted: 10th Jan 2003 02:06
in DBPro that is....
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 10th Jan 2003 02:07
ok after fiddling with this I have got it to work and understand it better, what I am left wondering is:-

1) can anyone confirm the amount of Types within Types you are allowed? I ask this because if I have 5 types within 1 type(total of 6) and ask an array to be AS this type, will it produce an error or make an array with 6 elements?

2) How many Fields per Type are allowed?

3) Do the amount of fields allowed relate to DWORDS, FLOATS, INTEGERS, etc.. etc.. or is there just a simple limit like 255?

1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name
the architect
21
Years of Service
User Offline
Joined: 6th Jan 2003
Location: United Kingdom
Posted: 10th Jan 2003 02:36
matto
get a book about C++ and read about classes. They should show you how programmers use type (classes in c) and remember that they are arrays, you can have more than one of a type

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jan 2003 14:59
I have no idea if there is a limit to the level of types you can have. You can have an array of types:

dim a(10) as MyType

But you can't currently have an array within a type.

I have no idea if there is a limit to the number of fields in a type, but I have never hit it if there is.
I have no idea if there is a limit to the size of a type, and again, have never hit a limit.

A bit of information that I've recently discovered, leads me to believe that a type is limited to free memory only.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jan 2003 15:00
... in it's size that is.
Dr OcCuLt
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 10th Jan 2003 16:45
you we be never able to get an array in to a datatype sadle, for this u have to ues a class DB can`t do this yet. if you want to now how datatype work you have to look in to Heap maping.i do`t now all the in&out

--Dr 0--
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 10th Jan 2003 19:44
Quote: "get a book about C++ and read about classes. They should show you how programmers use type (classes in c) and remember that they are arrays, you can have more than one of a type"


C++'s classes will tell you nothing of how user defined types work in DB!

Types are NOT arrays! types can handle multiple data types within them, arrays can not (not in DB anyway).

User defined types are a collection of data that can be accessed using a common name followed by the individual piece of data you wish to read!

See this code:


this defines that variables X and Y (of type Integer) are associated with the name (type) man.

This code:



defines the variable BOB as 'man' type. to set and get the values of X and Y contained in the man type you can use:



if you need more man types for other 'people' in this example you could dim an array to handle them:



This creates 10 'people' as type man, and because its in an array you can iterate through it easily using loops, etc...

get it?

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Jan 2003 19:47
there are no Maximum setups for Types ... however i would not recommend using more than 32 per type as it does become a little hard to understand all the subtypes, especially if you have several objects lower than that.

you should never exceed 256 data types within a type, because else it'll become a double-byte type - and Pro DOES NOT LIKE THEM at all.

Setting up types is a relatively simple task however, remember that all your doing is making an encapsulated object for use as a custom data type.

First you setup a simple type ->



now this type will be used as a position object.
now we can declare this to an object like so ->



and this will mean that now on you're 'player' you now have the position object giving you
'player.x', 'player.y', 'player.z'

however what if we don't ONLY want this for the player, and we also don't just want the position.
let say we want to make a new type which will cover health, sheild, weapon and ammunition.
well we'll create a second type like so



did you notice how we've put 'armoury' as a data type... this is because the weapon data itself should be a subtype allowing us to understand that it is a weapon rather than part of the main type.
now we make this extra type



notice how they've not been named but given 6 either yes or no slots ... and each have ammo except for 0.
well we can assume that 0 will actually be the default weapon requiring no ammunition - now that will also be used by the enemy, because you don't want them running out of ammunition or altering weapon.
However if you wanted you could have them run to the same rules as the player.

now its time to declare these


what we've done here is created the final type required, which for arguments sake will be called a 'Class Type' because it combines ALL of the 'Data Types' into a nice neat package.

we can access and fill the player data with these new objects ->
'player.obj' // player object number (0-65535)
'player.pos.x', 'player.pos.y', 'player.pos.z' // players position
'player.itm.health' // players health
'player.itm.sheild' // players sheild
'player.itm.weapon.active_1' // weapon 1 (active)
'player.itm.weapon.ammo_1' // corrisponding ammunition
etc...

now its a similar setup for the monsters, only you have an array for them ->
'enemy(0).pos.x', 'enemy(0).pos.y', 'enemy(0).pos.z' // enemy position

--||--

now a note to the team it would be nice if we could rather than armoury being setup the way it is... just have



ofcourse using the [] instead of the usual () to make sure it is recognised as an array rather than a function. Personally I think that arrays should be renamed in this fashion anyways because it does cause some confusion sometimes, especially with functions having same or similar names.

--||--

well i'll leave you now to type that all up and figure out what order it should be in ... remember you don't have to keep 'data types' to just the 'class types' because you can declare them freely on thier own.
you make want to use the 'pos' object for particle generation later

have fun and be creative because types are more versitile for keeping your programming ticking along nicely whilst neatening up the entire overall code.
and I would recommend learning howto use them well now because it is likely we'll see Array and Function encapsulation due to sheer demand

Anata aru kowagaru no watashi!
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 11th Jan 2003 22:56
Thanks for the help here guys I appreciate all of your usefull tips, special thanks to Regeta for the easy to read and well layed out help, that really cleared the remaining problems up , cheers.

1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name

Login to post a reply

Server time is: 2024-05-18 17:09:26
Your offset time is: 2024-05-18 17:09:26