Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

8/16/12

Curious look into code evaluation

If you have been programming for a while, you already should know about operator precedence. If you for some reason don't, now is a good time to read about it on from Wikipedia or the documentation of your language of choice.

Before proceeding, remember that this may contain some erroneous information, and if you notice any, please inform me so that article can be fixed.

Let's take a rather simple set of expressions:

int i = 5; 
i = ++i + ++i;

This seems rather simple, doesn't it? So did I think, but the results (which we'll see a bit late) left me thinking wtf was actually going on. If we look at the Wikipedia-article, we can see that unary operators such as prefix and suffix increment and decrement come before the addition and substraction, at least in C-family of languages. Now, what do you think the answer will be? Write your guess down somewhere, we'll take a small plunge in to the world of compilers soon.

So, you got your answer? Good. If you did a quick test with a short code of piece, shame on you. Now, let me guess what you got.

If you used Python or Ruby, you got 10.
If you used JS, Java or C#, you got 13.
If you used C, C++ or Perl, you got 14.

Wait, what? How does this even happen?


10/26/10

Back again (also, I have Twitter now!)

Hello!

So, we got back from Paris late in the Saturday evening. What a refreshing holiday, I have to say. Although my French was rusty, I managed to communicate with the locals (although from time to time we had to use English). Eiffel Tower, Arc de Triomphe, Louvre, Mona Lisa, Versailles... we visited a lot of places, but many were left out, like the Catacombs. I feel a whole lot more cheerful and powered up in all ways, which is a good thing, because I'm going to have hellalot coding ahead of me.

10/14/10

Disappointment

Sooooo, long time no update. I'll just write some major thoughts right now.

After being lazy for too long I took up the coding again and actually got around to write the code for jumping. It worked (in a way, at least), but when it came to collision detection everything went to hell. I simply failed to make it so, that the blob would stop when it lands on platform - instead it fell happily through. It turned out I had some major flaws in code (especially considering hitboxes and rectangles) and so I decided to ditch the old code and begin writing new (which wouldn't take long, as I had some pretty good tutorials and examples at my hand). I wonder if I get the code ready tonight (it's now three days late from deadline!) and if it is any good for further use. Hopefully so, stay tuned!

9/23/10

Just another short update

Finally got the gravity working on the platformer. The jumping, not so much. It seems to have some tricky parts, but I guess I'll manage to do it if I can just grab the motivation from somewhere. At the moment the roguelike-project just buuuuurns in my hands and I can't wait to get on to it. But priorization is the first thing to do now, I'll have to work for this damned "blop gets keys, avoids ghosts and loots some sweet-ass treasure"-platformer. Oh, and have I mentioned already that I just love XNA? It makes everything so damn easy. Although I hate the way Visual Studio puts all my wavebrackets on their own lines. It's infuriating! And why are the line number-options so well hidden? It took me some time in Google to find out how to turn them on! Unforgivable.

9/12/10

Starting developing games

This year I will start developing some games. The first one is a game made with C# using XNA 3.0 (I yet don't have any idea what it will be like!) and the second one, a larger and more ambitious one, will be made using C++.

But first something little about me. I am 20 year old student in University of Oulu, majoring in Information Processing Science and also taking courses in mathematics. I have pretty much very little experience in programming, thus far I've programmed with Java for about a year and C/C++ for three months. I've great ambition in making games, although I understand that right now these projects will most likely be more than I can chew, but what I've learned about programming in this short time is that one must learn from one's mistakes. And what would be a better way to make mistakes than creating a game?