I’ll get right into the titles today. I tend to ramble about before finally getting to the point, and not so today. Well, maybe a little. You see, I can, and do, write about everything involved in my game projects be they good, bad, or incredibly stupid. It allows me to comment on them in my own odd way, say by including an Oxford Comma in that last sentence.
But there I go again, going on about nothing. Let’s start this over again, but not really, because I hate the delete key.
Yesterday, I learned how the Get function works in C#. In and of itself, that’s cute. The Get function can pull individual variables or structures right out of Class Instances. So I can see what direction an object is going, or like I did yesterday, figure out which way it is facing. This is part of me wanting to create functions that will allow me to create bullets of all sizes, shapes and colors. Collision is easy after I can make the damned things. Same is true for enemies and other, well, objects.
But, that’s not the thing I feel kind of dumb about. That actually makes me feel all smart, since I deduced how it works. The problem was that I had to deduce how it works. Online tutorials don’t really go into it, they just say that it helps to create a Return Function, and are otherwise silent.
A Return Function does exactly what I explained above, it fetches a variable from somewhere. It turns out that it’s one of the most basic tools available. It’s in the same category as an “if” statement. So if you don’t understand it, the logic goes, why did somebody let you have a computer in the first place? Silly noob.
But those are lamentations for another day really. I’m over it…now. I can move forward. The other thing that I worked out, is basic structure of C# code. First though, I need to explain basic code structure for Blitz Basic. As a basic language, it doesn’t instance things and everything is super modular. Everything lives on the same page and functions can be called easily. Variables can be ‘Global’ which means that they are the same thing everywhere. That’s why I never bothered to figure out a return function. Instead my functions altered those same Global Variables. It was a Monolithic Structure, everything was tied into the central whole. That’s the biggest reason it was such a Caligula-esque orgy to confine that structure inside of a menu wrapper.
In contrast, C# is built using Classes, which are almost like tiny sub-programs. In the code, you can create instances of those Classes, like making a little autonomous robot that follows the code it has. These robots don’t really give too much of a damn about the rest of the code, so focused are they on their own crap. Also, those instances all have their own little variables and their own little stuff. There isn’t a ‘Global’ variables in C# to the best of my knowledge. Which is why a Return Function is suddenly so important.
Consequently, the code isn’t structured like it is in Blitz. In previous experiments I’d tried to organize things by chains. So there is a Sprite Class, and a Player Sprite Class and I thought that I would add a Bullet Class to the Player Sprite Class. The logic went that the origin of the thing should also be the code that is responsible for its creation.
Turns out that’s about as wrong as it could be. The better way to do it, is to tie all Vishnu style creation, Shiva themed destruction and Brahma based updates into a single Monotheic Class. I called this Class the Sprite Manager. It’s the happy little tree at the center of the code that I can hang little ornaments on.
So now, all of my Sprites are sub-classes of the Arch Sprite Class, which controls adorable shit like making them display and animate correctly (no need to have each type of sprite have distinct drawing code, that’s just asinine). Specific logic is done for an object is done by that object’s Class Code. So the enemy sprites have their own instructions in their own code that is unique to them. When they interact with things, they will do a Return Function and send some info back to the Sprite Manager. It sounds kind of complicated when I say it like that, but it’s really starting to gel now. I was actually able to add functionality without causing a compiler error or an odd access violation. I should be able to have something to show for all of this soon.
– In not programming news, I’m also hip deep into Assassin’s Creed 2. As somebody that really rather loved the first one, the second is like the first, but better in every possible way. Well, the controls are the same except I have the Metal Gear Solid 2 problem of having way too many weapons that I have to bother with. Oh, and I can play dress up with my character, which I find I enjoy more than I should.
My options, post XBox surgery, were it or ODST. I think I chose wisely. Although everybody speaks in bloody Italian. Nice, but I own a standard definition TV, so the little subtitles are incredibly little. Borderline unreadable really. Instead I get to pick up the Italian via exposure and context. Which is, how do you say, no bene. So I miss every third word, but I get to take out my fury on an unsuspecting guard population with two (2!) wrist daggers. So I guess what I’m saying is, in addition to C#, I’m also learning how to speak Italian.