confusion

Blitz3D Forums/Blitz3D Programming/confusion

luggage(Posted 2004) [#1]
Hello

I'm quite new to Blitz3d and was wondering if there were any articles that compare it to C?

I've been coding in C for years and getting my head around some of the stuff in Blitz3d is a little tricky.

eg.

1) I'm using Protean and created a project but how does Blitz know where to start? There is no main().

2) If I write code outside of a function in what order does it get executed if I have bits of code in several files?

3) What actually happens with the variables? Say I have 'temp = MyFunc()' When does temp get created? Destroyed? Should I care?

4) How does the Type stuff work? It's supposed to be like a structure right? I have some code which does 'player1.Player = CreatePlayer()'. Inside the function it does 'p.Player = New Player' What's player1, what's p? Where is getting these from? When I want to access this player it has to 'For p.Player=Each Player' - there's that 'p' thing again!

5) One of the elements of the Player type has 'Field entity'. What type is this? It calls p\entity = CreatePivot().

6) There's a toggle for wireframe and the code is 'wire = NOT wire' which is fair enough but I haven't created wire anywhere, let alone initialised it.

7) How do I free up my mesh when it's no longer needed?

Hope someone can clear some of these up.

Thanks!

scott


Rhyolite(Posted 2004) [#2]
I am no expert, but here goes:

1) Consider anything not in a function or sub-routine as being in main().

2) Normally code outside of functions/routines gets execute etop to bottom, but with Protean be aware of the order you have included any 'include' files.

3) Blitz will 'intelligently' create variables as it needs them, but you are betting declaring them in advance. In your 'main()' code you can declare GLOBAL variables which are accesible in your functions. In 'main()' and functions/routines you can declare LOCAL variables which are only available within that func/routine/main and are destroyed when func/rout exited. You can pass variables into functions and return a single varaible.

4) Will leave that one for now ;)

5) As 4

6) Blitz has already 'intellignetly' (dont ask me exactly how) initialised it as zero (btw, this is 'basic' standard, not specific to blitz).

7) FreeEntity

Does that help?

Rhy


luggage(Posted 2004) [#3]
Excellent! Have just read the tutorial on Types so I think I have that sorted. When I write C code I have a habit of putting any globals for a module in one structure. So if I have a player.c then there would be a playerGlobs structure that holds any globals - just keeps it tidier. I also start all the functions with Player_ to make it more obvious where the function is kept. I can keep these practices going now.

Thanks


Rhyolite(Posted 2004) [#4]
Types
=====
This was hard to get my head around, and although I think I understand it not sure I can explain it!! Hopefully someone better will help out, but here are a few pointers. I will explain them how I (thats ME) understands them).

A TYPE is a collection of fields. Each FIELD is a variable and can be an integer, float or string. You access fields as typename\fieldname.

The 'p' and 'player1' are both variables or handles pointing to a 'Player' TYPE object/collection. They could both be pointing to the same object or different ones.

'Field entity' is a variable named 'entity' within your type. The 'entity' has no special meaning and is probably used as a handle to a real entity.

Rhy


Rhyolite(Posted 2004) [#5]
Yes, you can keep all your global variables in a type which is especialy useful in Protean when using type intellisense (so you get a pop up box with all the fields listed). Only 'possible' down side to this is speed, but in a few tests I did there was no 'significant' drop in speed even when compared to using CONSTANTS.

How you name your functions is up to you, but I do the same thing as this allows Protean to list reletead functions together in the constructs overwiew (alphabetically listed).

Rhy


verfum(Posted 2004) [#6]
Keep an eye on www.EzBlitz.com

Apologies for speed of development - I do too much programming at work and the impetus is lost when I get home and the pub beckons :)


big10p(Posted 2004) [#7]

Apologies for speed of development - I do too much programming at work and the impetus is lost when I get home and the pub beckons :)



Amen to that! lol. I can certainly relate to when I was programming full-time as a 'job'. :/