Friday, 4 June 2010

Chapter 12 Advanced Data Types and Operators PT1

Ok so After finishing a chapter another begins! This time thought, we go back to the very foundations of programming and get tough other more efficient ways of doing things.


Firstly, I have discovered how variables can be assigned a different way, giving more type options. And those options are:


  • BYTE, which can hold a number up to 255 from 0
  • WORD, which can hold a number from 0 to 65536
  • DWORD, which can hold a number from 0 to 2147483647
  • INTEGER, which can hold a number from -2147483647 to 2147483647#
  • DOUBLE INTEGER, which can hold a number from -9223372036854775807 to 9223372036854775807
  • FLOAT, which I dont quite understand how much it can hold
  • DOUBLE FLOAT ^^
  • BOOLEAN, which despite being a true/false variable can hold a number from 0-255, 0 being false and any above being true.
  • STRING, which does not say how much it can hold.


They all have different byte sizes, so I am depicting that using the correct on at the right time can save a little space, not including BOOLEAN which has a more useful function.

All these types can be given to a variable by simply writing: Variablename AS Variabletype. For example
  • age AS BYTE
Though this way is just a way of defining a variable before its use, as it needs to be given a value first. I actually prefer this way because its easier to type. I have to stop and look at the symbols, but instead I can rather write them fluently. Futhermore, you do not have to put any symbol when you use it, as the variable becomes the type given for the rest of the program. The only downside to this, is that you cannot see what the variable is by looking at it, you would have to go to the place where you defined it.


As well as learning this so far, I have also came across the usage of TYPES. They are simply given variables a structure, and several sub-variables. For instance, if you had a player in a fantasy game, then you could simply define a type like so, giving it all the variables for the players stats:

  • TYPE PlayerType
  •     strength AS INTEGER
  •     defense AS INTEGER
  •     intellect AS INTEGER
  •     dexterity AS INTEGER
  •     willpower AS INTEGER
  • ENDTYPE
That way, you have grouped the variables. You would then need to define a variable a type so:

  • player AS PlayerType
Now when ever you want to access the variables (Called records), you just type "Player.record", lets say I wanted to increase the players strength by 10, I would write:
  • player.strength = player.strength + 10
Now you can see how useful this could be, as you can see what variables belong to which, but more over, something even more useful would be to use a type for an enemy in a fantasy game, so considering they have all the stats as given above, you do not have to define a variable for every enemy, instead you can define it as a "PlayerType" and access the records.

Array cells can be come types also, but you cannot have  an array as a record.

This is all that has been taught so far in this chapter, and you can see that it is a lot! The next part deals with more array functions, such as inserting extra cells and deleting excess ones. Every chapter I read I feel brings me closer to independent creation of games, and I am starting to think how certain genres and situations can be created using what I have learnt.

Tuesday, 1 June 2010

Chapter 11 Bull and Touch

Ok so I have finally finished it, Bull and Touch. In case you are worrying as to the time it took me do not fear, I can assure you that I did not spend 4 months solid working on it. To be honest I got stuck, and got annoyed so abandoned my programming for the time being. But as it does, I got the urge to create games once again and decided to continue learning DarkBASIC Professional.


I learnt a valuable lesson in my absence and return: Never do it on long projects, because my was it hard to "Catch up" and remember what you had done, what does what and the likes. Anyhow, I am proud of the finished product, and while I admit that I was unable to create the game without certain parts being checked in the solution but I am learning! Most of the time I wrote parts and if it was not working correctly I would attempt to find out why. If that failed then I would check the solution, but after many attempts to resolve the problem myself. More often that not though the answer was not in the solution the book gave and would be a simple error that I overlooked.


I think the main issue with the games development was the fact that I did not know the concept of "Bull and Touch" which hindered my understanding of it, where as hangman, I am sure everyone knows well from their school days I know of by heart.


On another note, I hope to continue programming commonly again because this is what I want to pursue as my carrer, and having knowledge this early of programming will make my life so much easier. I will upload the finished game for anyone to take a look at, as well as the source code.


Here is a screenshot of Bull and Touch!


Simple graphics again, blame the book =P No no, sprites do not come until later! But creating this game gave me insight into the use of arrays. If you find any bugs let me know and I will "Attempt" to fix them.


Also there is a lot of unused space but that is just due to the lack of features put on there. I might return to it one day and vamp it up!


Sorry for the blurry quality, the game will be uploaded for download, Link:
Bull and Touch

Thursday, 18 February 2010

Chapter 10 Arrays PT4

So here I am, back in business and writing on my blog! Only this time I am armed with the power of Google Chrome =D


I know I have not posted for a fair while, but just been busy. Now then the past two days I have finished of Chapter 10 of HODBP, which is really exciting as I make my first semi-independent game! I get given the Mini-Specs and that is all. I know it is just a small game (Bull and Torch) but it is a start so hey!


All this chapter I have been learning about (you guessed it) arrays =D My worst nightmare XD And yet a zoomed past them, now holding a good understanding of what they are, how they work and what they are used for. And by god if they did not exist I could never create such games with ease! They are as simple to declare as variables are to create a 1D array that has seven elements you would use the code:
  • DIM score(7)
And that is it! Also to make more than one dimension you add extra numbers for how big you want it to be (DIM score(7,7) for a two seven element dimension array.


That is basicly it! It got me creating several programs to do different things (IE shuffling cards), which by now, I try to do without looking at the code. And manage it as well!


*******************************************************
Other News:
  • Worked on the second piece of music for alchemy! With some help of freinds
  • My birthday on Saturday ^_^
  • Buying Mixcraft tomorrow
  • Now playing Grepolis!