Sunday, December 24, 2006

The moon on a stick

Gah, I've slapped in my path finding library. So now, with a few tweaks, mouse movement and path finding, is hacked in.

There's a problem though. I split the world into multiple maps and path finding across these maps, probably means changing my path finding code. The multiple maps buisness has always been a headache.

For now I'm happy to get path finding working on a single map. And worry about moving over map boundaries later.

Saturday, December 23, 2006

Old blue cake hat

I had to update from my source repository yesterday as things went horribly wrong. Entites can be teleported around various maps with out problem. It's all pretty horredously inefficent.

I'm adding smooth moving between tiles now. Somewhere down the line I'll bolt on my A* library and somewhere after that I'll finish my modest goals for this small project. (You can walk to a chest open it, recieve a message, then the game ends basically) Then I can get back to merging it with my old Einfall code base.

Oh yes I need to get animation in there too. Considering this is about the third time I've written code like this, in this project - I think this time I've gotten it right.

Also I want to clean my coursework up a little and maybe a add a download. It's not bad, apart from the camera being a bit messed up.

Tuesday, December 19, 2006

High Density

Currently I'm implementing the entity management system for einfall.

It's a little tricky. I want to be able to process / render my various entities. So I should be quickly able to determine what's at a particular x,y tile position and z height.

Any entities on map-1 should be able to be selected as a whole and removed easily. Also entities can be moved from map to map. Yes moving, when moving an entity exists "between tiles", if I want NPC movement to happen at the same time, there could be problems where they manage to land on the same tile. I do want movement to happen at the same time, so this also complicates things, basically an entity can be on one or more tiles. This also works well if I ever wanted to add mulitiled monsters into the game. (Which really I'm suprised we never see in roguelikes)

I've been very good and written tests first. Simplicity is my goal at the moment but not so simple that it's extremely slow.

Wednesday, December 06, 2006

The small grey children, who stand by your bed and watch you while you're sleeping.

Sometimes we need pointers to pointers. Today was one of those days, it's used to pass back information. If you want to pass back info and just pass in a normal pointer, then a copy is made and the pointer outside of the function is never changed.

This is my *arghh* how does it work code.


#include "stdafx.h"
#include

using namespace std;

int b = 3;

void func(int ** i){
*i = &b;
}

int _tmain(int argc, _TCHAR* argv[])
{
int * p;
func(&p);
std::cout << (*p) << std::endl;
char a;
cin >> a;
return 0;
}


My second sweet snippet is cheap cheap openGL matrices.

This takes in an openGL matrix array, like you'd get from glLoadMatrix, then applies to a vector or vertex.


void TransformVector(float * m, Vector3d &v, Vector3d &d)
{
d.x = (m[0] * v.x) + (m[4] * v.y) + (m[8] * v.z) + m[12];
d.y = (m[1] * v.x) + (m[5] * v.y) + (m[9] * v.z) + m[13];
d.z = (m[2] * v.x) + (m[6] * v.y) + (m[10] * v.z) + m[14];
}

Saturday, December 02, 2006

This buffer is for notes you don't want to save,

Another Tightmap checkin. I pulled some code over from Einfall, simplified it a bit and added it. Now when you run your mouse over a map, each tile is highlighted as you hover over it. Which is just what I wanted so yay me.

I noticed this small function seemed to destroy my frame rate ... but on running it a few times - it bounced back up, maybe the JIT stuff?