int main() { struct Shape shapes[9]; int i; InitializeCircle(shapes+0, 1, 0, 0); InitializeCircle(shapes+1, 1.5, 6, 8); InitializeCircle(shapes+2, 0.5, -3, 4); InitializeRectangle(shapes+3, 0, 1, 0, 1); InitializeRectangle(shapes+4, 1, 1.1, 10, 20); InitializeRectangle(shapes+5, 1.5, 3.5, 10, 12); InitializeTriangle(shapes+6, 0, 1, 0, 1); InitializeTriangle(shapes+7, 0, 1, 0, 0.1); InitializeTriangle(shapes+8, 0, 10, 0, 50); for (i = 0 ; i < 9 ; i++) { double bbox[4]; printf("Shape %d\n", i); printf("\tArea: %f\n", shapes[i].ft.GetArea(shapes+i)); shapes[i].ft.GetBoundingBox(shapes+i, bbox); printf("\tBbox: %f-%f, %f-%f\n", bbox[0], bbox[1], bbox[2], bbox[3]); } }
// Gameplay Screen Initialization logic void InitGameplayScreen(void) { // TODO: Initialize GAMEPLAY screen variables here! framesCounter = 0; finishScreen = 0; // MAP LAODING // TODO: Read .bmp file propierly in order to get image width & height Color *mapPixels = malloc(GRID_WIDTH*GRID_HEIGHT * sizeof(Color)); mapPixels = GetImageData(LoadImage("assets/gameplay_screen/maps/map.bmp")); maxTriangles = 0; maxPlatforms = 0; for (int i=0; i<GRID_WIDTH*GRID_HEIGHT; i++) { /* printf("r: %i\n", mapPixels[i].r); printf("g: %i\n", mapPixels[i].g); printf("b: %i\n\n", mapPixels[i].b); */ if (mapPixels[i].r == 255 && mapPixels[i].g == 0 && mapPixels[i].b == 0) maxTriangles++; else if (mapPixels[i].r == 0 && mapPixels[i].g == 255 && mapPixels[i].b == 0) maxPlatforms++; } triangles = malloc(maxTriangles * sizeof(TriangleObject)); platforms = malloc(maxPlatforms * sizeof(SquareObject)); int trianglesCounter=0; int platformsCounter=0; for (int y=0; y<GRID_HEIGHT; y++) { for (int x=0; x<GRID_WIDTH; x++) { if (mapPixels[y*GRID_WIDTH+x].r == 255 && mapPixels[y*GRID_WIDTH+x].g == 0 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializeTriangle(&triangles[trianglesCounter], (Vector2){x, y}); trianglesCounter++; } else if (mapPixels[y*GRID_WIDTH+x].r == 0 && mapPixels[y*GRID_WIDTH+x].g == 255 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializePlatform(&platforms[platformsCounter], (Vector2){x, y}); platformsCounter++; } } } free(mapPixels); //DEBUGGING && TESTING variables pause = FALSE; srand(time(NULL)); // Textures loading player.texture = LoadTexture("assets/gameplay_screen/cube_main.png"); triangleTexture = LoadTexture("assets/gameplay_screen/triangle_main.png"); platformTexture = LoadTexture("assets/gameplay_screen/platform_main.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); bg = LoadTexture("assets/gameplay_screen/bg_main.png"); // Sound loading InitAudioDevice(); PlayMusicStream("assets/gameplay_screen/music/Flash_Funk_MarshmelloRemix.ogg"); PauseMusicStream(); SetMusicVolume(0.5f); // Did player win? startGame = FALSE; /* player.texture = LoadTexture("assets/gameplay_screen/debug.png"); triangleTexture = LoadTexture("assets/gameplay_screen/debug.png"); platformTexture = LoadTexture("assets/gameplay_screen/debug.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); */ // Camera initialization mainCamera = (Camera2D){Vector2Right(), (Vector2){6.5f, 6.5f}, Vector2Zero(), TRUE}; // Gravity initialization gravity = (GravityForce){Vector2Up(), 1.5f}; // Ground position and coordinate groundCoordinadeY = GetScreenHeight()/CELL_SIZE-1; groundPositionY = GetOnGridPosition((Vector2){0, groundCoordinadeY}).y; // Player initialization InitializePlayer(&player, (Vector2){4, groundCoordinadeY-1}, (Vector2){0, 15}, 0.35f*GAME_SPEED); /* // Triangles initialization InitializeTriangle(&triangles[0], (Vector2){40, groundCoordinadeY-1}); InitializeTriangle(&triangles[1], (Vector2){50, groundCoordinadeY-1}); InitializeTriangle(&triangles[2], (Vector2){85, groundCoordinadeY-1}); // Platforms initialization InitializePlatform(&platforms[0], (Vector2){20, groundCoordinadeY-1}); InitializePlatform(&platforms[1], (Vector2){21, groundCoordinadeY-1}); InitializePlatform(&platforms[2], (Vector2){22, groundCoordinadeY-1}); InitializePlatform(&platforms[3], (Vector2){23, groundCoordinadeY-2}); InitializePlatform(&platforms[4], (Vector2){24, groundCoordinadeY-2}); */ }