Compare commits
No commits in common. "daf7317c08aaf9cd68762ba6f0d6704702dffd35" and "2a806f515bb5a571a5629f383fa72c4400920682" have entirely different histories.
daf7317c08
...
2a806f515b
11
enemy.c
11
enemy.c
@ -14,15 +14,7 @@
|
||||
#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));
|
||||
@ -43,8 +35,7 @@ Entity *spawn_enemy(void) {
|
||||
|
||||
void draw_enemy(Entity *e) {
|
||||
EnemyProperties *props = e->properties;
|
||||
// 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);
|
||||
DrawRectangleRec(props->position, RED);
|
||||
}
|
||||
|
||||
void update_position_enemy(Entity *e, float dt) {
|
||||
|
Binary file not shown.
BIN
img/enemy.png
BIN
img/enemy.png
Binary file not shown.
Before 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 }, (Vector2) { p->position.x - 64, p->position.y - 29 }, WHITE);
|
||||
DrawTextureRec(p->spritesheet, (Rectangle) { 128, 128, 128, 128 }, p->position, WHITE);
|
||||
}
|
||||
|
||||
void move_player(Player *p) {
|
||||
|
Loading…
Reference in New Issue
Block a user