Help a moddeler/designer understand programming :(

Blitz3D Forums/Blitz3D Beginners Area/Help a moddeler/designer understand programming :(

Pez263(Posted 2014) [#1]
Hello, I have been into game design for around nine years now and have always struggled with programming. I've tought myself 3D moddeling starting with sketchup, to wings, and to Blender which I've used for around six years now somewhat fluently. I've also tought myself several graphic programs like gimp and photoshop so my point is that I've always been a more graphics savy person, graphic programs are just easier for me to understand because I can play around with tools and visually see what each does. I have because of this been limited to engines that allow me to create applications without programming like silent walk, rpg maker, xtreme worlds, ect. But in the past few years I've begun to use Construct and Construct 2 and using them, in addittion to taking a few algebra classes at my college, have lead to understanding logic a lot clearer. I was happy to discover today that Blitz 3D was now open source and it has made me want to attempt to learn programming again, but I am again troubled by the same things that have confussed me int he past when attempting to learn other languages, so I just wanted to ask this comunity of programmers if they would be willing to answer a few questions. I have trouble with tutorials because they tell me to write said scripts, but never exactly explain why they work and why they are written exactly how they are. So here are a few questions I hope will help me understand BlitzBasic better. Here are just a few question to start.

1. I notice in all the tutorials I look at they end with,

Flip
Wend

End

What do the "flip" and "wend" mena exactly? Also, I understand the "end" is a conclusion to the end of the string, but do I need an "end" at the end of every set of strings (I'm sorry if strings is the wrong term for this, but the end of every 'tabbed' body of commands is what I mean)

2. I notice a lot of tutorials give me a seperate .bb file containing functions, must they be in a seperate file? I understand it can make things easier of course to have say one universal mouse look function but at the same time I have trouble learning how the functions work when they are handed to me and I am instructed to just implement pre-existing functions.

3. How is a variable defined in BlitzBasic, and what are variables required for exactly? I notice in the begining of a few tutorials a line like "Global Escape_key = 1" or "Cam1=CreateCamera()". Is the name the name I would refer to and the command on the right side the function of the command? Are either of the two I just quoted variables?

I have a few more, I am scarce on time at the moment but I just want to try to understand programming, I'm sorry if I am hard to understand or work with.

Thankyou,
Pez


Matty(Posted 2014) [#2]
1. Flip - this tells the graphics card to swap the "backbuffer" with the "frontbuffer" - this is how you update the screen all in one go. Think of it like this, when you are drawing elements to the screen you usually want the whole screen to be refreshed at the one time once you have finished putting everything on the screen for that frame.

Wend - this is the end of a "while" loop. There will be a corresponding "While" statement at the beginning of the loop and when the program flow gets to the "Wend" statement that tells the program to continue execution from the top of the while statement.

2. You can arrange your .bb files however you choose. Often it makes it easier to read if they are kept in separate files...but there's nothing stopping you from putting all your code into one large .bb file. Main reason is readability.

3. A variable can be defined in a few ways. eg Global variablename creates a variable called "variablename" which is accessible from anywhere and everywhere in the program. Generally good design doesn't include too many of these. Local variablename creates a variable called "variablename" which is local to the function in which it is defined. So if you define a function such as function myfunction() then any variables declared in it will be only available while you are inside that function.

Also - regarding variables - there are 3 basic data types in blitz... Strings, Integers and Floats. To define a string variable include a "$" at the end of the variable name, to define an integer either include a "%" symbol at the end of the variable (or leave it off - that is what it defaults to) and to define a float use "#".

Note - blitz often uses things they refer to as handles, such as for entities, images and the like. These are best stored as integers. Do not store them as floats. Some people store them as strings but this is not really the best way of doing things.

Something else to consider in blitz is that unlike some languages there is no garbage collector. This means that you have to handle the management of memory (releasing resources when they go out of scope etc - you need to do this yourself) . Usually it is as simple as specifying "freeimage" or similar but it is very important or else you will find that your program will eventually crash because it has used up all available memory. Simple datatypes you don't need to free, but objects and anything that uses a handle pretty much does need to be freed. Simply setting the handle to 0 will not free it but is often good practice to do after you have freed the resource as a way of remembering that that resource is no longer available.


RemiD(Posted 2014) [#3]
I would add 2 things to what Matty explained :

->a handle/reference is like an integer variable but it is used to store the reference of a font, or of an image, or of a mesh, or of a texture, or of an animation, etc...
This handle/reference is created when creating a thing and then can be used to access/read/write/delete the thing.

->you can store variables (integers, floats, strings) and handles/references in lists by using dim arrays or "types"

the blitz3d manual is your friend, don't hesitate to consult it : http://www.blitzbasic.com/b3ddocs/docs.php


MarkG(Posted 2014) [#4]
Also, if you're old-school like me and prefer a printed book, there's a Blitz3D Manual you can order...

http://www.blitzbasic.com/Products/_index_.php
(bottom of page)

I wore my first one out and ordered another, lol. You find the same info on the online help and elsewhere, I just like having actual pages to flip through and reference. I'm probably going to take the one with the pages falling out and have the spine removed and spiral binded.