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 / DBPro Question... Are classes available?

Author
Message
Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 4th Sep 2009 16:45
Are you able to make classes in DBPro?

If so, how would you go about making one?

DBPro!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Sep 2009 17:00
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 5th Sep 2009 01:31 Edited at: 5th Sep 2009 01:32
I thought you were talking about classes to learn DB - which made IanM's response quiet funny .



Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 5th Sep 2009 02:30
Ah, I see.


So to control multiple things at once, while using multiple variables for each one, I could use an array instead?

Let's say I want to control the ID, X, Y, and color of 307,200 individual pixels.

Could I do that with a single array? (Or if multiple arrays for numbers 0 - 1000, etc.)

DBPro!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Sep 2009 03:26
Use the TYPE...ENDTYPE statements to build a UDT, and then use that to define your array.

I'd give you the example, but your request seems a little strange to me so I probably don't understand exactly what you want...

An ID for a pixel? Surely a pixel has a colour, and a set of pixels make up a bitmap, with the pixels being identified by their X/Y coordinates within the bitmap - that equates to a 2D array of the required dimensions, holding the pixel colour and nothing more - that is simply 'DIM MyBitmap(640,480) as dword'.

Or you could create a secondary bitmap of the correct dimensions and use the DOT/POINT commands to write/read from it.

Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 5th Sep 2009 03:32 Edited at: 5th Sep 2009 03:32
UDT?

Basically I'm making a falling sand game, and I want each pixel to have it's own ID number for referencing it's velocity, type, x, and y values.

DBPro!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 5th Sep 2009 05:57
Yes, you could say something like this:

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Sep 2009 07:02
Quote: "UDT?"


It stands for User Defined Type. It's used to create your own array filled with different data types (instead of all strings or all integers). Neuro Fuzzy shows a UDT in his code snip.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Sep 2009 09:39
It's equivalent to a struct. (Similar to a class, but can't support methods, basically).

Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 6th Sep 2009 04:31
Thanks everyone.
I'm starting coding now.

DBPro!

Login to post a reply

Server time is: 2024-11-25 01:53:34
Your offset time is: 2024-11-25 01:53:34