Spacewar/source/Spacewar-Physics.h

63 lines
1.9 KiB
C
Raw Normal View History

2023-10-08 21:22:21 +00:00
// =========================================
// | Spacewar-Physics.h |
// | Copyright (C) 2023, Barra Ó Catháin |
// | See end of file for copyright notice. |
// =========================================
#ifndef SPACEWAR_PHYSICS
#define SPACEWAR_PHYSICS
#include <stdint.h>
#include "xyVector.h"
2023-10-13 13:44:24 +00:00
#include "Spacewar-Server.h"
2023-10-08 21:22:21 +00:00
typedef struct SpacewarShipState
{
bool inPlay;
xyVector engine;
xyVector gravity;
xyVector position;
xyVector velocity;
} SpacewarShipState;
2023-10-15 00:47:23 +00:00
typedef struct SpacewarShipInput
{
double turningAmount, acceleratingAmount;
bool turningClockwise, turningAnticlockwise, accelerating;
} SpacewarShipInput;
2023-10-08 21:22:21 +00:00
typedef struct SpacewarClientInput
{
uint8_t playerNumber;
uint32_t secret;
2023-10-15 00:47:23 +00:00
SpacewarShipInput input;
2023-10-08 21:22:21 +00:00
} SpacewarClientInput;
typedef struct SpacewarState
{
uint64_t tickNumber;
struct timeval timestamp;
SpacewarShipState playerStates[32];
2023-10-15 00:47:23 +00:00
SpacewarShipInput playerInputs[32];
2023-10-08 21:22:21 +00:00
} SpacewarState;
// Does a single step of the physics:
void doPhysicsTick(SpacewarState * state);
#endif
// ========================================================
// | End of Spacewar-Physics.h, copyright notice follows. |
// ========================================================
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.