Showing posts with label Coding. Show all posts
Showing posts with label Coding. 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?


11/20/10

+-

So, I've been a bit lazy with updating lately. Sorry about that!

As some of you may know, I've halted the developement for the platformer for now, because I'm swamped with work. And yet for some reason I volunteered for programmer slot in a Unity-project. I guess I'll release the one level platformer some time around January or February. And as it is, I'd like to know some good places to upload code to share, as I don't think its quite convenient to upload all the code here, eh.

So, the Unity-project, or as it should be called, "The Curtain". It is a biiiig surprise. I guess. I'm still not all sure about what it's all about, but I guess we'll find out. Pretty nifty thing, this Unity. Although it does have some problems.

Oh yeah, roguelike! I've been designing the ruleset for it for now and it's getting closer to actual testing phase. Once it's ready I'll release it somewhere, free of course. You are allowed to use it as you will, modify it even if you think it's necessary and so forth. I'll try to make it as usable as possible to be used in tabletop roleplaying games, but being made for computer game, it'll need some modifications for it. Unless I invent some good way to bypass that.

So yeah, that's all for now.

Ps. there's snow everywhere. Yay!

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.

9/20/10

Just a quick update

So, I've finally got random dungeon generation working, although it could use a lot of tweaking (especially for getting those lovely long corridors!) and making corridors actually make sense. I'll include the source code in the end, so if you're interested you can have a look at it. Next up: including player character into the screen and enabling movement and collisions!

The platformer, on the other hand, progresses rather slow. I've just started implementing some kind of gravity to it, but it seems to be rather tricky from time to time. Hopefully it'll sort out in time. (Also, I suck at drawing so the game will most likely be hideous).