Compare commits
10 Commits
fd9fd453b3
...
v0.4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d9c211737 | |||
| 4e7e37821e | |||
| f520790f9c | |||
| 44531ab24e | |||
| c1139ddb81 | |||
| da8d83de92 | |||
| bc6881f851 | |||
| b842bd0095 | |||
| bb28285794 | |||
| 6621decc09 |
10
CHANGELOG
10
CHANGELOG
@@ -1,10 +0,0 @@
|
|||||||
v0.1: First Release
|
|
||||||
- Basic simulation.
|
|
||||||
- Information printing.
|
|
||||||
|
|
||||||
v0.2: Menu Bar
|
|
||||||
- Added a menu bar.
|
|
||||||
- Can reset the simulation.
|
|
||||||
|
|
||||||
v0.3: Port to C
|
|
||||||
- Codebase ported to C for better performance.
|
|
||||||
21
CHANGELOG.md
Normal file
21
CHANGELOG.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
## v0.4: More functionality
|
||||||
|
|
||||||
|
- Fix acceleration.
|
||||||
|
- Add fullscreen support.
|
||||||
|
- Pause functionality.
|
||||||
|
|
||||||
|
## v0.3: Port to C
|
||||||
|
|
||||||
|
- Codebase ported to C for better performance.
|
||||||
|
|
||||||
|
## v0.2: Menu Bar
|
||||||
|
|
||||||
|
- Added a menu bar.
|
||||||
|
- Can reset the simulation.
|
||||||
|
|
||||||
|
## v1.0: First Release
|
||||||
|
|
||||||
|
- Basic simulation.
|
||||||
|
- Information printing.
|
||||||
@@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.10)
|
|||||||
project(SpaceShipSim C)
|
project(SpaceShipSim C)
|
||||||
|
|
||||||
set(TARGET_NAME "spaceshipsim")
|
set(TARGET_NAME "spaceshipsim")
|
||||||
set(TARGET_VERSION "0.3")
|
set(TARGET_VERSION "0.4")
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "release")
|
set(CMAKE_BUILD_TYPE "release")
|
||||||
@@ -48,8 +48,7 @@ set(SRCS
|
|||||||
|
|
||||||
add_definitions(-DVERSION="${TARGET_VERSION}")
|
add_definitions(-DVERSION="${TARGET_VERSION}")
|
||||||
|
|
||||||
if(${CMAKE_BUILD_TYPE} STREQUAL "debug" OR
|
if(${CMAKE_BUILD_TYPE} STREQUAL "debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "relwithdebinfo")
|
||||||
${CMAKE_BUILD_TYPE} STREQUAL "relwithdebinfo")
|
|
||||||
add_definitions(-DDEBUG)
|
add_definitions(-DDEBUG)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DNDEBUG)
|
add_definitions(-DNDEBUG)
|
||||||
|
|||||||
@@ -1,39 +1,40 @@
|
|||||||
====================
|
# SpaceShipSim
|
||||||
*** SpaceShipSim ***
|
|
||||||
====================
|
|
||||||
This is a small simulation program of a space ship (with infinite fuel) in a
|
This is a small simulation program of a space ship (with infinite fuel) in a
|
||||||
frictionless environment (space). The idea is to use it for educational
|
frictionless environment (space). The idea is to use it for educational
|
||||||
purposes.
|
purposes.
|
||||||
|
|
||||||
# Compiling
|
## Compiling
|
||||||
-----------
|
|
||||||
In order to build this program you will require the following dependencies:
|
In order to build this program you will require the following dependencies:
|
||||||
|
|
||||||
- GNU GCC (https://gcc.gnu.org/)
|
- A C compiler that supports C99 or higher
|
||||||
- CMake (https://cmake.org/)
|
- CMake 3.10 or higher
|
||||||
- Allegro 5 (http://liballeg.org/)
|
- Allegro 5
|
||||||
|
|
||||||
You can then compile the program via the following commands:
|
You can then compile the program via the following commands:
|
||||||
|
|
||||||
cd build/
|
```bash
|
||||||
cmake ..
|
cd build/
|
||||||
make
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
This will create a release build with compiler optimizations. If you would like
|
This will create a release build with compiler optimizations. If you would like
|
||||||
a debug build then pass the `-DCMAKE_BUILD_TYPE=debug' flag to the `cmake'
|
a debug build then pass the `-DCMAKE_BUILD_TYPE=debug` flag to the `cmake`
|
||||||
command. If you would like to install then run `cmake' with the additional flag
|
command. If you would like to install then run `cmake` with the additional flag
|
||||||
`-DCMAKE_INSTALL_PREFIX=<install_dir>'. If you are installing as a user then
|
`-DCMAKE_INSTALL_PREFIX=<install_dir>`. If you are installing as a user then
|
||||||
you may want to set the installation prefix to `/usr/local/', and if you're
|
you may want to set the installation prefix to `/usr/local/`, and if you're
|
||||||
packaging then please consult your distribution's policies. With this you
|
packaging then please consult your distribution's policies. With this you
|
||||||
should be able to run the `make install' target and install the binary.
|
should be able to run the `make install' target and install the binary.
|
||||||
|
|
||||||
# Contributing
|
## Contributing
|
||||||
--------------
|
|
||||||
If you would like to contribute to the project, send a patch file to my e-mail
|
If you would like to contribute to the project, send a patch file to my e-mail
|
||||||
address: <nortega@themusicinnoise.net>.
|
address: [nicolas@ortegas.org](mailto:nicolas@ortegas.org).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
# License
|
|
||||||
---------
|
|
||||||
As educational software, unless otherwise noted, all files are licensed under
|
As educational software, unless otherwise noted, all files are licensed under
|
||||||
the terms & conditions of the GNU General Public License version 3 or greater
|
the terms & conditions of the GNU General Public License version 3 or greater
|
||||||
(see `LICENSE' file for more information).
|
(see the [license file](LICENSE) for more information).
|
||||||
1
TODO
1
TODO
@@ -1,3 +1,2 @@
|
|||||||
TODO:
|
TODO:
|
||||||
- Add a fullscreen mode.
|
|
||||||
- Add presets with stellar masses (for gravity simulation).
|
- Add presets with stellar masses (for gravity simulation).
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ void handle_event() {
|
|||||||
ALLEGRO_EVENT evnt;
|
ALLEGRO_EVENT evnt;
|
||||||
al_wait_for_event(event_queue, &evnt);
|
al_wait_for_event(event_queue, &evnt);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
switch(evnt.type)
|
switch(evnt.type)
|
||||||
{
|
{
|
||||||
case ALLEGRO_EVENT_TIMER:
|
case ALLEGRO_EVENT_TIMER:
|
||||||
@@ -136,6 +138,7 @@ void handle_event() {
|
|||||||
set_key(evnt.keyboard.keycode, 0);
|
set_key(evnt.keyboard.keycode, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} while(al_get_next_event(event_queue, &evnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
int key_is_down(int code) {
|
int key_is_down(int code) {
|
||||||
|
|||||||
21
src/main.c
21
src/main.c
@@ -38,6 +38,7 @@ const char *help =
|
|||||||
"P - pause/unpause the simulation\n"
|
"P - pause/unpause the simulation\n"
|
||||||
"I - show/hide simulation information\n"
|
"I - show/hide simulation information\n"
|
||||||
"H - show/hide this help information\n"
|
"H - show/hide this help information\n"
|
||||||
|
"F - toggle fullscreen\n"
|
||||||
"Q/ESC - quit";
|
"Q/ESC - quit";
|
||||||
|
|
||||||
const char *info_format =
|
const char *info_format =
|
||||||
@@ -107,6 +108,7 @@ int main() {
|
|||||||
show_info = 1;
|
show_info = 1;
|
||||||
int paused = 0;
|
int paused = 0;
|
||||||
int old_paused = 0;
|
int old_paused = 0;
|
||||||
|
int just_toggled_fullscreen = 0;
|
||||||
while(run)
|
while(run)
|
||||||
{
|
{
|
||||||
handle_event();
|
handle_event();
|
||||||
@@ -127,6 +129,23 @@ int main() {
|
|||||||
ship_update(&ship);
|
ship_update(&ship);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key_is_down(KEY_FULLSCREEN) && !just_toggled_fullscreen)
|
||||||
|
{
|
||||||
|
if(al_get_display_flags(display) & ALLEGRO_FULLSCREEN_WINDOW)
|
||||||
|
{
|
||||||
|
al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, 1);
|
||||||
|
}
|
||||||
|
just_toggled_fullscreen = 1;
|
||||||
|
}
|
||||||
|
else if (!key_is_down(KEY_FULLSCREEN) && just_toggled_fullscreen)
|
||||||
|
{
|
||||||
|
just_toggled_fullscreen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||||
ship_draw(&ship);
|
ship_draw(&ship);
|
||||||
if(show_info)
|
if(show_info)
|
||||||
@@ -148,7 +167,7 @@ int main() {
|
|||||||
{
|
{
|
||||||
al_draw_multiline_text(font,
|
al_draw_multiline_text(font,
|
||||||
al_map_rgb(0xFF, 0xFF, 0xFF),
|
al_map_rgb(0xFF, 0xFF, 0xFF),
|
||||||
WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 50,
|
(float)WINDOW_WIDTH / 2, (float)WINDOW_HEIGHT / 2 - 50,
|
||||||
WINDOW_WIDTH, 10.0f,
|
WINDOW_WIDTH, 10.0f,
|
||||||
ALLEGRO_ALIGN_CENTRE,
|
ALLEGRO_ALIGN_CENTRE,
|
||||||
help);
|
help);
|
||||||
|
|||||||
Reference in New Issue
Block a user