Go to file
John McCardle d93642094e Squashed commit of the following: [alpha_streamline_1]
the low-hanging fruit of pre-existing issues and standardizing the
Python interfaces

Special thanks to Claude Code, ~100k output tokens for this merge

    🤖 Generated with [Claude Code](https://claude.ai/code)
    Co-Authored-By: Claude <noreply@anthropic.com>

commit 99f301e3a0
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Jul 5 16:25:32 2025 -0400

    Add position tuple support and pos property to UI elements

    closes #83, closes #84

    - Issue #83: Add position tuple support to constructors
      - Frame and Sprite now accept both (x, y) and ((x, y)) forms
      - Also accept Vector objects as position arguments
      - Caption and Entity already supported tuple/Vector forms
      - Uses PyVector::from_arg for flexible position parsing

    - Issue #84: Add pos property to Frame and Sprite
      - Added pos getter that returns a Vector
      - Added pos setter that accepts Vector or tuple
      - Provides consistency with Caption and Entity which already had pos properties
      - All UI elements now have a uniform way to get/set positions as Vectors

    Both features improve API consistency and make it easier to work with positions.

commit 2f2b488fb5
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Jul 5 16:18:10 2025 -0400

    Standardize sprite_index property and add scale_x/scale_y to UISprite

    closes #81, closes #82

    - Issue #81: Standardized property name to sprite_index across UISprite and UIEntity
      - Added sprite_index as the primary property name
      - Kept sprite_number as a deprecated alias for backward compatibility
      - Updated repr() methods to use sprite_index
      - Updated animation system to recognize both names

    - Issue #82: Added scale_x and scale_y properties to UISprite
      - Enables non-uniform scaling of sprites
      - scale property still works for uniform scaling
      - Both properties work with the animation system

    All existing code using sprite_number continues to work due to backward compatibility.

commit 5a003a9aa5
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Jul 5 16:09:52 2025 -0400

    Fix multiple low priority issues

    closes #12, closes #80, closes #95, closes #96, closes #99

    - Issue #12: Set tp_new to NULL for GridPoint and GridPointState to prevent instantiation from Python
    - Issue #80: Renamed Caption.size to Caption.font_size for semantic clarity
    - Issue #95: Fixed UICollection repr to show actual derived types instead of generic UIDrawable
    - Issue #96: Added extend() method to UICollection for API consistency with UIEntityCollection
    - Issue #99: Exposed read-only properties for Texture (sprite_width, sprite_height, sheet_width, sheet_height, sprite_count, source) and Font (family, source)

    All issues have corresponding tests that verify the fixes work correctly.

commit e5affaf317
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Jul 5 15:50:09 2025 -0400

    Fix critical issues: script loading, entity types, and color properties

    - Issue #37: Fix Windows scripts subdirectory not checked
      - Updated executeScript() to use executable_path() from platform.h
      - Scripts now load correctly when working directory differs from executable

    - Issue #76: Fix UIEntityCollection returns wrong type
      - Updated UIEntityCollectionIter::next() to check for stored Python object
      - Derived Entity classes now preserve their type when retrieved from collections

    - Issue #9: Recreate RenderTexture when resized (already fixed)
      - Confirmed RenderTexture recreation already implemented in set_size() and set_float_member()
      - Uses 1.5x padding and 4096 max size limit

    - Issue #79: Fix Color r, g, b, a properties return None
      - Implemented get_member() and set_member() in PyColor.cpp
      - Color component properties now work correctly with proper validation

    - Additional fix: Grid.at() method signature
      - Changed from METH_O to METH_VARARGS to accept two arguments

    All fixes include comprehensive tests to verify functionality.

    closes #37, closes #76, closes #9, closes #79
2025-07-05 17:30:49 -04:00
assets Whoops, never commited the UI icons spritesheet 2025-03-08 20:33:55 -05:00
deps/platform Windows build 2024-02-25 15:38:38 -05:00
modules Refactor: Python 3.12, build libtcod & SFML from source. Cmake build. Directory cleanup 2024-02-24 22:48:39 -05:00
src Squashed commit of the following: [alpha_streamline_1] 2025-07-05 17:30:49 -04:00
tests Squashed commit of the following: [alpha_streamline_1] 2025-07-05 17:30:49 -04:00
.gitignore Squashed commit of the following: [alpha_streamline_1] 2025-07-05 17:30:49 -04:00
.gitmodules Refactor: Python 3.12, build libtcod & SFML from source. Cmake build. Directory cleanup 2024-02-24 22:48:39 -05:00
CMakeLists.txt Iterators, other Python C API improvements 2025-05-31 09:11:51 -04:00
GNUmakefile Squashed commit of the following: [interpreter_mode] 2025-07-05 17:23:09 -04:00
LICENSE.md Refactor: Python 3.12, build libtcod & SFML from source. Cmake build. Directory cleanup 2024-02-24 22:48:39 -05:00
README.md Squashed commit of the following: [interpreter_mode] 2025-07-05 17:23:09 -04:00
compile_commands.json Squashed commit of the following: [interpreter_mode] 2025-07-05 17:23:09 -04:00
css_colors.txt Squashed commit of the following: [standardize_color_handling] 2024-03-30 21:20:40 -04:00
generate_color_table.py Squashed commit of the following: [standardize_color_handling] 2024-03-30 21:20:40 -04:00
wikicrayons_colors.txt Squashed commit of the following: [standardize_color_handling] 2024-03-30 21:20:40 -04:00
xkcd_colors.txt Squashed commit of the following: [standardize_color_handling] 2024-03-30 21:20:40 -04:00

README.md

McRogueFace

Blame my wife for the name

A Python-powered 2D game engine for creating roguelike games, built with C++ and SFML.

Pre-Alpha Release Demo: my 7DRL 2025 entry "Crypt of Sokoban" - a prototype with buttons, boulders, enemies, and items.

Tenets

  • Python & C++ Hand-in-Hand: Create your game without ever recompiling. Your Python commands create C++ objects, and animations can occur without calling Python at all.
  • Simple Yet Flexible UI System: Sprites, Grids, Frames, and Captions with full animation support
  • Entity-Component Architecture: Implement your game objects with Python integration
  • Built-in Roguelike Support: Dungeon generation, pathfinding, and field-of-view via libtcod (demos still under construction)
  • Automation API: PyAutoGUI-inspired event generation framework. All McRogueFace interactions can be performed headlessly via script: for software testing or AI integration
  • Interactive Development: Python REPL integration for live game debugging. Use mcrogueface like a Python interpreter

Quick Start

# Clone and build
git clone <wherever you found this repo>
cd McRogueFace
make

# Run the example game
cd build
./mcrogueface

Example: Creating a Simple Scene

import mcrfpy

# Create a new scene
mcrfpy.createScene("intro")

# Add a text caption
caption = mcrfpy.Caption((50, 50), "Welcome to McRogueFace!")
caption.size = 48 
caption.fill_color = (255, 255, 255)

# Add to scene
mcrfpy.sceneUI("intro").append(caption)

# Switch to the scene
mcrfpy.setScene("intro")

Documentation

For comprehensive documentation, tutorials, and API reference, visit: https://mcrogueface.github.io

Requirements

  • C++17 compiler (GCC 7+ or Clang 5+)
  • CMake 3.14+
  • Python 3.12+
  • SFML 2.5+
  • Linux or Windows (macOS untested)

Project Structure

McRogueFace/
├── src/           # C++ engine source
├── scripts/       # Python game scripts
├── assets/        # Sprites, fonts, audio
├── build/         # Build output directory
└── tests/         # Automated test suite

Contributing

PRs will be considered! Please include explicit mention that your contribution is your own work and released under the MIT license in the pull request.

The project has a private roadmap and issue list. Reach out via email or social media if you have bugs or feature requests.

License

This project is licensed under the MIT License - see LICENSE file for details.

Acknowledgments

  • Developed for 7-Day Roguelike 2023, 2024, 2025 - here's to many more
  • Built with SFML, libtcod, and Python
  • Inspired by David Churchill's COMP4300 game engine lectures