00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "WinMainSelector.h"
00025 #if defined COMPILE_DEMOMASSIVE
00026
00027 #include "..\AEngine\AEngine.h"
00028
00029
00030 ATexture tankTexture = NULL;
00031 AMesh tankMesh = NULL;
00032 AMesh turretMesh = NULL;
00033 FLOAT camTheta, camRadius, camHeight;
00034 Vec3D tankPos;
00035 FLOAT tankTheta, turretTheta;
00036
00037
00038 void init()
00039 {
00040 sys_showConsole(true);
00041
00042 tankTexture = load_texture("textures\\units\\tank_light.tga");
00043 tankMesh = load_mesh("models\\parts\\tank_light_chasis.obj");
00044 turretMesh = load_mesh("models\\parts\\tank_light_turret.obj");
00045
00046 camTheta = 0.0f;
00047 camRadius = 30.0f;
00048 camHeight = 10.0f;
00049
00050 tankPos = Vec3D(0.0f,0.0f,0.0f);
00051 tankTheta = turretTheta = 0.0f;
00052 }
00053
00054 void update()
00055 {
00056 Vec3D camPos( cosf(camTheta)*camRadius, sinf(camTheta)*camRadius, camHeight );
00057 const Vec3D origin(0.0f,0.0f,0.0f);
00058 camera_set( camPos, origin, 0.1f );
00059
00060
00061 if( input_isKeyDown(KeyCodes::key_LEFT) ) camTheta -= 0.05f;
00062 if( input_isKeyDown(KeyCodes::key_RIGHT) ) camTheta += 0.05f;
00063 if( input_isKeyDown(KeyCodes::key_UP) ) camRadius -= 0.3f;
00064 if( input_isKeyDown(KeyCodes::key_DOWN) ) camRadius += 0.3f;
00065 if( input_isKeyDown(KeyCodes::key_PRIOR) ) camHeight += 0.3f;
00066 if( input_isKeyDown(KeyCodes::key_NEXT) ) camHeight -= 0.3f;
00067
00068
00069 if( input_isKeyDown(KeyCodes::key_A) ) tankTheta -= 2.0f;
00070 if( input_isKeyDown(KeyCodes::key_D) ) tankTheta += 2.0f;
00071 FLOAT radian = D3DXToRadian(tankTheta);
00072 if( input_isKeyDown(KeyCodes::key_W) ) tankPos += 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00073 if( input_isKeyDown(KeyCodes::key_S) ) tankPos -= 0.1f*Vec3D(cosf(radian),sinf(radian),0);
00074
00075
00076 if( input_isKeyDown(KeyCodes::key_Q) ) turretTheta -= 1.5f;
00077 if( input_isKeyDown(KeyCodes::key_E) ) turretTheta += 1.5f;
00078 }
00079
00080 void render()
00081 {
00082 overlay_text() << "Use the arrow keys and the PgUp/PgDown to control CAMERA" << endl;
00083 overlay_text() << "Use W/S/A/D to control TANK" << endl;
00084 overlay_text() << "Use Q/E to control TURRET";
00085 overlay_textOut( Vec2D(0.0f,0.0f), 1.0f );
00086
00087 const Vec3D tankSize( 4.0f, 2.0f, 1.0f );
00088 const Vec3D turretSize( 3.7f, 1.7f, 1.1f );
00089
00090 int n = 25;
00091 int N = n*n;
00092 Vec3D p;
00093
00094 for( int i=0; i<N; i++ )
00095 {
00096 p = tankPos + 5.0f*Vec3D( (FLOAT)(i/n), (FLOAT)(i%n), 0.0f );
00097 mesh_render( tankMesh, p, tankSize, Vec3D(tankTheta,90.0f,0.0f), tankTexture );
00098 mesh_render( turretMesh, p, turretSize, Vec3D(tankTheta+turretTheta,90.0f,0.0f), tankTexture );
00099 }
00100 }
00101
00102 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR, INT )
00103 {
00104 sys_init(hInst,800,600,32,false);
00105 sys_setInitFunc(init);
00106 sys_setUpdateFunc(update);
00107 sys_setRenderFunc(render);
00108 sys_go();
00109 return 0;
00110 }
00111
00112 #endif