Spriting the days away...

Posted by Astryl on May 8, 2012, 2:18 a.m.

Two days before the comp start, I wrote a 'game plan' for the comp. That is, a list of decisions and reasonings behind the choice of tools.

The choice of C++ was a difficult one, because I have many alternatives. So in the end, I decided on a provisional choice: I'll use whatever I can make the game fastest in once I've finished my artwork.

So I'm now still tweaking the C++ framework (Which is suffering from Nervous Collision Detection Disorder. Collisions work fine, but setting the bounding boxes up is a pain in the ass, to the point where I'm thinking of making a visual editor for the damned things).

Anyway, I still have loads of time to tweak frameworks, because the art is going to take ages. In fact, I won't be too surprised if I have nothing to show at the end of the comp besides a folder full of art, a semi-complete framework and a test game, but hey, that's the way these things go :3

And here I go on a ramble again. Let me shut up now and show you two things:

The sprite-sheet for my main character

The artists among you will notice the obvious flaws. That's fine, because this is a spritesheet composed of my animating work, which is naturally messy (As the animators among you will know). Unless you use Vector Graphics and animate the lazy way. In which case you're a lazy bugger :3

I spent four days on this character (Who is unnamed at the moment, because my mental name generator can't come up with anything more creative than Alaron, which has been used before (NWN2, if I recall)). That is the longest time I've ever spent on a single character's animations, but I'm pleased with the results.

The results

Seen there is a demonstration of the character's abilities at the moment, as well as the first prototype of the Jungle tileset I'm working on.

Ye long section on collision detection

I'll hide this, since I'll probably ramble again.

I've been fighting with a complex collision detection system for my framework for nearly a week now. It started off simply enough: AABB collision detection. Easy enough.

Until I started adding in modifiable Bounding Boxes and Sprite Origins; the transformations I'm having to apply to these things are making my head want to explode.

Anyway, enough with that. I'll fix it, or I won't. Doesn't matter either way.

But I was spending much time today in deep thought on the subject of collision detection, and also on the subject of Raytracing (I'm constructing a little raytracer slowly. Screenshots whenever I get it to render my data).

One of the 'problems' I face when tracing a Ray from the camera through each point in the view plane is collision with perfect spheres (Spheres defined as a Vector with a Radius as opposed to a set of polygons).

Now how to you not only test for an intersection between a Ray and a Sphere, but also calculate the precise point in 3D space where the collision took place, and generate seconday rays from that point?

Well the latter part of the problem is solved using the Dot Product between the Center Point of the Sphere and the collision point, and determining the deflection off the surface based on that angle.

The middle problem, solving for the precise point of collision, is solved using the (again) Dot Product, this time between the view-plane and the center of the sphere, then using the new data along with the radius and a bit of PI to calculate the surface position.

That's all standard, actually, but it's the broad-phase that I was thinking about, and a way to speed it up quite a bit (Depending on the implementation).

I solved this little problem of mine in 2D, where it also works quite well, although I don't use circular collisions anywhere near as much. (Squared Distance is the best alternative in 2D. In 3D as well, actually).

Anyway, imagine this scene (In 2D, viewed from above):

A circle

A line denoting the viewing plane with it's normal (Perpindicular line) pointing towards the sphere (Doesn't have to be precisely centered. Can be facing away too).

A ray (line) drawn from the center of the view plane along it's normal for a set distance.

Our problem is to test whether or not the ray intersects the sphere at any point, at the highest possible speed.

My little solution takes this form:

Normalize the view-plane's vector and multiply it by the radius of the sphere.

Place the new vector on the center point of the sphere

Perform a Line/Line intersection test between the Ray and the new vector V and -V (Negated).

Anyway, depending on the line intersection test you use, this will either be a little bit faster, or a lot slower (3D math can be fickle).

So it's useless, but the very fact that my mind is trying to think this stuff up now must mean that I'm finally getting my head around that math I've been trying to learn.

That got me thinking about raycasting again, which is a much-easier-to-perform subset of raytracing (Only trace along each column instead of for each pixel).

And that gets me thinking of renderer that scans each column, and scans a certain number of patches along each column for extra geometric detail (If I scanned every four pixels, at 320x240 that'd be a total of 19200 scans per frame. A bit hectic, but it could be optimized to make liberal use of the information already gained by the column (You won't have to trace to the column again, basically)).

Mechanical Spiders and Portals

I've been playing Minecraft again, and as usual I end up modding it. Some of the mods out there are just great, like the Portal Gun Mod, and RedPower.

I discovered a little setting in the Portal Gun configuration that enables a primitive form of portal rendering (They're using a second virtual camera, by the looks of things, and their transformations are a bit off, but it's authentic enough. They can't exactly implement a Portal Engine that'll work in Minecraft, because Minecraft is basically using an Octree in conjunction with a low-res Terrain renderer :P)

RedPower, in conjunction with Buildcraft, have provided me with lots of fun construction projects. I'll just put it this way: I'm designing and slowly building a robotic spider mecha. And that's just the awesome bit: I can.

I'm just waiting for a few of the bugs with Frames, specifically the one where vertical cables will stay in place and detach when a movement is made.

What with the extended height limit, RedPower Control/Logic, IndustrialCraft, ComputerCraft and the Portal Gun mod, I see the potential here for a giant rampaging Nuclear Powered Mecha of destruction (Programmed in either 6502 assembly, FORTH, or LISP). :D

Here, have some screenshots

I got it working… to a degree. First of all, the fact that vertically placed Cable Bundles don't 'stick' to the surfaces they're on (When moving, that is) means I had to use a really complicated setup.

Secondly, getting the power to work on nothing but solar panels with the miniscule amount of surface area I had in this model proved near impossible. I need IndustrialCraft. Nuclear Reactors FTW.

Anyway, I'll get back to my plans for world domination the competition, and see if I can tweak my collision code to be a bit less mind-bending, then I'll be back with more progress :P

Comments

Cesque 12 years, 6 months ago

Your character has big feet.

Yes, I did read the blog, dammit - before you accuse me of just looking at the pics.

death 12 years, 6 months ago

that's quite nice. i'm assuming the sprites with the characters hand out is going to be a shield? lol also from the look of it, you won't be able to attack while moving will you?

Alert Games 12 years, 6 months ago

I wonder if theres some editors already made that are free to use.

but anywho nice sprites.

Astryl 12 years, 6 months ago

Thanks everybody. I know my character has big feet Cesque: I drew them >;3

Actually, I did about five different revisions of the feet, then decided to leave them alone until I have more time later on.

I'm now fighting with a problem you're having, just in a different way (Complex forests for a platformer, a town, plains, mountains, etc etc. Using Megaman ZX and Castlevania as references).

@Death: Nope. Magic attacks, actually. And you won't be able to use the sword while moving.