added hitbox toggle
This commit is contained in:
		
							parent
							
								
									53130a6d19
								
							
						
					
					
						commit
						6749eeb679
					
				
					 1 changed files with 16 additions and 4 deletions
				
			
		
							
								
								
									
										20
									
								
								src/Main.c
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								src/Main.c
									
										
									
									
									
								
							|  | @ -1,6 +1,5 @@ | |||
| #include "raylib.h" | ||||
| 
 | ||||
| 
 | ||||
| #include "Controls.h" | ||||
| #include "Debug.h" | ||||
| #include "Copying.h" | ||||
|  | @ -11,6 +10,9 @@ | |||
| float EnemyPos_x = 482.0f, EnemyPos_y = 62.0f; | ||||
| float TuxPos_x = 32.0f, TuxPos_y = 62.0f; | ||||
| 
 | ||||
| // Toggle bools
 | ||||
| bool ShowHitbox = false; | ||||
| 
 | ||||
| // Setup Code
 | ||||
| void Func_Setup() | ||||
| { | ||||
|  | @ -39,7 +41,8 @@ void Func_MainGameLoop() | |||
|   bool collision = false; | ||||
| 
 | ||||
|       // GameLoop
 | ||||
|       while (!WindowShouldClose()) { | ||||
|     while (!WindowShouldClose()) { | ||||
| 
 | ||||
|           Func_ShowPos(); | ||||
|           Func_Controls(); | ||||
| 
 | ||||
|  | @ -59,7 +62,9 @@ void Func_MainGameLoop() | |||
|         DrawTexture(tux, TuxPos_x, TuxPos_y, RAYWHITE); | ||||
|         DrawTexture(enemy, EnemyPos_x, EnemyPos_y, RAYWHITE); | ||||
| 
 | ||||
|         if (IsKeyDown(KEY_SPACE)) { | ||||
|         Func_CheckHitboxToggle(); | ||||
| 
 | ||||
|         if (ShowHitbox==true) { | ||||
|           DrawRectangleRec(EnemyHitbox, RED); | ||||
|           DrawRectangleRec(TuxHitbox, BLUE); | ||||
|         } | ||||
|  | @ -70,14 +75,21 @@ void Func_MainGameLoop() | |||
|           DrawText("Tux Vs X ENGINE PROTOTYPE please read the LINCENSE", 50, 18, 20, BLACK); | ||||
|         } | ||||
| 
 | ||||
|         DrawText("Press 'H' to toggle hitboxes", 50, 72, 20, BLACK); | ||||
| 
 | ||||
|       EndDrawing(); | ||||
|      } | ||||
|     } | ||||
|   // Unload Textures
 | ||||
|   UnloadTexture(tux); | ||||
|   UnloadTexture(enemy); | ||||
|   UnloadTexture(arctic); | ||||
| } | ||||
| 
 | ||||
| void Func_CheckHitboxToggle() | ||||
| { | ||||
|   if (IsKeyPressed(KEY_H)) ShowHitbox = !ShowHitbox; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int main() | ||||
| { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue