Very crude intro
This commit is contained in:
		
							parent
							
								
									4a52d509c9
								
							
						
					
					
						commit
						7f039aa4f2
					
				
							
								
								
									
										
											BIN
										
									
								
								01_text_adventure/img/made_by_bgb.aseprite
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								01_text_adventure/img/made_by_bgb.aseprite
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								01_text_adventure/img/made_by_bgb.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								01_text_adventure/img/made_by_bgb.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 7.1 KiB | 
							
								
								
									
										
											BIN
										
									
								
								01_text_adventure/img/made_w_raylib.aseprite
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								01_text_adventure/img/made_w_raylib.aseprite
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								01_text_adventure/img/made_w_raylib.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								01_text_adventure/img/made_w_raylib.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 6.6 KiB | 
							
								
								
									
										40
									
								
								01_text_adventure/intro.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								01_text_adventure/intro.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| #include <stdlib.h> | ||||
| #include "intro.h" | ||||
| 
 | ||||
| #define FONT_SIZE 36 | ||||
| 
 | ||||
| void display_loading(void) { | ||||
|   int window_width = GetRenderWidth();  | ||||
|   int window_height = GetRenderHeight();  | ||||
|   int loading_width = MeasureText("Loading...", FONT_SIZE); | ||||
|   BeginDrawing(); | ||||
|   DrawText("Loading...", window_width - loading_width, window_height - FONT_SIZE, FONT_SIZE, RAYWHITE); | ||||
|   EndDrawing(); | ||||
| } | ||||
| 
 | ||||
| Intro *load_intro(void) { | ||||
|   Intro *i = malloc(sizeof(Intro)); | ||||
|   i->textures = malloc(sizeof(Texture) * 2); | ||||
| 
 | ||||
|   Image bgb = LoadImage("img/made_by_bgb.png"); | ||||
|   i->textures[0] = LoadTextureFromImage(bgb); | ||||
|   UnloadImage(bgb); | ||||
| 
 | ||||
|   Image ray = LoadImage("img/made_w_raylib.png"); | ||||
|   i->textures[1] = LoadTextureFromImage(ray); | ||||
|   UnloadImage(ray); | ||||
| 
 | ||||
|   i->texture_count = 2; | ||||
|   i->timer = 0.; | ||||
|   return i; | ||||
| } | ||||
| 
 | ||||
| void intro_display(Intro *intro) { | ||||
|   for (int i = 0; i < intro->texture_count; i++) { | ||||
|     intro->timer = GetTime() + 2.0; | ||||
|     BeginDrawing(); | ||||
|     DrawTexture(intro->textures[i], 0, 0, WHITE); | ||||
|     EndDrawing(); | ||||
|     while(GetTime() < intro->timer) {} | ||||
|   } | ||||
| } | ||||
							
								
								
									
										18
									
								
								01_text_adventure/intro.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								01_text_adventure/intro.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| #ifndef _FD_INTRO_ | ||||
| #define _FD_INTRO_ | ||||
| 
 | ||||
| typedef struct Intro Intro; | ||||
| 
 | ||||
| #include <raylib.h> | ||||
| 
 | ||||
| struct Intro { | ||||
|   Texture *textures; | ||||
|   int texture_count; | ||||
|   double timer; | ||||
| }; | ||||
| 
 | ||||
| void display_loading(void); | ||||
| Intro *load_intro(void); | ||||
| void intro_display(Intro *i); | ||||
| 
 | ||||
| #endif | ||||
| @ -4,12 +4,17 @@ | ||||
| 
 | ||||
| #include <raylib.h> | ||||
| 
 | ||||
| #include "intro.h" | ||||
| #include "game.h" | ||||
| 
 | ||||
| int main(void) { | ||||
| int main(int argc, char** argv) { | ||||
|     InitWindow(800, 450, "Text Adventure"); | ||||
|     SetTargetFPS(60); | ||||
| 
 | ||||
|     display_loading(); | ||||
|     Intro *i = load_intro(); | ||||
|     intro_display(i); | ||||
| 
 | ||||
|     Game *g = game_create(); | ||||
| 
 | ||||
|     game_run_until_close(g); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user