diff --git a/game.c b/game.c new file mode 100644 index 0000000..8d2c581 --- /dev/null +++ b/game.c @@ -0,0 +1,41 @@ +// 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 +#include "game.h" + +void initialize_game(Game *g) { + g->should_close = false; + g->player = malloc(sizeof(Player)); + initialize_player(g->player); +} + +void handle_input(Game *g) { + handle_player_input(g->player); +} + +void run_frame(Game *g) { + handle_input(g); +} + +void draw_frame(Game *g) { + BeginDrawing(); + ClearBackground(RAYWHITE); + draw_player(g->player); + EndDrawing(); +} + +void run_until_closing(Game *g) { + while (!WindowShouldClose() && !g->should_close) { + run_frame(g); + draw_frame(g); + } +} diff --git a/game.h b/game.h new file mode 100644 index 0000000..ac38bb0 --- /dev/null +++ b/game.h @@ -0,0 +1,29 @@ +// 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 . + +#ifndef GAME_H +#define GAME_H + +#include +#include "player.h" + +typedef struct Game { + Player *player; + /* + Levels levels; + Entities entities; + */ + bool should_close; +} Game; + +void initialize_game(Game *g); +void run_until_closing(Game *g); + +#endif diff --git a/main.c b/main.c new file mode 100644 index 0000000..49931af --- /dev/null +++ b/main.c @@ -0,0 +1,41 @@ +// 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 +#include +#include + +#include + +// #include "intro.h" +#include "game.h" + +int main(int argc, char** argv) { + srand(time(NULL)); + InitWindow(800, 550, "Starship Futuretime"); + SetTargetFPS(60); + + /* + if (!getenv("SKIP_INTRO") || strcmp(getenv("SKIP_INTRO"), "1") != 0) { + display_loading(); + Intro *i = load_intro(); + intro_display(i); + } + */ + + Game g; + initialize_game(&g); + + run_until_closing(&g); + + CloseWindow(); + return 0; +} diff --git a/player.c b/player.c new file mode 100644 index 0000000..17a2934 --- /dev/null +++ b/player.c @@ -0,0 +1,43 @@ +// 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 "player.h" + +void initialize_player(Player *p) { + + p->position = (Vector2) { 400, 300 }; + p->pitch = PITCH_NEUTRAL; + p->roll = ROLL_NEUTRAL; +} + +void handle_player_input(Player *p) { + if (IsKeyDown(KEY_DOWN)) p->pitch = PITCH_DESCENDING; + else if (IsKeyDown(KEY_UP)) p->pitch = PITCH_ASCENDING; + else p->pitch = PITCH_NEUTRAL; + + if (IsKeyDown(KEY_LEFT)) p->roll = ROLL_LEFT; + else if (IsKeyDown(KEY_RIGHT)) p->roll = ROLL_RIGHT; + else p->roll = ROLL_NEUTRAL; +} + +void draw_player(Player *p) { + Vector2 nose = { p->roll == ROLL_LEFT ? p->position.x - 50 : + p->roll == ROLL_RIGHT ? p->position.x + 50 : + p->position.x, + p->pitch == PITCH_DESCENDING ? p->position.y + 20 : + p->pitch == PITCH_ASCENDING ? p->position.y - 20 : + p->position.y + }; + Vector2 left_wing = { p->position.x - 100, p->position.y + 50 }; + Vector2 right_wing = { p->position.x + 100, p->position.y + 50 }; + + DrawTriangle(nose, left_wing, right_wing, DARKGRAY); +} diff --git a/player.h b/player.h new file mode 100644 index 0000000..70fbbd5 --- /dev/null +++ b/player.h @@ -0,0 +1,34 @@ +// 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 . +#ifndef PLAYER_H +#define PLAYER_H + +typedef enum PlayerPitch { + PITCH_DESCENDING, + PITCH_NEUTRAL, + PITCH_ASCENDING, +} PlayerPitch; + +typedef enum PlayerRoll { + ROLL_LEFT, + ROLL_NEUTRAL, + ROLL_RIGHT, +} PlayerRoll; + +typedef struct Player { + Vector2 position; + PlayerPitch pitch; + PlayerRoll roll; +} Player; + +void handle_player_input(Player *p); +void draw_player(Player *p); + +#endif