Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Main.cpp

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include "../DeFacto/Math/Vector.h"
00005 #include "../DeFacto/Game/Level.h"
00006 #include "../DeFacto/Graphics/Image.h"
00007 
00008 /************************************************************************
00009  * Load
00010  */
00011 int load() {
00012         char buf[sizeof(LevelInfo)];
00013         char *filename = "file.lvl";
00014 
00015         LevelInfo lvl;
00016         lvl.data = NULL;
00017 
00018         memset(buf, '\0', sizeof(buf));
00019 
00020         FILE *file = fopen(filename, "rb");
00021         if (file == NULL) return false;
00022 
00023         fread(&lvl, sizeof(lvl), 1, file);
00024 
00025         printf("%s\n", lvl.name);
00026         printf("size: %i x %i\n", lvl.width, lvl.height);
00027 
00028         lvl.data = new unsigned char[lvl.width*lvl.height*3]; //(unsigned char *)malloc(sizeof(unsigned char)*lvl.width*lvl.height*3);
00029         //memset(lvl.data, '\0', sizeof(unsigned char)*lvl.width*lvl.height);
00030         fread(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00031 
00032         fclose(file);
00033 
00034         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00035                 if (i % lvl.width*3 == 0)
00036                         printf("\n");
00037                 if (lvl.data[i] == 255)
00038                         printf("9");
00039                 else if (lvl.data[i] == 15)
00040                         printf("8");
00041                 else if (lvl.data[i] == 240)
00042                         printf("7");
00043                 else
00044                         printf("%i", lvl.data[i]);
00045         }
00046 
00047         delete [] lvl.data;
00048 
00049         return 0;
00050 }
00051 
00052 /************************************************************************
00053  * 1
00054  */
00055 int save1() {
00056         char buf[sizeof(LevelInfo)];
00057         char *filename = "electronic2.lvl";
00058 
00059         memset(buf, '\0', sizeof(buf));
00060 
00061         LevelInfo lvl;
00062 
00063         //char name[32] = "Gravity Pump";
00064         //char map[32] = "gp.map";
00065         //char texWater[32] = "lava1.bmp";
00066         //char texWaterSurface[32] = "lava1Surface.bmp";
00067         //char texWall[32] = "stone.bmp";
00068         //char texFloor[32] = "rock.bmp";
00069 
00070         //memcpy(lvl.name, name, sizeof(name));
00071         //memcpy(lvl.texFloor, texFloor, sizeof(texFloor));
00072         //memcpy(lvl.texWall, texWall, sizeof(texWall));
00073         //memcpy(lvl.texWater, texWater, sizeof(texWater));
00074         //memcpy(lvl.texWaterSurface, texWaterSurface, sizeof(texWaterSurface));
00075 
00076         strcpy(lvl.name, "Electronic - ZeroOne");
00077 
00078         strcpy(lvl.texWater, "electronic.bmp");                                                                 // textures
00079         strcpy(lvl.texWaterSurface, "electronic_surface.bmp");
00080         strcpy(lvl.texWall, "electronic.bmp");
00081         strcpy(lvl.texFloor, "electronic.bmp");
00082 
00083         lvl.numModels = 1;                                                                                                      // models
00084         strcpy(lvl.modelsPath, "data//models//");
00085         strcpy(lvl.models[0], "electronic1.txt");
00086         //strcpy(lvl.models[1], "flying_sphere.txt");
00087 
00088         lvl.waterSurfaceSpeed = 0.2f;                                                                           // constants
00089         lvl.gravity = 9.82f;
00090         lvl.friction = 0.5f;
00091         lvl.music = 1;
00092         lvl.sky = 1;
00093 
00094         lvl.numLights = 4;                                                                                                      // lights
00095                 lvl.lights[0].ambient = Vec4(0.3f, 0.3f, 0.3f, 1.0f);
00096                 lvl.lights[0].color = Vec4(0.5f, 0.5f, 0.5f, 1.0f);
00097                 lvl.lights[0].pos = Vec3(2.0f, 6.0f, 23.0f);
00098                 lvl.lights[0].attenuation = Vec3(1.0f, 0.0f, 0.0f);
00099                 lvl.lights[0].pulse = 0.0f;
00100                 lvl.lights[0].radius = 0.0f;
00101 
00102                 lvl.lights[1].ambient = Vec4(0.3f, 0.1f, 0.1f, 1.0f);
00103                 lvl.lights[1].color = Vec4(0.8f, 0.1f, 0.1f, 1.0f);
00104                 lvl.lights[1].pos = Vec3(28.0f, 1.0f, 15.0f);
00105                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00106                 lvl.lights[1].pulse = 0.5f;
00107                 lvl.lights[1].radius = 5.0f;
00108 
00109                 lvl.lights[2].ambient = Vec4(0.1f, 0.1f, 0.3f, 1.0f);
00110                 lvl.lights[2].color = Vec4(0.1f, 0.1f, 0.8f, 1.0f);
00111                 lvl.lights[2].pos = Vec3(21.0f, 1.0f, 27.0f);
00112                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00113                 lvl.lights[2].pulse = 0.0f;
00114                 lvl.lights[2].radius = 5.0f;
00115 
00116                 lvl.lights[3].ambient = Vec4(0.1f, 0.3f, 0.1f, 1.0f);
00117                 lvl.lights[3].color = Vec4(0.1f, 0.8f, 0.1f, 1.0f);
00118                 lvl.lights[3].pos = Vec3(9.0f, 1.0f, 9.0f);
00119                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00120                 lvl.lights[3].pulse = 0.0f;
00121                 lvl.lights[3].radius = 5.0f;
00122 
00123 
00124         Image *image = new Image();                                                                                                     // map
00125         if (!image->loadImage("..\\WORKING\\lvl\\new\\lvl1.bmp"))
00126                 return -1;
00127 
00128         lvl.width = image->width;
00129         lvl.height = image->height;
00130         lvl.data = image->data;
00131 
00132 
00133         FILE *file = fopen(filename, "wb");                                                                                     // save
00134         if (file == NULL) return false;
00135 
00136         memcpy(buf, &lvl, sizeof(LevelInfo));
00137 
00138         fwrite(&buf, sizeof(LevelInfo), 1, file);
00139         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00140 
00141         fclose(file);
00142 
00143         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00144                 if (i % lvl.width*3 == 0)
00145                         printf("\n");
00146                 if (lvl.data[i] == 255)
00147                         printf("9");
00148                 else if (lvl.data[i] == 15)
00149                         printf("8");
00150                 else if (lvl.data[i] == 240)
00151                         printf("7");
00152                 else
00153                         printf("%i", lvl.data[i]);
00154         }
00155 
00156         delete [] lvl.data;
00157 
00158         return 0;
00159 }
00160 
00161 /************************************************************************
00162  * Crystal 1
00163  */
00164 int saveCrystal1() {
00165         char buf[sizeof(LevelInfo)];
00166         char *filename = "ice3.lvl";
00167 
00168         memset(buf, '\0', sizeof(buf));
00169 
00170         LevelInfo lvl;
00171 
00172         strcpy(lvl.name, "Heaven");
00173 
00174         strcpy(lvl.texWater, "ice.bmp");                                                                        // textures
00175         strcpy(lvl.texWaterSurface, "ice_surface.bmp");
00176         strcpy(lvl.texWall, "ice.bmp");
00177         strcpy(lvl.texFloor, "ice.bmp");
00178 
00179         lvl.numModels = 1;                                                                                                      // models
00180         strcpy(lvl.modelsPath, "data//models//");
00181         strcpy(lvl.models[0], "crystal.txt");
00182         //strcpy(lvl.models[1], "flying_sphere.txt");
00183 
00184         lvl.waterSurfaceSpeed = 0.6f;                                                                           // constants
00185         lvl.gravity = 9.82f;
00186         lvl.friction = 0.2f;
00187         lvl.music = 1;
00188         lvl.sky = 1;
00189 
00190         lvl.numLights = 4;                                                                                                      // lights
00191                 lvl.lights[0].pos = Vec3(7.0f, 7.0f, 26.0f);
00192                 lvl.lights[0].ambient = Vec4(0.5f, 0.5f, 0.5f, 1.0f);
00193                 lvl.lights[0].color = Vec4(0.8f, 0.8f, 0.8f, 1.0f);
00194                 lvl.lights[0].attenuation = Vec3(0.9f, 0.0f, 0.0f);
00195                 lvl.lights[0].pulse = 0.0f;
00196                 lvl.lights[0].radius = 0.0f;
00197 
00198                 lvl.lights[1].pos = Vec3(8.0f, 1.0f, 5.0f);
00199                 lvl.lights[1].ambient = Vec4(0.6f, 0.6f, 0.6f, 1.0f);
00200                 lvl.lights[1].color = Vec4(0.5f, 0.5f, 0.5f, 1.0f);
00201                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00202                 lvl.lights[1].pulse = 0.5f;
00203                 lvl.lights[1].radius = 5.0f;
00204 
00205                 lvl.lights[2].pos = Vec3(25.0f, 1.0f, 22.0f);
00206                 lvl.lights[2].ambient = Vec4(0.3f, 0.3f, 0.6f, 1.0f);
00207                 lvl.lights[2].color = Vec4(0.5f, 0.5f, 0.6f, 1.0f);
00208                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00209                 lvl.lights[2].pulse = 0.0f;
00210                 lvl.lights[2].radius = 5.0f;
00211 
00212                 lvl.lights[3].pos = Vec3(23.0f, 1.0f, 6.0f);
00213                 lvl.lights[3].ambient = Vec4(0.2f, 0.3f, 0.4f, 1.0f);
00214                 lvl.lights[3].color = Vec4(0.5f, 0.5f, 0.5f, 1.0f);
00215                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00216                 lvl.lights[3].pulse = 0.0f;
00217                 lvl.lights[3].radius = 5.0f;
00218 
00219 
00220         Image *image = new Image();                                                                                                     // map
00221         if (!image->loadImage("..\\WORKING\\lvl\\new\\moon.bmp"))
00222                 return -1;
00223 
00224         lvl.width = image->width;
00225         lvl.height = image->height;
00226         lvl.data = image->data;
00227 
00228 
00229         FILE *file = fopen(filename, "wb");                                                                                     // save
00230         if (file == NULL) return false;
00231 
00232         memcpy(buf, &lvl, sizeof(LevelInfo));
00233 
00234         fwrite(&buf, sizeof(LevelInfo), 1, file);
00235         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00236 
00237         fclose(file);
00238 
00239         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00240                 if (i % lvl.width*3 == 0)
00241                         printf("\n");
00242                 if (lvl.data[i] == 255)
00243                         printf("9");
00244                 else if (lvl.data[i] == 15)
00245                         printf("8");
00246                 else if (lvl.data[i] == 240)
00247                         printf("7");
00248                 else
00249                         printf("%i", lvl.data[i]);
00250         }
00251 
00252         delete [] lvl.data;
00253 
00254         return 0;
00255 }
00256 
00257 /************************************************************************
00258  * Radioactive 1
00259  */
00260 int saveRadioactive1() {
00261         char buf[sizeof(LevelInfo)];
00262         char *filename = "radioactive1.lvl";
00263 
00264         memset(buf, '\0', sizeof(buf));
00265 
00266         LevelInfo lvl;
00267 
00268         strcpy(lvl.name, "Radioactive - toxic");
00269 
00270         strcpy(lvl.texWater, "radioactive1_water.bmp");                                                                 // textures
00271         strcpy(lvl.texWaterSurface, "radioactive1_watersurface.bmp");
00272         strcpy(lvl.texWall, "radioactive1.bmp");
00273         strcpy(lvl.texFloor, "radioactive1.bmp");
00274 
00275         lvl.numModels = 1;                                                                                                      // models
00276         strcpy(lvl.modelsPath, "data//models//");
00277         strcpy(lvl.models[0], "cylinder.txt");
00278         //strcpy(lvl.models[1], "flying_sphere.txt");
00279 
00280         lvl.waterSurfaceSpeed = 0.7f;                                                                           // constants
00281         lvl.gravity = 9.82f;
00282         lvl.friction = 1.0f;
00283         lvl.music = 1;
00284         lvl.sky = 1;
00285 
00286         lvl.numLights = 4;                                                                                                      // lights
00287                 lvl.lights[0].pos = Vec3(4.0f, 7.0f, 25.0f);
00288                 lvl.lights[0].ambient = Vec4(0.5f, 0.3f, 0.3f, 1.0f);
00289                 lvl.lights[0].color = Vec4(0.8f, 0.4f, 0.4f, 1.0f);
00290                 lvl.lights[0].attenuation = Vec3(0.9f, 0.0f, 0.0f);
00291                 lvl.lights[0].pulse = 0.0f;
00292                 lvl.lights[0].radius = 0.0f;
00293 
00294                 lvl.lights[1].pos = Vec3(23.0f, 1.0f, 22.0f);
00295                 lvl.lights[1].ambient = Vec4(0.6f, 0.1f, 0.1f, 1.0f);
00296                 lvl.lights[1].color = Vec4(0.8f, 0.1f, 0.1f, 1.0f);
00297                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00298                 lvl.lights[1].pulse = 0.5f;
00299                 lvl.lights[1].radius = 5.0f;
00300 
00301                 lvl.lights[2].pos = Vec3(15.0f, 1.0f, 7.0f);
00302                 lvl.lights[2].ambient = Vec4(0.1f, 0.6f, 0.1f, 1.0f);
00303                 lvl.lights[2].color = Vec4(0.1f, 0.8f, 0.1f, 1.0f);
00304                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00305                 lvl.lights[2].pulse = 0.0f;
00306                 lvl.lights[2].radius = 5.0f;
00307 
00308                 lvl.lights[3].pos = Vec3(15.0f, 1.0f, 15.0f);
00309                 lvl.lights[3].ambient = Vec4(0.2f, 0.6f, 0.2f, 1.0f);
00310                 lvl.lights[3].color = Vec4(0.3f, 0.8f, 0.2f, 1.0f);
00311                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00312                 lvl.lights[3].pulse = 0.0f;
00313                 lvl.lights[3].radius = 5.0f;
00314 
00315 
00316         Image *image = new Image();                                                                                                     // map
00317         if (!image->loadImage("..\\DeFacto\\data\\lvls\\working\\radioactive1.bmp"))
00318                 return -1;
00319 
00320         lvl.width = image->width;
00321         lvl.height = image->height;
00322         lvl.data = image->data;
00323 
00324 
00325         FILE *file = fopen(filename, "wb");                                                                                     // save
00326         if (file == NULL) return false;
00327 
00328         memcpy(buf, &lvl, sizeof(LevelInfo));
00329 
00330         fwrite(&buf, sizeof(LevelInfo), 1, file);
00331         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00332 
00333         fclose(file);
00334 
00335         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00336                 if (i % lvl.width*3 == 0)
00337                         printf("\n");
00338                 if (lvl.data[i] == 255)
00339                         printf("9");
00340                 else if (lvl.data[i] == 15)
00341                         printf("8");
00342                 else if (lvl.data[i] == 240)
00343                         printf("7");
00344                 else
00345                         printf("%i", lvl.data[i]);
00346         }
00347 
00348         delete [] lvl.data;
00349 
00350         return 0;
00351 }
00352 
00353 
00354 /************************************************************************
00355  * saveElectronic1
00356  */
00357 int saveElectronic1() {
00358         char buf[sizeof(LevelInfo)];
00359         char *filename = "electronic2.lvl";
00360 
00361         memset(buf, '\0', sizeof(buf));
00362 
00363         LevelInfo lvl;
00364 
00365         strcpy(lvl.name, "Electronic - ZeroOne");
00366 
00367         strcpy(lvl.texWater, "electronic.bmp");                                                                 // textures
00368         strcpy(lvl.texWaterSurface, "electronic_surface.bmp");
00369         strcpy(lvl.texWall, "electronic.bmp");
00370         strcpy(lvl.texFloor, "electronic.bmp");
00371 
00372         lvl.numModels = 1;                                                                                                      // models
00373         strcpy(lvl.modelsPath, "data//models//");
00374         strcpy(lvl.models[0], "electronic1.txt");
00375         //strcpy(lvl.models[1], "flying_sphere.txt");
00376 
00377         lvl.waterSurfaceSpeed = 0.2f;                                                                           // constants
00378         lvl.gravity = 9.82f;
00379         lvl.friction = 1.0f;
00380         lvl.music = 1;
00381         lvl.sky = 1;
00382 
00383         lvl.numLights = 4;                                                                                                      // lights
00384                 lvl.lights[0].pos = Vec3(4.0f, 7.0f, 25.0f);
00385                 lvl.lights[0].ambient = Vec4(0.5f, 0.7f, 0.5f, 1.0f);
00386                 lvl.lights[0].color = Vec4(0.5f, 0.8f, 0.4f, 1.0f);
00387                 lvl.lights[0].attenuation = Vec3(0.9f, 0.0f, 0.0f);
00388                 lvl.lights[0].pulse = 0.0f;
00389                 lvl.lights[0].radius = 0.0f;
00390 
00391                 lvl.lights[1].pos = Vec3(23.0f, 1.0f, 23.0f);
00392                 lvl.lights[1].ambient = Vec4(0.4f, 0.6f, 0.4f, 1.0f);
00393                 lvl.lights[1].color = Vec4(0.2f, 0.8f, 0.2f, 1.0f);
00394                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00395                 lvl.lights[1].pulse = 0.5f;
00396                 lvl.lights[1].radius = 5.0f;
00397 
00398                 lvl.lights[2].pos = Vec3(23.0f, 1.0f, 8.0f);
00399                 lvl.lights[2].ambient = Vec4(0.3f, 0.6f, 0.3f, 1.0f);
00400                 lvl.lights[2].color = Vec4(0.3f, 0.8f, 0.3f, 1.0f);
00401                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00402                 lvl.lights[2].pulse = 0.0f;
00403                 lvl.lights[2].radius = 5.0f;
00404 
00405                 lvl.lights[3].pos = Vec3(8.0f, 1.0f, 8.0f);
00406                 lvl.lights[3].ambient = Vec4(0.3f, 0.8f, 0.3f, 1.0f);
00407                 lvl.lights[3].color = Vec4(0.3f, 0.8f, 0.3f, 1.0f);
00408                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00409                 lvl.lights[3].pulse = 0.0f;
00410                 lvl.lights[3].radius = 5.0f;
00411 
00412 
00413         Image *image = new Image();                                                                                                     // map
00414         if (!image->loadImage("..\\WORKING\\lvl\\new\\lvl1.bmp"))
00415                 return -1;
00416 
00417         lvl.width = image->width;
00418         lvl.height = image->height;
00419         lvl.data = image->data;
00420 
00421 
00422         FILE *file = fopen(filename, "wb");                                                                                     // save
00423         if (file == NULL) return false;
00424 
00425         memcpy(buf, &lvl, sizeof(LevelInfo));
00426 
00427         fwrite(&buf, sizeof(LevelInfo), 1, file);
00428         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00429 
00430         fclose(file);
00431 
00432         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00433                 if (i % lvl.width*3 == 0)
00434                         printf("\n");
00435                 if (lvl.data[i] == 255)
00436                         printf("9");
00437                 else if (lvl.data[i] == 15)
00438                         printf("8");
00439                 else if (lvl.data[i] == 240)
00440                         printf("7");
00441                 else
00442                         printf("%i", lvl.data[i]);
00443         }
00444 
00445         delete [] lvl.data;
00446 
00447         return 0;
00448 }
00449 
00450 
00451 /************************************************************************
00452  * pink
00453  */
00454 int pink() {
00455         char buf[sizeof(LevelInfo)];
00456         char *filename = "pink3.lvl";
00457 
00458         memset(buf, '\0', sizeof(buf));
00459 
00460         LevelInfo lvl;
00461 
00462         strcpy(lvl.name, "Pink - Fluffy");
00463 
00464         strcpy(lvl.texWater, "pink.bmp");                                                                       // textures
00465         strcpy(lvl.texWaterSurface, "pink_surface.bmp");
00466         strcpy(lvl.texWall, "pink.bmp");
00467         strcpy(lvl.texFloor, "pink.bmp");
00468 
00469         lvl.numModels = 1;                                                                                                      // models
00470         strcpy(lvl.modelsPath, "data//models//");
00471         strcpy(lvl.models[0], "heart.txt");
00472         //strcpy(lvl.models[1], "flying_sphere.txt");
00473 
00474         lvl.waterSurfaceSpeed = 0.2f;                                                                           // constants
00475         lvl.gravity = 9.82f;
00476         lvl.friction = 1.0f;
00477         lvl.music = 1;
00478         lvl.sky = 1;
00479 
00480         lvl.numLights = 4;                                                                                                      // lights
00481                 lvl.lights[0].pos = Vec3(4.0f, 7.0f, 25.0f);
00482                 lvl.lights[0].ambient = Vec4(0.7f, 0.5f, 0.5f, 1.0f);
00483                 lvl.lights[0].color = Vec4(0.5f, 0.8f, 0.4f, 1.0f);
00484                 lvl.lights[0].attenuation = Vec3(0.9f, 0.0f, 0.0f);
00485                 lvl.lights[0].pulse = 0.0f;
00486                 lvl.lights[0].radius = 0.0f;
00487 
00488                 lvl.lights[1].pos = Vec3(23.0f, 1.0f, 23.0f);
00489                 lvl.lights[1].ambient = Vec4(0.6f, 0.4f, 0.4f, 1.0f);
00490                 lvl.lights[1].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00491                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00492                 lvl.lights[1].pulse = 0.5f;
00493                 lvl.lights[1].radius = 5.0f;
00494 
00495                 lvl.lights[2].pos = Vec3(23.0f, 1.0f, 8.0f);
00496                 lvl.lights[2].ambient = Vec4(0.6f, 0.3f, 0.3f, 1.0f);
00497                 lvl.lights[2].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00498                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00499                 lvl.lights[2].pulse = 0.0f;
00500                 lvl.lights[2].radius = 5.0f;
00501 
00502                 lvl.lights[3].pos = Vec3(8.0f, 1.0f, 8.0f);
00503                 lvl.lights[3].ambient = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00504                 lvl.lights[3].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00505                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00506                 lvl.lights[3].pulse = 0.0f;
00507                 lvl.lights[3].radius = 5.0f;
00508 
00509 
00510         Image *image = new Image();                                                                                                     // map
00511         if (!image->loadImage("..\\WORKING\\lvl\\new\\crystalcastle.bmp"))
00512                 return -1;
00513 
00514         lvl.width = image->width;
00515         lvl.height = image->height;
00516         lvl.data = image->data;
00517 
00518 
00519         FILE *file = fopen(filename, "wb");                                                                                     // save
00520         if (file == NULL) return false;
00521 
00522         memcpy(buf, &lvl, sizeof(LevelInfo));
00523 
00524         fwrite(&buf, sizeof(LevelInfo), 1, file);
00525         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00526 
00527         fclose(file);
00528 
00529         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00530                 if (i % lvl.width*3 == 0)
00531                         printf("\n");
00532                 if (lvl.data[i] == 255)
00533                         printf("9");
00534                 else if (lvl.data[i] == 15)
00535                         printf("8");
00536                 else if (lvl.data[i] == 240)
00537                         printf("7");
00538                 else
00539                         printf("%i", lvl.data[i]);
00540         }
00541 
00542         delete [] lvl.data;
00543 
00544         return 0;
00545 }
00546 
00547 /************************************************************************
00548  * lava
00549  */
00550 int lava() {
00551         char buf[sizeof(LevelInfo)];
00552         char *filename = "lava3.lvl";
00553 
00554         memset(buf, '\0', sizeof(buf));
00555 
00556         LevelInfo lvl;
00557 
00558         strcpy(lvl.name, "Lava - Volcano");
00559 
00560         strcpy(lvl.texWater, "lava.bmp");                                                                       // textures
00561         strcpy(lvl.texWaterSurface, "lava_surface.bmp");
00562         strcpy(lvl.texWall, "lava.bmp");
00563         strcpy(lvl.texFloor, "lava.bmp");
00564 
00565         lvl.numModels = 1;                                                                                                      // models
00566         strcpy(lvl.modelsPath, "data//models//");
00567         strcpy(lvl.models[0], "blob.txt");
00568         //strcpy(lvl.models[1], "flying_sphere.txt");
00569 
00570         lvl.waterSurfaceSpeed = 0.7f;                                                                           // constants
00571         lvl.gravity = 9.82f;
00572         lvl.friction = 1.0f;
00573         lvl.music = 1;
00574         lvl.sky = 1;
00575 
00576         lvl.numLights = 4;                                                                                                      // lights
00577                 lvl.lights[0].pos = Vec3(4.0f, 7.0f, 25.0f);
00578                 lvl.lights[0].ambient = Vec4(0.7f, 0.5f, 0.5f, 1.0f);
00579                 lvl.lights[0].color = Vec4(0.5f, 0.6f, 0.4f, 1.0f);
00580                 lvl.lights[0].attenuation = Vec3(0.9f, 0.0f, 0.0f);
00581                 lvl.lights[0].pulse = 0.0f;
00582                 lvl.lights[0].radius = 0.0f;
00583 
00584                 lvl.lights[1].pos = Vec3(23.0f, 1.0f, 23.0f);
00585                 lvl.lights[1].ambient = Vec4(0.8f, 0.4f, 0.4f, 1.0f);
00586                 lvl.lights[1].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00587                 lvl.lights[1].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00588                 lvl.lights[1].pulse = 0.5f;
00589                 lvl.lights[1].radius = 5.0f;
00590 
00591                 lvl.lights[2].pos = Vec3(23.0f, 1.0f, 8.0f);
00592                 lvl.lights[2].ambient = Vec4(0.6f, 0.3f, 0.3f, 1.0f);
00593                 lvl.lights[2].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00594                 lvl.lights[2].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00595                 lvl.lights[2].pulse = 0.0f;
00596                 lvl.lights[2].radius = 5.0f;
00597 
00598                 lvl.lights[3].pos = Vec3(8.0f, 1.0f, 8.0f);
00599                 lvl.lights[3].ambient = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00600                 lvl.lights[3].color = Vec4(0.8f, 0.3f, 0.3f, 1.0f);
00601                 lvl.lights[3].attenuation = Vec3(0.5f, 0.1f, 0.02f);
00602                 lvl.lights[3].pulse = 0.0f;
00603                 lvl.lights[3].radius = 5.0f;
00604 
00605 
00606         Image *image = new Image();                                                                                                     // map
00607         if (!image->loadImage("..\\WORKING\\lvl\\new\\Vulcano.bmp"))
00608                 return -1;
00609 
00610         lvl.width = image->width;
00611         lvl.height = image->height;
00612         lvl.data = image->data;
00613 
00614 
00615         FILE *file = fopen(filename, "wb");                                                                                     // save
00616         if (file == NULL) return false;
00617 
00618         memcpy(buf, &lvl, sizeof(LevelInfo));
00619 
00620         fwrite(&buf, sizeof(LevelInfo), 1, file);
00621         fwrite(lvl.data, sizeof(unsigned char)*lvl.width*lvl.height*3, 1, file);
00622 
00623         fclose(file);
00624 
00625         for (int i=0; i<lvl.width*lvl.height*3; i+=3) {
00626                 if (i % lvl.width*3 == 0)
00627                         printf("\n");
00628                 if (lvl.data[i] == 255)
00629                         printf("9");
00630                 else if (lvl.data[i] == 15)
00631                         printf("8");
00632                 else if (lvl.data[i] == 240)
00633                         printf("7");
00634                 else
00635                         printf("%i", lvl.data[i]);
00636         }
00637 
00638         delete [] lvl.data;
00639 
00640         return 0;
00641 }
00642 
00643 int main() {
00644         saveElectronic1();
00645         return 0;
00646 }

Generated on Sun Jun 5 15:47:04 2005 for Defacto by  doxygen 1.4.3