Jump to content

The Most Perfect Piece Of Videogame Code.


Recommended Posts

#include <ddraw.h>

#define B(x,y,r,p) (p&1<<(((x^(r+1&2?3:0))<<(r*2&2))+((y^(r&2?3:0))*(r&1?1:4))))

#define F(x,y,w,h,c) {RECT R={x,y,x+w,y+h};b.dwFillColor=c;_->Blt(&R,0,0,k,&b);}

char *m="TetrisBy Pouya LarjaniScore:Next:GAME OVER",z[9]; unsigned L=16



q;HWND W;LOGFONT l={96,48};MSG g;DDSURFACEDESC S={108,33,0,0,0,1,0,0,0,0,0,0,0,0

,0,0,0,0,0,0,0,0,0,0,0,0,{536}};HFONT f=CreateFontIndirect(&l);DDSCAPS c={4};X()


I/20][i%20]=s[i/20-1][i--%20]);e++;return 1;}}return 0;}M(int p){return(++p<<21&

1<<23|p<<14&1<<15|p<<7&1<<7)+8355711;}K(int v){return GetAsyncKeyState(v)&32768;

}O(int x,int y,int r,int p){for(I=0;I<L;I++)if(B(I%4,I/4,r,P[p])&&(x+I%4<0||x+I%

4>19||y+I/4<0||y+I/4>29||s[y+I/4][x+I%4]))return 0;return 1;}void G(){v=r;t=x;u=



++:K(27)?PostQuitMessage(0):0;if(O(t,u,v,p))x=t,y=u,r=v;else if(u-y){for(I=0;I<L


;while(X());}}void R(){F(0,0,640,480,1<<15);for(I=0;I<600;I++)F(I%20*L,I/20*L,L,






,f);TextOut(q,336,20,m,6);_->ReleaseDC(q);V->Flip(0,1);}WINAPI WinMain(HINSTANCE

h,HINSTANCE,char*,int){srand(timeGetTime());WNDCLASS w={0,DefWindowProc,0,0,h,0,





();int U=0;V->Release();d->Release();DestroyWindow(W);DeleteObject(f);return U;}

(it's tetris)

Tetris in BBC basic:







Explanation here http://www.survex.com/~olly/dsm_rheolism/explanation.html

Link to comment
Share on other sites

I like the Acorn Electron version. Can't fit the code in memory, eh? Ack, the screen will do fine, stick it in there as a fancy border.

That was pretty common on electron games though, plus dealing with a smaller view area helped compensate for the lack of hardware scrolling (that's why Repton & co. used smaller sprites on the electron and gave you a score display and stuff on the spare screen space).

Link to comment
Share on other sites

The way the Gamecube logo upon appearing whenever you turn the console on organically changes shape as you press [hold] and release the A button.

It's only a tiny thing, but I am always ridiculously impressed by it everytime. It's amazing!

And the very faint dazed effect that appears after you do a sword spin in Wind Waker, though that's probably appropiate for another thread.

Link to comment
Share on other sites

The Windwakers overworld.

Being able to jump in your boat and sail to a tiny dot on the horizon and watch it get bigger and bigger and then jump off onto it.

The Lighthouse with its light running looked amazing from distance. :)

With it's what?? How did you do that?

Link to comment
Share on other sites

That was pretty common on electron games though, plus dealing with a smaller view area helped compensate for the lack of hardware scrolling (that's why Repton & co. used smaller sprites on the electron and gave you a score display and stuff on the spare screen space).

On a similar theme, but possibly the worst bit of coding ever rather than the best, I was at studio where we had to convert a C64 fighting game to one of those later Commodore machines - the C16 or +4 (can't remember which was which) - the one which was basically a cut-down C64 with far less RAM.

Of course, the game was expected to be exactly the same as the C64 version, so the conversion was all about reducing the RAM required in one way or another.

By the end the programmer had completely run out of RAM, but still had to squeeze a bit more code in there. He noticed that the background graphics consisted of a plain blue sky with plain white clouds dotted about in them, so he decided to use the top half of the screen RAM as a place to put his remaining code. He used the attributes to set the ink / paper colours of the empty sky to both blue, so that the bytes of code wouldn't be visible, and made the empty clouds solid white for the same reason. Where the cloud edge graphics were (ie the bytes of screen RAM that contained actual graphics) he just put jumps in his code to jump past them. Absolute insanity, but it worked.

Link to comment
Share on other sites


I've never played anything so addictive since. Well, apart from WoW I suppose - and in fact that's another one for the list, flying for the first time in Wow - you realise quite how huge the world is, and fly over areas that you're probably not going to be able to go into for another six months (well, if you level as slowly as I do), and it's very pretty.

Link to comment
Share on other sites

Not exactly my most favourite, but the control configuration in SSX Blur that enables you to adjust the amount of carving controlled by either tilting the NunChuk or using the Nunchuk stick. I only found this out last night and since I moved it to 100% control stick it's so much easier.

General little bits like that are the best, when the developer has actually put some thought into it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Use of this website is subject to our Privacy Policy, Terms of Use, and Guidelines.