Starting My Programming Journey

Blitz3D Forums/Blitz3D Beginners Area/Starting My Programming Journey

Kirkkaf13(Posted 2010) [#1]
Hi all,

I have just purchased/downloaded Blitz3D I am completely new to this how should I start my journey in BlitzBasic?

Regards,

Kirk.


Ross C(Posted 2010) [#2]
Well, that's a tough one... I suppose you should start by reading through the helps docs and tutorials that come with it. Are you completely new to programming?


Yasha(Posted 2010) [#3]
Well, the first thing you'll need is a decent editor (the one included with Blitz3D isn't very good).

If you plan to make 2D games and applications, or want a reasonable amount of 2D displayed over 3D scenes, a "2D in 3D" drawing library is a fast and powerful addition to your toolset.

There's an enormous wealth of free goodies in the code archives, so be sure to look there if you need a specific solution to a problem. There are also plenty of free samples and libraries floating around the forums, so search for anything you're interested in as someone's probably given it a go before you.

Don't use Goto or Global variables, or the bear will eat you.

Other than that... as long as you have a specific idea of what you want to achieve, the rest will fall into place as you go on.


Kirkkaf13(Posted 2010) [#4]
Hi there,

I would just like to say thanks for your replys, I anit completely new to programming as I have some knowledge in basic and VB.NET.

E.G.

Variables, Arrays, Functions, Gobal, local, basic mathmatics, various loops, If statements ect...

I guess I need to start by programming in console before I move onto graphics then eventually 2D - 3D games.

If anyone has any tips or reccomendations please let me know.

EDITED:

Use GoSub and Local/Private instead of Goto and Gobal?

- Thanks

Kirk.


Yasha(Posted 2010) [#5]
Gosub generally isn't viewed any more positively than Goto; most people tend to just forget about it as it really has no practical uses. There is no code structure that needs the Goto or Gosub commands; If/For/While etc. and functions are quite adequate and a lot more elegant and readable, so it looks like you can safely stick to what you would have been using already with VB.

Global variables are also unnecessary to express any given program, although in some cases they might be a simpler way of accessing objects. What I'd suggest is trying as far as possible to pass all necessary information to a function in its parameters; only add Globals for things that really are supposed to be visible to and dominate the entire program. Otherwise it's hard to see what information is being made available to a given function and to get an idea of what is going on.

Finally... Blitz3D makes graphics easy! You don't need to start with non-graphical apps unless that's what you actually want to be working on - 3D applications are really no more difficult and (in my opinion) far more rewarding to work on as you can visually check on your progress as you go along. If you've already got some basic BASIC experience, you'll probably learn best by just diving straight in.

Good luck!


Kirkkaf13(Posted 2010) [#6]
Thanks for the heads up Yasha, I do have previous experience in BASIC language - YaBasic (also written on the PS2) which isn't quite as powerful as Blitz.

I will do just that and dive straight into some sample programs.

I'd like to thank you once again for your help and I'm sure I will have lots of questions to ask in the future, hopfully everyone here can help.

EDITED:

I also ordered the Blitz3D Book from LULU, hw helpful is this book, have I made a good purchase?

- Cheers,

Kirk.


Nike(Posted 2010) [#7]
Not sure which one you got but I started with a blitz3d programming book too. I started to write one but I only got to page 9. It still is useful if you want to read it. It's at this website It's a word 2007 file so if you can't read it I can try and change it.


Warner(Posted 2010) [#8]
I agree it is a good practice to use a book to learn programming. Perhaps look for 'game programming for teens', which I read good reviews of.
To learn Blitz, I used the original b3d manual (pre-Lulu). But I knew how to write programs before that.
As a first project, I would recommend writing a text-based adventure. From there, work up to a point-and-click adventure.
I don't see why using Goto and Gosub would be bad. They can be translated straight into assembly. For a text-based adventure game, goto is perfect.


Wayne(Posted 2010) [#9]
B3d is based on the entity concept, embrace entities and you'll do well.


Kirkkaf13(Posted 2010) [#10]
Hi guys,

Thanks for the replies, I will look into entity concept. As writing a text based adventure, I might just start that now seems like a nice fun project cheers.

Oh and Nike I don't have MSW so I won't be able to view your document, but I hear it works with OpenOffice so I could just download that.

- Cheers,

Kirk.


SabataRH(Posted 2010) [#11]
My advice is to watch out for 'bad advice' you may be getting - like some of the responses in this thread.


Ross C(Posted 2010) [#12]
Hmm, my post didn't show up... Anyway, i think you should try programming some smaller games, and building your knowledge. Games like tetris will give you some good tools to get you through more complex projects.

And Swampdonkey, you should highlight the bad advice, as Kirkkaf probably won't know what it is :)


Kirkkaf13(Posted 2010) [#13]
Hi all,

Yeah if there is some bad advice here could you please let me know what that is and why?

I also wouldn't know where to start when creating a game like Tetris yet I don't have the skills to create something like that yet.

- Kirk.


Ross C(Posted 2010) [#14]
Well, do you know much about arrays?


Kirkkaf13(Posted 2010) [#15]
Yeah I know the basics of an array.


Ross C(Posted 2010) [#16]
Well, tetris, is closely related to an array. If you can imagine all possible locations of a block, as a visualisation of the array itself.

Global BlockAreaWidth = 16
Global BlockAreaHeight = 30
Dim BlockArea(BlockAreaWidth,BlockAreaHeight) ; arrays are global as standard. Oh and the ; character means anything after on the same line will be ignored as it is a comment.


That would give you a container, so to speak, to place your blocks in. Every time you want to redraw the screen, you simply loop through the array, and draw a block, at the correct location.

So, you would need a few things to start off with. Firstly, you need to know how wide the image your using as a block is. From this, you can work out the spacing between each block:

Global BlockImage = LoadImage("Block.png")
Global BlockSize = ImageWidth(BlockImage)


Ok, so what that does, is load an image using the LoadImage() command. You simply supply the filename, of the image you want to load. Here, i have used a local filepath, so the image is located in the same directory as the code running it. The Global command sets the variable up, so it can be accessed/usuable anywhere in the code. When ever you want to use that image, you simply provide the variable name BlockImage.

Now, you set up a global variable to hold the size of the image. Because tetris generally uses square images, the image you provided should be square. That being the case, the width will also be the height. Makes things a little easier as you don't need to concern yourself with two different dimension sizes.

Now, you need a start drawing co-ord for your play area:

Global StartDrawX = 100
Global StartDrawY = 100


Now, when drawing you arrays contents, you have everything you need:

For X = 0 to BlockAreaWidth
   For Y = 0 to BlockAreaHeight
      If BlockArea(X,Y) = 1 then
         DrawImage BlockImage, StartDrawX + (X * BlockSize), StartDrawY + (Y * BlockSize)
      End If
   Next
Next


Sorry to patronise you here, if you know all this stuff ^_^. The above will set up two loops inside each other. Firsty it will loop through the Y columns, moving onto a column after each loop.

It then checks the array value, to see if it holds a 1. If so, then it will draw a block at that location.

Now, the positioning works fairly easily. It takes the starting draw location, and adds on (the current value of X) TIMES (the value of the blocksize), and the same with the Y co-ord.

This draws out the play area. the good thing here is, any changes made to the array elsewhere, are instantly drawn to the screen the next time the draw is called. So, tetris, in this instant, is all about putting values into an array, and deleting them if no block exists.

The way i'm working it here, is any array slot with a 1 in it, will have a block drawn in it. Any other value (i'd put a zero in for simplicity) will cause no block to be drawn.


6(Posted 2010) [#17]
There are few users who have put some tutorials on youtube too.

http://www.youtube.com/user/amcadam26#p/u


_PJ_(Posted 2010) [#18]
Your background knowledge of programming will be handy.

I'd personally recommend getting your teeth stuck into trying to write some simplistic kind of program, maybe space invaders, tetris, pong or such (I recommend sticking with the 2D at first). Get used to the different syntax that Blitz uses compared to VB etc. and see how it goes.
There are tutorials, code-archives and all sorts of resources (I am not sure if you have the samples and demo programs with your copy of B3D???) available from these forums and if you get stuck, just ask on here, the people on these forums are very helpful!

If you succeed in making a simple program to your taste, go back through it, and see if there's a means of making it more efficient within the Blitz language.

Once that's done, you shouuld have a pretty clear understanding of how to achieve what you need to with Blitz llanguage itself and so can approach the 3D side and more techy stuff....