// Copyright 2025 Bill Rossi // // This file is part of Starship Futuretime // // Starship Futuretime is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. // // Starship Futuretime is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with Starship Futuretime. If not, see . #include #include #include "enemy.h" #include "entity.h" Entity *spawn_enemy(void) { Entity *e = malloc(sizeof(Entity)); e->name = "Enemy"; e->properties = malloc(sizeof(Entity)); e->timer = 1.0; EnemyProperties *props = (EnemyProperties*)e->properties; props->position.x = 400; props->position.y = 50; props->position.width = 25; props->position.height = 25; props->velocity.x = 3; props->velocity.y = 0; e->draw = &draw_enemy; e->tick = &tick_enemy; e->free = &free_enemy; return e; } void draw_enemy(Entity *e) { EnemyProperties *props = e->properties; DrawRectangleRec(props->position, RED); } void tick_enemy(Entity *e, float dt) { EnemyProperties *props = e->properties; if (props->position.x < 200) props->velocity.x = 3; if (props->position.x > 600) props->velocity.x = -3; props->position.x += props->velocity.x; } void free_enemy(Entity *e) { free(e->properties); free(e); }