// Genesaver: copyright 2003 Sam Stafford. #include <GL/glut.h> #include "globals.h" #include "Thing.h" Thing::Thing(void) { } Thing::~Thing(void) { } void Thing::RenderBy( float ax, float ay ) { // Wrap around world edge. float tx = x; float ty = y; x = XNearest( ax ); y = YNearest( ay ); bool vis = (x - ax)*(x - ax) + (y - ay)*(y - ay) <= A_V*A_V; if ( !vis && settings.drawvis ) { x = tx; y = ty; return; } if ( !vis ) settings.alpha = 0.2; glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glTranslatef( 0, 0.5, 0 ); //move to top of screen glScalef( 0.5 / A_V, 0.5 / A_V, 0.5 / A_V ); //scale to vis range glTranslatef( -ax, -ay, 0 ); //center on target creature Render(); glPopMatrix(); x = tx; y = ty; settings.alpha = 1.0; return; } float Thing::XNearest( float ax ) { if ( ax > x ) { if ( ax - x > 1.0 ) return x + 2.0; else return x; } else { if ( x - ax > 1.0 ) return x - 2.0; else return x; } } float Thing::YNearest( float ay ) { if ( ay > y ) { if ( ay - y > 1.0 ) return y + 2.0; else return y; } else { if ( y - ay > 1.0 ) return y - 2.0; else return y; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 4448 | Sam Stafford | Turn this thing into a Windows screensaver. | ||
#2 | 4433 | Sam Stafford |
More work on this little project. The AI is still nonexistent. |
||
#1 | 4430 | Sam Stafford |
Start importing alife/AI code from Genesaver. Much tweaking will need to be done. |
||
//guest/sam_stafford/genesaver/src/Thing.cpp | |||||
#1 | 3052 | Sam Stafford |
Add Genesaver to the Public Depot. It's not in any way Perforce-related, but it does share a bit of code with Jamgraph, and it feels strange to have an open-source project that's not in the PD. |