Quick Query

Blitz3D Forums/Blitz3D Beginners Area/Quick Query

Jono(Posted 2003) [#1]
Just wondering can this be done?, And if so how, please?, Slow but surely getting the hang of Types...

Type Pad
Field FileName = LoadImage("Pad.bmp")
Field X = ScreenWidth / 2 - ImageWidth(Pad\FileName) / 2
Field Y = 128
End Type


GfK(Posted 2003) [#2]
No, you'd have to do it like this:
p.pad = new pad

p\FileName = Loadimage("Pad.bmp")
p\X = GraphicsWidth() / 2 - ImageWidth(Pad\FileName) / 2 
p\Y = 128 

Type Pad 
  Field FileName% 
  Field X%
  Field Y%
End Type



Neo Genesis10(Posted 2003) [#3]
When you call the Type command you are building a framework for objects, not the actual objects themselves. To create an object from the framework, use variable.type = new type. replacing variable with whatever you want to call the new object and type with your framework name.

The benefit of using types is that you can have a virtually unlimited number of objects which behave in the same way as each other. An example of this could be a car type. You could have multiple cars, which essentially do the same thing, but give them different names to give them some individuality.