Skip to content

aapadill/cubAI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prompt me maybe: AI-Assisted Retro Ray-Casting Engine

A first-person shooter prototype combining classic graphics with generative AI power.

Prompt Me Maybe is a retro-inspired ray-casting engine written in C, powered by MLX42. At its core, it recreates the charm of early FPS games — but with a twist: generative AI is used to produce game assets like weapons, textures, and more.

The result is a hybrid workflow: fast, real-time rendering meets creative iteration through AI prompts. This is not just a game demo — it’s a proof of concept for AI-assisted game development, and a game-changer for the future of gaming.


Features

  • 🎨 AI-Assisted Asset Creation: Weapons are now generated by open-ai prompt. In future, doors, wall textures, NPC designs or even game play will be produced using prompt-driven workflows — empowering rapid prototyping.
  • Ray-Casting Rendering: Real-time 3D perspective rendering from a 2D grid map, mimicking early FPS engines.
  • Minimap: A top-down live map showing player position and current rays.
  • Floor & Ceiling Coloring: User-configurable RGB values in .cub files for stylistic flexibility.
  • Dynamic Doors: Doors open and close when the player approaches, complete with animated transitions (also AI-generated).
  • Interactive Sprites: Support for displaying enemy and item sprites (AI-generated or hand-made).
  • Animated HUD Hands: Fully animated weapon hands, generated using AI image models and optimized for sprite-based animation.
  • Keyboard & Mouse Controls: Smooth first-person movement, camera rotation, shooting mechanics, and weapon switching.
  • Custom Map Configuration: Easily define levels using .cub files for layout, textures, and colors.

Screenshots

Rotation demo


Dependencies

  • MLX42 (with PNG support)
  • C compiler (GCC or Clang)
  • stb_image & stb_image_write (bundled)
  • cJSON for JSON parsing
  • POSIX libraries (pthread, math, fcntl)

API Key Setup

This project uses the OpenAI API for AI-assisted asset generation. You need to provide your own API key to enable this functionality.

How to add your API key:

  • Open src/api.c
  • Find the macro or variable where the API key is defined (e.g., #define API_KEY "your_api_key_here")
  • Replace "your_api_key_here" with your actual OpenAI API key as a string.

Alternatively, you can modify the code to load the key from an environment variable or a configuration file for better security.

Note: Keep your API key private and never commit it to public repositories.

If you don't have an API key, get one at https://platform.openai.com/account/api-keys.


Building

# Clone the repo
git clone https://github.com/aapadill/cub3d.git
cd cub3d

# Build using Make (adjust as needed)
make

Installing Dependencies (macOS/Linux)

Before building, make sure the following libraries are installed: macOS (with Homebrew)

# Install cJSON (for JSON parsing)
brew install cjson

# Install GLFW (required by MLX42)
brew install glfw

# Install libpng (for PNG support)
brew install libpng

# Install curl (if your API uses libcurl to make HTTP requests)
brew install curl

# Optional: If make is missing
xcode-select --install

Linux (Ubuntu/Debian-based)

sudo apt update

# Install build essentials
sudo apt install build-essential

# Install dependencies
sudo apt install libcjson-dev libglfw3-dev libpng-dev libcurl4-openssl-dev

🧪 Test tip: If you run into build issues, make sure your compiler supports C99 and that all libraries are correctly linked in the Makefile.


Usage

./cub3d path/to/map.cub [--strict]
  • --strict: Enforce stricter map closure rules.

.cub File Format

NO path/to/north.png
SO path/to/south.png
WE path/to/west.png
EA path/to/east.png
DO path/to/door.png
F 220,100,0      # Floor RGB
C 225,30,0       # Ceiling RGB

1111111
1     1
1  N   1
1  D   1
1111111
  • N/S/E/W: Player start orientation
  • D: Door tile
  • 1: Wall
  • 0 or space: Floor

Controls

Key / Mouse Action
W / A / S / D Move forward/left/back/right
Left / Right Arrows Rotate camera
Mouse Drag (Tab) Free-look
Space / Left Click Shoot (trigger hand animation)
2 Change weapon (enter object name)
0 Talk to NPC (needs to be close)
Esc Quit

Project Structure

├── include/          # Headers
│   └── cub3D.h
├── src/              # Source files
│   ├── main.c
│   ├── parsing.c
│   ├── movement.c
│   ├── ray.c
│   ├── utils.c       # entry_screen, draw_floor_and_ceiling, etc.
|   ├── api.c					# Open ai api call
│   └── ...
├── textures/         # Default textures & AI-generated hands
│   ├── hand/         # Hand sprite frames
│   └── pics/         # Wall & door PNGs
│   └── ...
├── map.cub           # Example map file
├── Makefile
└── README.md

Contributing

Feel free to open issues or submit pull requests. Please follow the existing coding style and provide clear commit messages.


License

This project is licensed under the MIT License. See LICENSE for details.

About

Ray-casting engine + AI gen weapons (for now..)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 50.7%
  • C 48.3%
  • Makefile 1.0%