summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE24
-rw-r--r--README.md46
-rw-r--r--credits.txt7
-rw-r--r--gui.hpp1
-rw-r--r--main.cpp3
-rw-r--r--package.bat14
-rw-r--r--sim.cpp11
7 files changed, 96 insertions, 10 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/README.md b/README.md
index 9bfac79..9c206ba 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,35 @@
Computer-generated catapults.
-Somewhat inspired by [boxcar2d](https://boxcar2d.com).
+Created for [PROCJAM 2020](https://itch.io/jam/procjam).
+
+Somewhat inspired by [boxcar2d](http://boxcar2d.com).
+
+Press F11 to toggle fullscreen and Ctrl+Q (or just close the window) to quit.
+
+## How it works
+
+The algorithm begins by generating 110 random catapults, then throwing out all but the top 10 (in terms of
+the distance the ball traveled).
+Then, for each generation, 100 new catapults are generated from the top 10 from the last generation.
+Each new catapult is a copy of one of the old ones, with a chance of having some "mutations".
+These mutations slightly modify the setup, by changing the positions, sizes, etc. of platforms.
+Each generation has catapults with different mutations rates (20 with a 5% mutation rate per platform, 20 with a 10%
+mutation rate, 20 with a 20% mutation rate, 20 with a 30% mutation rate, and 20 completely random new setups).
## Editor controls
-@TODO
+Left mouse - build / edit platform
+Right mouse - delete platform
+W/A/S/D - pan
+Up/Down - change platform size
+Left/Right - change platform angle
+R - toggle rotating platform
+Q - decrease rotation speed
+E - increase rotation speed
+M - toggle moving platform
+Z - decrease move speed
+X - increase move speed
+space - simulate catapult
# Compiling it yourself
You will need SDL2 and Box2D.
@@ -31,7 +56,7 @@ Now, just run `make release`, and you will get the executable `boxcatapult2d`.
## Windows
First, you will need MSVC and `vcvarsall.bat` in your PATH.
-Then, download SDL2 (Visual C++ 32/64-bit): https://www.libsdl.org/download-2.0.php
+Then, download <a href="https://www.libsdl.org/download-2.0.php" target="_blank">SDL2 (Visual C++ 32/64-bit)</a>.
Copy the contents of the folder `SDL2-something\lib\x64` into the same directory as Boxcatapult2D,
and copy the folder `SDL2-something\include` there too, renaming it to `SDL2`.
@@ -49,3 +74,18 @@ copy bin\Release\box2d.lib ..\..
```
Now, you should be able to run `make.bat release` and you will get `boxcatapult2d.exe`.
+
+## Report a bug
+
+If you find a bug, you can report it to pommicket at gmail.com if you'd like.
+
+## Credits
+Box2D: A physics library
+See: https://box2d.org
+
+Roboto font (assets/font.ttf):
+Courtesy of Google Fonts.
+Apache 2.0 license (see: assets/apache-2.0.txt)
+
+STB truetype (lib/stb\_truetype.h):
+See: https://github.com/nothings/stb
diff --git a/credits.txt b/credits.txt
deleted file mode 100644
index f94553c..0000000
--- a/credits.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Roboto font (assets/font.ttf):
- Courtesy of Google Fonts.
- Apache 2.0 license (see: assets/apache-2.0.txt)
-STB truetype (lib/stb_truetype.h):
- See: https://github.com/nothings/stb
-Box2D:
- See: https://box2d.org
diff --git a/gui.hpp b/gui.hpp
index 451d9e0..d1d707c 100644
--- a/gui.hpp
+++ b/gui.hpp
@@ -65,6 +65,7 @@ typedef struct {
typedef struct {
Input input;
i32 width, height; // window width and height in pixels
+ bool fullscreen;
bool close; // should the window be closed? default: input.closed
void *memory;
size_t memory_size;
diff --git a/main.cpp b/main.cpp
index 02584b9..e8e0361 100644
--- a/main.cpp
+++ b/main.cpp
@@ -432,6 +432,7 @@ int main(void) {
input->mouse_x = x;
input->mouse_y = y;
}
+
{
Uint32 this_frame_ticks = SDL_GetTicks();
@@ -444,6 +445,8 @@ int main(void) {
sim_frame(&frame);
+ SDL_SetWindowFullscreen(window, frame.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
+
SDL_SetWindowTitle(window, frame.title);
if (frame.close) break;
diff --git a/package.bat b/package.bat
new file mode 100644
index 0000000..6bd1ba4
--- /dev/null
+++ b/package.bat
@@ -0,0 +1,14 @@
+@echo off
+del boxcatapult2d-windows.zip
+rd /s/q boxcatapult2d
+mkdir boxcatapult2d
+mkdir boxcatapult2d\assets
+copy assets\*.* boxcatapult2d\assets
+copy LICENSE boxcatapult2d
+copy SDL2.dll boxcatapult2d
+copy README.md boxcatapult2d
+del boxcatapult2d.exe
+
+call make release
+copy boxcatapult2d.exe boxcatapult2d
+7z a boxcatapult2d-windows.zip boxcatapult2d
diff --git a/sim.cpp b/sim.cpp
index 6636ac9..d5eb4b9 100644
--- a/sim.cpp
+++ b/sim.cpp
@@ -260,6 +260,17 @@ void sim_frame(Frame *frame) {
correct_mouse_button(state, &r->button);
}
+ if (keys_pressed[KEY_F11]) {
+ frame->fullscreen = !frame->fullscreen;
+ if (input->nkey_presses == 1) {
+ input->nkey_presses = 0; // consume this key press
+ }
+ }
+ if (state->ctrl && keys_down[KEY_Q]) {
+ frame->close = true;
+ return;
+ }
+
state->win_width = (float)width;
state->win_height = (float)height;
state->aspect_ratio = state->win_width / state->win_height;