Skip to content

Commit 222995c

Browse files
committed
Upload new game: Dr. Turtle & Mr. Gamera
1 parent 56a7979 commit 222995c

23 files changed

+2300
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*******************************************************************************************
2+
*
3+
* raylib game - Dr. Turtle & Mr. Gamera
4+
*
5+
* Welcome to raylib!
6+
*
7+
* To test examples, just press F6 and execute raylib_compile_execute script
8+
* Note that compiled executable is placed in the same folder as .c file
9+
*
10+
* You can find all basic examples on C:\raylib\raylib\examples folder or
11+
* raylib official webpage: www.raylib.com
12+
*
13+
* Enjoy using raylib. :)
14+
*
15+
* This game has been created using raylib 1.1 (www.raylib.com)
16+
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
17+
*
18+
* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
19+
*
20+
********************************************************************************************/
21+
22+
#include "raylib.h"
23+
24+
#define MAX_ENEMIES 10
25+
26+
typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen;
27+
28+
int main()
29+
{
30+
// Initialization
31+
//--------------------------------------------------------------------------------------
32+
const int screenWidth = 1280;
33+
const int screenHeight = 720;
34+
35+
// Init window
36+
InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA");
37+
38+
// Define current screen
39+
GameScreen currentScreen = TITLE;
40+
41+
SetTargetFPS(60); // Setup game frames per second
42+
//--------------------------------------------------------------------------------------
43+
44+
// Main game loop
45+
while (!WindowShouldClose()) // Detect window close button or ESC key
46+
{
47+
// Update
48+
//----------------------------------------------------------------------------------
49+
50+
// Game screens management
51+
switch (currentScreen)
52+
{
53+
case TITLE:
54+
{
55+
// Press enter to change to gameplay screen
56+
if (IsKeyPressed(KEY_ENTER))
57+
{
58+
currentScreen = GAMEPLAY;
59+
}
60+
61+
} break;
62+
case GAMEPLAY:
63+
{
64+
// Press enter to change to ending screen
65+
if (IsKeyPressed(KEY_ENTER))
66+
{
67+
currentScreen = ENDING;
68+
}
69+
70+
} break;
71+
case ENDING:
72+
{
73+
// Press enter to change to title screen
74+
if (IsKeyPressed(KEY_ENTER))
75+
{
76+
currentScreen = TITLE;
77+
}
78+
79+
} break;
80+
default: break;
81+
}
82+
//----------------------------------------------------------------------------------
83+
84+
// Draw
85+
//----------------------------------------------------------------------------------
86+
BeginDrawing();
87+
88+
ClearBackground(RAYWHITE);
89+
90+
switch (currentScreen)
91+
{
92+
case TITLE:
93+
{
94+
// Draw title screen
95+
DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
96+
DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
97+
98+
} break;
99+
case GAMEPLAY:
100+
{
101+
// Draw gameplay screen
102+
DrawRectangle(0, 0, screenWidth, screenHeight, RED);
103+
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
104+
105+
} break;
106+
case ENDING:
107+
{
108+
// Draw ending screen
109+
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
110+
DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
111+
112+
} break;
113+
default: break;
114+
}
115+
116+
EndDrawing();
117+
//----------------------------------------------------------------------------------
118+
}
119+
120+
// De-Initialization
121+
//--------------------------------------------------------------------------------------
122+
CloseWindow(); // Close window and OpenGL context
123+
//--------------------------------------------------------------------------------------
124+
125+
return 0;
126+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*******************************************************************************************
2+
*
3+
* raylib game - Dr. Turtle & Mr. Gamera
4+
*
5+
* Welcome to raylib!
6+
*
7+
* To test examples, just press F6 and execute raylib_compile_execute script
8+
* Note that compiled executable is placed in the same folder as .c file
9+
*
10+
* You can find all basic examples on C:\raylib\raylib\examples folder or
11+
* raylib official webpage: www.raylib.com
12+
*
13+
* Enjoy using raylib. :)
14+
*
15+
* This game has been created using raylib 1.1 (www.raylib.com)
16+
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
17+
*
18+
* Copyright (c) 2014 Ramon Santamaria (Ray San - [email protected])
19+
*
20+
********************************************************************************************/
21+
22+
#include "raylib.h"
23+
24+
#define MAX_ENEMIES 10
25+
26+
typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen;
27+
28+
int main()
29+
{
30+
// Initialization
31+
//--------------------------------------------------------------------------------------
32+
const int screenWidth = 1280;
33+
const int screenHeight = 720;
34+
35+
// Init window
36+
InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA");
37+
38+
// Load game resources: textures
39+
Texture2D sky = LoadTexture("resources/sky.png");
40+
Texture2D mountains = LoadTexture("resources/mountains.png");
41+
Texture2D sea = LoadTexture("resources/sea.png");
42+
43+
// Define scrolling variables
44+
int backScrolling = 0;
45+
int seaScrolling = 0;
46+
47+
// Define current screen
48+
GameScreen currentScreen = TITLE;
49+
50+
SetTargetFPS(60); // Setup game frames per second
51+
//--------------------------------------------------------------------------------------
52+
53+
// Main game loop
54+
while (!WindowShouldClose()) // Detect window close button or ESC key
55+
{
56+
// Update
57+
//----------------------------------------------------------------------------------
58+
59+
// Game screens management
60+
switch (currentScreen)
61+
{
62+
case TITLE:
63+
{
64+
// Sea scrolling
65+
seaScrolling -= 2;
66+
if (seaScrolling <= -screenWidth) seaScrolling = 0;
67+
68+
// Press enter to change to gameplay screen
69+
if (IsKeyPressed(KEY_ENTER))
70+
{
71+
currentScreen = GAMEPLAY;
72+
}
73+
74+
} break;
75+
case GAMEPLAY:
76+
{
77+
// Background scrolling logic
78+
backScrolling--;
79+
if (backScrolling <= -screenWidth) backScrolling = 0;
80+
81+
// Sea scrolling logic
82+
seaScrolling -= 8;
83+
if (seaScrolling <= -screenWidth) seaScrolling = 0;
84+
85+
// Press enter to change to ending screen
86+
if (IsKeyPressed(KEY_ENTER))
87+
{
88+
currentScreen = ENDING;
89+
}
90+
91+
} break;
92+
case ENDING:
93+
{
94+
// Press enter to change to title screen
95+
if (IsKeyPressed(KEY_ENTER))
96+
{
97+
currentScreen = TITLE;
98+
}
99+
100+
} break;
101+
default: break;
102+
}
103+
//----------------------------------------------------------------------------------
104+
105+
// Draw
106+
//----------------------------------------------------------------------------------
107+
BeginDrawing();
108+
109+
ClearBackground(RAYWHITE);
110+
111+
// Draw background (common to all screens)
112+
DrawTexture(sky, 0, 0, WHITE);
113+
114+
DrawTexture(mountains, backScrolling, 0, WHITE);
115+
DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE);
116+
117+
DrawTexture(sea, seaScrolling, 0, BLUE);
118+
DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE);
119+
120+
switch (currentScreen)
121+
{
122+
case TITLE:
123+
{
124+
// Draw title screen
125+
DrawText("PRESS ENTER", 450, 420, 40, BLACK);
126+
127+
} break;
128+
case GAMEPLAY:
129+
{
130+
// Draw gameplay screen
131+
DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
132+
133+
} break;
134+
case ENDING:
135+
{
136+
// Draw ending screen
137+
138+
// Draw a transparent black rectangle that covers all screen
139+
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));
140+
141+
DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
142+
143+
} break;
144+
default: break;
145+
}
146+
147+
EndDrawing();
148+
//----------------------------------------------------------------------------------
149+
}
150+
151+
// De-Initialization
152+
//--------------------------------------------------------------------------------------
153+
154+
// Unload textures
155+
UnloadTexture(sky);
156+
UnloadTexture(mountains);
157+
UnloadTexture(sea);
158+
159+
CloseWindow(); // Close window and OpenGL context
160+
//--------------------------------------------------------------------------------------
161+
162+
return 0;
163+
}

0 commit comments

Comments
 (0)