O'Reilly logo

DarkBASIC Pro Game Programming, Second Edition by Joshua R. Smith, Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

User-Defined Data Types

A user-defined type (UDT) is an advanced data type in DarkBASIC that you can customize for your own needs into a complex structure containing many variables within. A structure of this type greatly reduces the number of global variables you would normally need to use in a complex game.

Defining Your Own UDT

You can define a UDT yourself using the TYPE and ENDTYPE statements, and the result is your own custom data type. Here is an example:

TYPE Person
  FirstName AS STRING
  LastName AS STRING
  Age AS INTEGER
ENDTYPE

When you’re ready to use this type, you can define a variable AS [your type] to create a new variable of the type, like any other variable:

padawan AS Person

Using a UDT

Voila, now you have a new variable using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required