Tuesday 4 September 2007

blerghghggh

Well bollux I fell alseep @10pm and woke up an hour later, ignoring this timezone as I have stated its Wednesday morning... 2:32AM right now.. Yes my sleeping pattern has been damaged beyond immediate repair!

So anyhow I coded some more and drank some coffee, the editor now has the ability to delete tiles already added with the delete key(amazing) or to clear the whole level with one swift press of the c key if required... Soon I will add the ability to save/load levels into the editor, after this I want to add more features and will think real hard about what I can add to make it greater!

One thing I have learnt from the past is that always use variables and not numbers, this makes the program far easier to read and to modify, for example I could say if i press the leftt key then move the cursor 32 pixels across..or in real code like so:

if(key(_left) and posix>1)
posix--;
x-=32;
end

However I would have to stick to 32 forever (or go about changing loads of 32's wherever they crop up in the program), what if I wanted in one press of a key to change the gaps that the cursor moves to 16? As you should imagine this would involve alot of modifying wherever 32 is... a pain to say the least! so instead I choose to say:

if(key(_left) and posix>1)
posix--;
x-=xgap;
end



xgap is a global variable that currently has a value of 32, if I change just one single instance where I declare the variable from 32 to 16 then this effects whole chunks of code!
I hope you can see how much better it is!


Of course the more skilled among you will already know this, I practice it religeously throughout the whole of my code..

No comments: