Compare commits
	
		
			2 Commits
		
	
	
		
			2a806f515b
			...
			daf7317c08
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| daf7317c08 | |||
| d0c6b363b8 | 
							
								
								
									
										11
									
								
								enemy.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								enemy.c
									
									
									
									
									
								
							| @ -14,7 +14,15 @@ | ||||
| #include "enemy.h" | ||||
| #include "entity.h" | ||||
| 
 | ||||
| Texture2D *enemy_sprite = NULL; | ||||
| 
 | ||||
| Entity *spawn_enemy(void) { | ||||
|   if (enemy_sprite == NULL) { | ||||
|     enemy_sprite = malloc(sizeof(Texture2D)); | ||||
|     Image sprite_img = LoadImage("img/enemy.png"); | ||||
|     *enemy_sprite = LoadTextureFromImage(sprite_img); | ||||
|     UnloadImage(sprite_img); | ||||
|   } | ||||
|   Entity *e = malloc(sizeof(Entity)); | ||||
|   e->name = "Enemy"; | ||||
|   e->properties = malloc(sizeof(Entity)); | ||||
| @ -35,7 +43,8 @@ Entity *spawn_enemy(void) { | ||||
| 
 | ||||
| void draw_enemy(Entity *e) { | ||||
|   EnemyProperties *props = e->properties; | ||||
|   DrawRectangleRec(props->position, RED); | ||||
|   // DrawRectangleRec(props->position, RED);
 | ||||
|   DrawTextureRec(*enemy_sprite, (Rectangle) { props->velocity.x > 0 ? 32 : 0, 0, 32, 32 }, (Vector2) { props->position.x, props->position.y }, WHITE); | ||||
| } | ||||
| 
 | ||||
| void update_position_enemy(Entity *e, float dt) { | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								img/enemy.aseprite
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								img/enemy.aseprite
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								img/enemy.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								img/enemy.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 793 B | 
							
								
								
									
										2
									
								
								player.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								player.c
									
									
									
									
									
								
							| @ -34,7 +34,7 @@ void handle_player_input(Player *p) { | ||||
| } | ||||
| 
 | ||||
| void draw_player(Player *p) { | ||||
|   DrawTextureRec(p->spritesheet, (Rectangle) { 128, 128, 128, 128 }, p->position, WHITE); | ||||
|   DrawTextureRec(p->spritesheet, (Rectangle) { 128, 128, 128, 128 }, (Vector2) { p->position.x - 64, p->position.y - 29 }, WHITE); | ||||
| } | ||||
| 
 | ||||
| void move_player(Player *p) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user