Skip to content

Commit

Permalink
Upload new game: Dr. Turtle & Mr. Gamera
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Jul 25, 2014
1 parent 56a7979 commit 222995c
Show file tree
Hide file tree
Showing 23 changed files with 2,300 additions and 0 deletions.
126 changes: 126 additions & 0 deletions games/drturtle/00_drturtle_screens.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*******************************************************************************************
*
* raylib game - Dr. Turtle & Mr. Gamera
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
*
********************************************************************************************/

#include "raylib.h"

#define MAX_ENEMIES 10

typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen;

int main()
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 1280;
const int screenHeight = 720;

// Init window
InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA");

// Define current screen
GameScreen currentScreen = TITLE;

SetTargetFPS(60); // Setup game frames per second
//--------------------------------------------------------------------------------------

// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------

// Game screens management
switch (currentScreen)
{
case TITLE:
{
// Press enter to change to gameplay screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = GAMEPLAY;
}

} break;
case GAMEPLAY:
{
// Press enter to change to ending screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = ENDING;
}

} break;
case ENDING:
{
// Press enter to change to title screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = TITLE;
}

} break;
default: break;
}
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
BeginDrawing();

ClearBackground(RAYWHITE);

switch (currentScreen)
{
case TITLE:
{
// Draw title screen
DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);

} break;
case GAMEPLAY:
{
// Draw gameplay screen
DrawRectangle(0, 0, screenWidth, screenHeight, RED);
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);

} break;
case ENDING:
{
// Draw ending screen
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);

} break;
default: break;
}

EndDrawing();
//----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

return 0;
}
163 changes: 163 additions & 0 deletions games/drturtle/01_drturtle_scrolling.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*******************************************************************************************
*
* raylib game - Dr. Turtle & Mr. Gamera
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
*
********************************************************************************************/

#include "raylib.h"

#define MAX_ENEMIES 10

typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen;

int main()
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 1280;
const int screenHeight = 720;

// Init window
InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA");

// Load game resources: textures
Texture2D sky = LoadTexture("resources/sky.png");
Texture2D mountains = LoadTexture("resources/mountains.png");
Texture2D sea = LoadTexture("resources/sea.png");

// Define scrolling variables
int backScrolling = 0;
int seaScrolling = 0;

// Define current screen
GameScreen currentScreen = TITLE;

SetTargetFPS(60); // Setup game frames per second
//--------------------------------------------------------------------------------------

// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------

// Game screens management
switch (currentScreen)
{
case TITLE:
{
// Sea scrolling
seaScrolling -= 2;
if (seaScrolling <= -screenWidth) seaScrolling = 0;

// Press enter to change to gameplay screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = GAMEPLAY;
}

} break;
case GAMEPLAY:
{
// Background scrolling logic
backScrolling--;
if (backScrolling <= -screenWidth) backScrolling = 0;

// Sea scrolling logic
seaScrolling -= 8;
if (seaScrolling <= -screenWidth) seaScrolling = 0;

// Press enter to change to ending screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = ENDING;
}

} break;
case ENDING:
{
// Press enter to change to title screen
if (IsKeyPressed(KEY_ENTER))
{
currentScreen = TITLE;
}

} break;
default: break;
}
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
BeginDrawing();

ClearBackground(RAYWHITE);

// Draw background (common to all screens)
DrawTexture(sky, 0, 0, WHITE);

DrawTexture(mountains, backScrolling, 0, WHITE);
DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE);

DrawTexture(sea, seaScrolling, 0, BLUE);
DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE);

switch (currentScreen)
{
case TITLE:
{
// Draw title screen
DrawText("PRESS ENTER", 450, 420, 40, BLACK);

} break;
case GAMEPLAY:
{
// Draw gameplay screen
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);

} break;
case ENDING:
{
// Draw ending screen

// Draw a transparent black rectangle that covers all screen
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));

DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);

} break;
default: break;
}

EndDrawing();
//----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------

// Unload textures
UnloadTexture(sky);
UnloadTexture(mountains);
UnloadTexture(sea);

CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

return 0;
}
Loading

0 comments on commit 222995c

Please sign in to comment.