blob: ef46feb1c746dbefb691192d0f5526724b931c4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# prj tiny
A small first-person sword combat game built with [raylib](https://www.raylib.com/). Fight a single enemy in a starlit arena. Built as a learning/prototype project.

## ~features
- **First-person melee combat** — left-click to swing your sword
- **Procedural audio** — sword swings, footsteps, and ambient drone are all generated in code (no audio files needed)
- **Enemy AI** — the enemy auto-attacks on a randomized timer and turns to face you
- **Player death & respawn** — die and you respawn after 2 seconds
- **Title screen + pause menu** — mouse-driven UI with fade transitions
- **Twinkling starfield** — 200 stars with per-star phase animation
- **Streaming background music** — drop in your own `music.ogg`
## ~controls
| Action | Input |
|--------|-------|
| Move | WASD |
| Look | Mouse |
| Swing sword | Left click |
| Pause | ESC |
| Start game | Click PLAY or ENTER |
## ~requirements
- [raylib](https://github.com/raysan5/raylib) (built with audio + OGG/Vorbis support)
- A C compiler (gcc/clang)
- `music.ogg` (optional — place next to the binary)
## ~build
```bash
gcc tiny.c -o tiny -lraylib -lm -lGL -lpthread -ldl -lrt -lvorbisfile -lvorbis -logg
```
For a static build (recommended for distribution):
```bash
gcc tiny.c -o tiny -Wl,-Bstatic -lraylib -lvorbisfile -lvorbis -logg \
-Wl,-Bdynamic -lGL -lm -lpthread -ldl -lrt
```
## ~run
```bash
./tiny
```
> `music.ogg` is loaded relative to your working directory. Place it next to the binary if you want background music. The game runs fine without it.
## ~how it works
The game is a single C file (~625 lines) with no external assets except an optional music file:
- **Graphics:** raylib's 3D immediate-mode API (`DrawCube`, `DrawCylinderEx`, etc.) for the world + sword models, 2D overlay for HUD/menus
- **Audio:** sounds are synthesized at runtime into `Wave` structs and loaded via `LoadSoundFromWave` — no `.wav` files needed
- **Combat:** sword swings are time-based with damage applied at the swing midpoint, gated by a `damage_dealt` flag to prevent multi-hit
- **Camera:** raylib's built-in `CAMERA_FIRST_PERSON` mode
## ~license
Trinity License
|