Looking back

Posted by Astryl on March 8, 2013, 4:17 a.m.

Warning: Wall of text.

During my usual 2AM or so argument with myself about the benefits of going to bed at least some time during the AM hours versus continued consciousness via caffeine, I saw an old picture of what Exile originally was. This one, specifically:

Yes. Exile was 8 blocks being rendered with my Minecraft Texture pack…

So I began to think "How did I arrive at Exile from that?". And from there, I started thinking "How the hell did I get to that in the first place?"

So after much thinking, my output buffer is now full, and I need to flush it.

This is going to be how I started graphics programming. Focusing mostly on the 3D side of things, though obviously the 2D aspects are the foundation I built upon.

The real beginning

I remember telling everybody about how I started learning Pascal about 10 years ago, and that it was my first foray into programming… well, I was wrong. But who can blame me for forgetting?

My first programming language was C64 BASIC. In 2001.

Before you start wondering how, I'll just say that my uncle had a lot of old machines lying around (He even gave me a C64 in it's freakin' box at some point… The power supply burnt out though).

And the library still had a lot of those old "Game" books. You know, the ones where you laboriously type out an entire program listing and type RUN at the end to play a simple game.

Being an intrepid 9 year old at the time who wasn't afraid of ripping things apart to see how they worked, I modified and tweaked and eventually 'understood' what was going on. SUBs still confused me, but I could get things to draw on the screen.

Of course, I didn't have much time to do anything, and we didn't have any convenient blank tapes lying around for me to use as storage.

But fortunately, somebody gave us an old 486 PC (Complete with ancient dot-matrix printer that used to make our whole apartment shake when we used it…) with Windows 95 and a defunct CD-ROM drive.

It didn't take me too long to discover QBASIC and it's help files. Soon I was pushing pixels around on the screen, drawing simple shapes and trying to move them (Flickery fun).

All of this was pointless from a modern perspective, but that's what jumpstarted my programming. Without discovering QBASIC, I wouldn't have had the slightest idea as to what the .PAS files in the one folder were (They were similar to .BAS, so of course I opened them… >_>)

Pascal

When I discovered Pascal, my first thoughts were "This is a mess". That was because I was used to typing out very linear programs with only a few SUBS here and there. Functions and structures were beyond me.

Eventually, I figured things out and started to love the layout of the language. My only problem was the fact that there didn't seem to be a graphics library (This gleaned from days poking at source code files.)

So I kept on mucking around in QBASIC until I got my hands on Turbo Pascal, almost two years later.

When I finally did get the compiler, I dove right into the help files and documentation and started looking for ways to get the graphics mode out of "DOS", as I used to say.

Eventually, I found what I was looking for. The Borland Graphics Interface.

My first program in the new system was a very buggy graphing program that has since been lost to time/space. It drew a white background, used a bitmap font that looked vaguely like the Win98 system font, and drew a simple 8 point graph on a grid. I was proud of that.

It's interesting to note that, while I had Turbo Pascal at this time, I also had Turbo C and Turbo C++. But I ignored the others as being "rubbish" and "inferior".

I never change, do I? :P

First forays into 3D

I'd seen many a 3D game by now. Duke Nukem 3D, Quake 2, several PS1 games (Some superbike racing game was my favorite, and Spyro the Dragon 3…)

So of course my ego dictated that I, the fledgeling programmer who jumped right into the graphical side of things and still ignored such important things as data structures, would create a popular 3D game in a single day…

And that was the beginning of my eternal frustration with 3D programming.

I already had the idea that each 3D object was made up of simple shapes. Polygons, basically. So I decided that I could store each point in an array.

Now, at this point, the Z axis was non-existent to my limited knowledge of geometry. So I called my Z axis the D coordinate, for depth.

Soon I had a copy of the Windows 98 Starfield screensaver running in a measly DOS box (320x200 pixels, I believe).

The next logical step was a 'real' object… so I tried a cube and immediately hit into something: Perspective. No matter what I did with my code, the wireframe cube looked wrong.

Eventually, after much hackery, I accidentally figured out the linear interpolation formula for basic perspective… Looking at some of my old code (Most of which is lost forever on floppy disks I can't read, but a few fragments remain on some old CD backups), I did something more or less like this:

int tx = x+(d/100);
int ty = y+(d/100);

This gave me some basic perspective, but then I ran into another problem: The depth. That 100 in that code is basically the 'Far' plane, as defined by myself. Of course, I never figured out that all I had to do was switch it to 1000, or whatever I felt like, to get more Z space to work with…

Anyway, by now I had a wireframe cube that I could move left, right, up, down, backwards and forwards. With flicker, of course (Page flipping came a lot later).

At this point I was already planning my first blockbuster game… Battletanks 3D, a highly original name. I still have one of my 'designs' in a folder somewhere; a simple sketch showing a level (With lots of slopes and obstacles and enemies and such).

So in high hopes, I began to painstakingly map out the coordinates to a blocky tank (I had no concept of the 3D model as a separate data file at that point. File IO was still a dark magick to me…). And then I tried to get it to rotate…

And that's how I originally gave up on 3D programming… though I never actually gave up. I still have reams of paper with grids drawn on them, trying to figure out rotation in 2D and 3D. I never got it (I had an aversion to the Trigonometry functions at the time, because Trigonometry was a scary word)…

Fast forward to 2007

By this time, I'd discovered C and C++, made a Breakout game for DOS in C, migrated to 32 bit, and heard about this very interesting library called "OpenGL". Yeah, I'm slow. Not having access to the internet does that to people.

The rest of what I went through was mostly trial and error. Most of that trial and error resulted in a now-lost 'game' called "Maze" (Still kicking with the creative names). Basically, it was a flat world with cube pillars and some of the worst collision detection I had ever done. Oh, and it was slow, because occlusion, in my own words, "Wasn't necessary on new computers. That's old Build Engine stuff.".

Anyway, the lack of materials, the difficulty of using WinAPI to create windows, and my own laziness all wound up pushing me in the direction of creating 2D games. With GM. Which I did. For three years.

Until I had a brain-fart and somehow came up with this:

Though I still maintain that this is some of the worst patchwork code I've ever written.

And that's when I joined the site in 2010, more or less.

Needless to say, I understand 3D a whole lot better now. I'm able to use shaders, I can model a diffuse point lighting system, and I can still whip up a simple software renderer if I have to. And actually get it to draw polygons and rotate stuff this time.

Some notes about Exile

Something interesting to make note of. Anybody remember this video?

There's something I have to confess about it. I almost completely gave up on the game then and there.

Why? Because of the collision detection. Notice in the video how I painstakingly made sure I didn't touch a wall. Because otherwise I'd get stuck :P

Even by the time this video came out, I still hadn't gotten it right and was still carefully trying to not make contact with the walls.

It was only by my third video that I'd actually figured out a simple preemptive collision system that didn't get you stuck in the walls or end up clipping you through them (Or violently backwards).

Anyway, let me leave you all with this latest screenshot:

And what I'm adding to the engine now? It's big. Bigger than anything I've done in one of my games before. It'll get a video when it's finished.

tl;dr: I did stuff. Shit happened. Things blew up. Explosions. Nuclear war.

Comments

Astryl 11 years, 6 months ago

He's still at it.

Posted a few days ago, apparently.

JuurianChi 11 years, 6 months ago

I thought they were the same person.

Huh.

Snakeman 11 years, 6 months ago

I love how the crosshair for the fps in that video is the Windows loading hourglass

aeron 11 years, 6 months ago

I'm drooling :3

Castypher 11 years, 6 months ago

New site challenge:

All competition participants must go back and finish at least one of their entries.

If you've already finished one or have never competed before, you must start a new one.

Iasper 11 years, 6 months ago

We need a competition to finish previous competition entries.

KaBob799 11 years, 6 months ago

A competition to go back and finish someone elses competition entry

Castypher 11 years, 6 months ago

I'm totally hosting this competition.

EDIT: This derail is all my fault.

Astryl 11 years, 6 months ago

Quote:
New site challenge:

All competition participants must go back and finish at least one of their entries.

That'd actually be an interesting challenge. :P

Astryl 11 years, 6 months ago

When in doubt, roll your own.