Traveling Without Moving

Created with Sketch.

Traveling Without Moving

C# University keeps some incredibly odd hours, with personal study seemingly located between 10:00 PM and ending sometime before the Sun greets the Earth. Of course, with the other stuff that I do, convenient times are all taken up by inconvenient things. So that leaves only inconvenient times to do convenient things.
No matter. Yesterday I learned how to overload a function. It’s a tricky little bastard, but crazy useful. So let’s use some examples (I love examples! – and parentheses!):

Static DrawCrap(Picture, Position)

Okay then, let’s say this is the basic function. It draws a picture on the screen at a certain position. No, that’s not correct code syntax, but blogspot doesn’t have the code fixer than my IDE does. In any event, it’s simple and basic. We could also do this, in the same program:

Static DrawCrap(Picture, Position, MaskColor)

You’ll notice that this new one is named the same as the last one – DrawCrap(). Usually, having functions, or anything really, named the same as something else is a recipe for holiday themed, peppermint flavoured disaster. However, since they want different stuff, then it still works. The computer will know which one you want based on the context of it. Give it only the name of the picture and the position, it’ll use the top one and give it some mask color information and it’ll use the bottom.
That’s not the only thing either, it’ll also know based on what type of information you feed it. So,
DoStuff(int) is different than DoStuff(string). It knows what to do based on what it just ate.
Cute, no? I’m still not sure how I want to use this, but I’m positive that I can think of something. The DoStuff example will probably turn into a function that draws me some bloody text without the nine pounds of dusty nonsense that C# wants to enforce.

-Which reminds me, I hate fonts. Firstly because I can’t seem to load them. Secondly, because the online tutorial sucks and finally, because the code to make it work is long, tedious and unnecessary. I’ll tell you what I want, what I really, really want (other than to not hate myself for just typing that) is to just draw some fuggin text on the screen. It’s what I use to debug stuff in real time. Turning on Debug Mode in The Thief’s Tale turns on dozens of little labels and numbers in a bunch of very colorful little characters. That’s what I want. Instead, C# wants me to load a font, and assign a font and make sure that my font isn’t licensed and I can use it and then it wants only a string, so I have to convert stuff and try not to play laptop Frisbee.
So, yeah. I may build an overloaded function for that and then use it ad perpetuity.

– Wait for it…here comes the titles. I figured out yesterday via tutorial and practical application how to make the keyboard do stuff. I have the computer check for the state of the keyboard and then play twenty questions.
“Is the spacebar pressed?
“How about the Right Arrow Key?”
“How about the Escape Key?”
“The left Shift Key?”
“Is that little Key up at the left with that little “~” on it, is that pressed?”

So it basically works exactly like it does in Blitz, but with squiggly fuggin‘ brackets. I also saw that I can have the computer remember what I pressed. So I can ask important questions like:
“Are you still holding the spacebar?”
“Was the Escape Key just pressed?”
“Did somebody just let go of the little Key up at the left with that little “~” on it?”

The answers to which allow me the summon the same functionality that KeyDown() and KeyHit() have in Blitz, plus the extra functionality of the non-existent KeyJustLetGo().

So I quickly leveraged that and now the little Knight Sprite (rhyme!) moves across the screen like a tiny puppet.
The reason that this is of value? Because with this most basic of abilities coupled with the logic and method behind drawing stuff on a screen, it’s safe to say that I can now write games using C#. Nothing good yet mind you, but TTT started this way. Right now I have a seed, and from it I can grow a giant thing, and my knowledge with it. That’s a big deal to me.
Of course, need to finish TTT first. But I’m thinking that this new seed can grow into Thief on XBLI with the proper care and feeding.

-Oh yes, that is another Jamiroquai reference in the title. Deal with it. Although looking back there is a kind of running theme of 90’s dance pop music in today’s post. Lack of sleep obviously clouds the mind.