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!

Tuesday, 22 December 2009

Chapter 10 Arrays PT3

Ok so this is going to take a little longer than expected, looking through whats to come, there is alot to go though and activites to do till Chapter 11, so it may take up till christmas!


Anyway, completing the activites I been doing has been giving me a good understanding of how we can use arrays, and why we use them. It has also been getting me used to the format, which is very helpfull, as i can type them faster! (Without any dumb moments nether)


There is not really much for me to comment on, as I havent learnt anything new, just enforcing what I have been learning. I may do some more later, but I need a break now, soak the sponge to much at once, it will drip! In this case refering to lee's (The holy creator of DarkBASIC) analogy of a brain =D


Until next time people =)

Monday, 21 December 2009

Chapter 10 Arrays PT2

Ok so I have been getting myself pumped for programming by thinking about the game/games I wish to make, and starting some of the graphics for the upcoming game! Also having a look round to see what others had done, making me a little jeolous, but in a good way!!!


Anyway, done some more of Chapter 10, learning about arrays, and they can be used just the same as variables! (Which i gathered) That really is the main thing covered in the section I. I also learnt how to store values into these arrays using this formula

  • arrayname(elementnumber) = value
I could not believe how easy it was! And to think that arrays are what stopped me learning soley on comunity tutorials! (Im glad it did as i wouldnt have the HODBP books now)

Anyway the element number is called the subscript, it can be a number or a variable, for instance

  • player1 = 1
  • highscores(player1) = 1000 
Would give the element 3 the value of 1000, a little more confusing than variables! But im sure I will get used to the format.


Well I think that is it for tonight, hopefully I will finish the array chapter eather tommorow or wednesday, then I begin Bull and Torch, and i have to program the entire thing just using the specs it gives me! No code to copy.


******* Off Topic *******

We had so much snow on friday, it is still here as I right this! We also got some more today, and hopefully even more tommorow! Though our lights have been flickering recently, and this happened yesterday just before a three hour long powercut >_<

See (write)  you all soon!

Friday, 18 December 2009

Chapter 10 Arrays PT1

And so christmas draws ever nearer! and with all the snow us brits have been getting, it is going to be a jolly good one! Anyway, sorry I have not posted in a while, been very busy with other things. Just a few updates before I explain what I have been doing in DarkBASIC.


ONE - I just finished the second music peice for a planned game (more on that next year) in mixcraft and it sounds really great!


TWO - I am hoping to buy a few expansions for DarkBASIC (The 2d pack, and a few more, also may buy Exgen for nice particle effects)


THREE - I wont be making an independent game after bull and touch, because that WILL be my independent game! looking at the chapter, it gives you the mini-specs and that is it!!!


FOUR - I have got the upgraded DarkBASIC interface! I was looking through the files of DBP and i found EditorU73, double clicking i realized it was the new interface that supposingly had came with update 7.3! It looks and feels really great to use, with that professional feel, and the added usability, media previewing, project list showing all data that has been declared and a bunch of other stuff! It has been based on the Visual Studio 2008 interface, anyway here is a screenie =D



************************************************************************
************************************************************************
************************************************************************

Ok back to Chapter 10, i have been studdying Arrays, somthing i did not understand before i had the HODBP books, and learnt alot already, how to create them (using DIM) and why they are used. Not read/reading much today though because i want to do other things, but as long as i have done some its cool!

Im afraid thats all there is to say so far, hope you all the very best christmas, and im sure I will post again in january or on christmas! Prehaps before, we will see as to what goes on!


Saturday, 5 December 2009

Chapter 9 Hangman PT4

Hello guys, I just completed hangman!, added the final few routines, one to draw the letters, one to draw the hanged man if the guess is wrong, and a few other smaller ones, I also added two error messeges one if you guess the same letter again, and one if you enter invalid values.


For my first game I am very pleased, and the book has been most helpful giving me easy explinations of why we do so and so. It also got me coding a few of the routines by myself, so that was quite nice, as I feel I have put some effort into the game =) The next game il will be making, is the classic bull and touch (mastermind nowdays) I know I said i wanted to make my own independant game before i continue, but there is only a few chapters inbetween, one being arrays which is very inportent so I will wait till after bull and touch.

PS, the words are just city names at the moment and the game also has its own icon, of a hanged man =)


OK the game has been added to my skydrive for people to download link:


Hangman Download


Screenshots:






Friday, 4 December 2009

Chapter 9 Hangman PT3

OK i have just filled in another two functions, GetGuess() and CheckForLetter(), (Had a little problem with check for letter, though i rectified, turns out i haddened asgined a varible to equal a function, anyhow) Now the program takes in a value from the user (Guess) and checks it for any equal letters in word$

I am looking to complete the game on Sunday or tommorow, depends on which day i decide to do my homework >_< and il post the download, so you can see what i have learnt =D After Hangman i am going to see if i can make my first independant word game of a sort, to test my current skills and knowledge.

But for now i am going to continue to write some of my story (Elysiem) So hope you all have a great weekend!