Re: So i'm learning B3D
Posted: Tue Apr 08, 2014 12:44 am
Sorry if I don't make any sense here, I'm not the best at explaining things but I'll try to keep the jargon as low as possible.
creates a new Sprite variable called 'Character', and while doing so, also creates the integers 'ID' and 'char_tex' for 'Character' in particular.
What Read does is assigns data found in a 'Data' entry to variables sent as parameters to the function, then assigns an internal pointer to the location after the last data read. For example, the first call of Read is equivalent to
The program knows where the last call to Read ended, so when the next call of Read is equivalent to
In this case 'Sprite' is the name of the type and 'Character' is the temporary variable name. For example, the lineCombine wrote: Alot of things about the TYPEs tutorial confuses me.
For example, it never explains how exactly types are named. In the tutorial, it saysThen it stops referring to that type and just starts using a type that seems to be called "Character" from then on, Which I presume is seperate from "Sprite"Code: Select all
Type Sprite Field ID, char_tex End Type
Code: Select all
Character.Sprite = New Sprite
Additionally, the tutorial presents this code:Code: Select all
For C = 1 To 3 ; 3 Characters Character.Sprite = New Sprite Character\ID = CreateSprite() Read img$, X, Y, Z Character\char_tex = LoadAnimTexture( img$, 7, 32, 48, 0, 4 ) EntityTexture Character\ID, Character\char_tex, 1 HandleSprite Character\ID, 0, -1 ScaleSprite Character\ID, 2, 2 EntityAutoFade Character\ID, 100, 120 PositionEntity Character\ID, X, Y, Z NextCode: Select all
Read img$, X, Y, Z
Since there aren't any other Data segments, the Read function defaults to starting at the first entry in 'Characters'. If you have other sets, the Restore function can be used to specify another block.First off, How does this know which data to look at?
img is a temporary string assigned by the Read function in the previous line (that the author probably should've explicitly instantiated in a tutorial for readability, but whatever)Secondly, img$ doesn't pop up anywhere else except here:
"Character\char_tex = LoadAnimTexture( img$, 7, 32, 48, 0, 4 )"
Which sets the image to the sprite defined (see below for the data)
The data used by the read command is this:
Code: Select all
.Characters Data "char2.bmp", 10, 0, 10 Data "char3.bmp", -10, 0, 10 Data "char4.bmp", 0, 0, 10
But I don't know how the read command knows to look at this data.
Code: Select all
Read img$, X, Y, Z
Code: Select all
img = "char2.bmp"
X = 10
Y = 0
Z = 10
Code: Select all
img = "char3.bmp"
X = -10
Y = 0
Z = 10