Files
spaceshipsim/src/ship.h
T

58 lines
1.7 KiB
C
Raw Normal View History

2018-03-25 16:59:03 +02:00
/*
2026-03-16 21:33:30 +01:00
* Copyright (C) 2018,2026 Ortega Froysa, Nicolás <nicolas@ortegas.org>
* Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
2018-03-25 16:59:03 +02:00
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2018-03-25 17:47:31 +02:00
#include <allegro5/allegro.h>
2018-03-25 16:59:03 +02:00
struct ship {
float x, y; ///< The x and y coordinates of the ship.
float velX, velY; ///< The x and y velocities of the ship.
/**
* The direction that the ship is facing in radians, where
* 0 is right facing.
*/
float direction;
};
/**
* @brief Initialize the ship at a position.
*
* @param ship A pointer to the ship object.
* @param x Initial x position of the ship.
* @param y Initial y position of the ship.
*/
2026-03-20 14:32:21 +01:00
void ship_init(struct ship *ship, float x, float y);
2018-03-25 16:59:03 +02:00
/**
* @brief Updates the ship's variables according to keyboard
2026-03-21 13:05:28 +01:00
* input and gravitational forces.
2018-03-25 16:59:03 +02:00
*
* @param ship A pointer to the ship object.
2026-03-21 13:05:28 +01:00
* @param gravity_x Gravitational acceleration in x direction.
* @param gravity_y Gravitational acceleration in y direction.
2018-03-25 16:59:03 +02:00
*/
2026-03-21 13:05:28 +01:00
void ship_update(struct ship *ship, float gravity_x, float gravity_y);
2018-03-25 17:47:31 +02:00
/**
* @brief Draw the ship.
*
* @param ship Ship object to draw.
*/
void ship_draw(struct ship *ship);