Skip to content

Mathorga/rughai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

857 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rughai is an action RPG game built entirely in Python.

Create a new venv and activate it

python3 -m venv .
chmod +x ./bin/activate
source ./bin/activate

Install dependencies

pip3 install -r requirements.txt

Run the game

python3 -O .\src\main.py

Run the scene editor

python3 -O .\src\scene_editor.py

Editor tools

The editor provides various tools, all with the same commands:

  • WASD to move the cursor on the map;
  • IJKL to move the camera around the current cursor position;
  • LSHIFT+WASD to move the cursor faster on the map;
  • ENTER to open the tool's dedicated menu (if present);
  • SPACE to trigger the tool's main mode;
  • RSHIFT+SPACE to trigger the tool's alternate mode (if present).

The currently available tools are:

  • Prop placement tool
  • Idle prop placement tool
  • Wall placement tool
  • Door placement tool (TODO)

Compile to executable (using Nuitka)

In order to compile to executable you first need to install Nuitka:
pip3 install nuitka

Then you can launch the compile command:

  • Windows:
    py -m nuitka .\src\main.py --standalone --include-data-dir=./assets=.

  • Linux and MacOS:
    python3 -m nuitka ./src/main.py --standalone --include-data-dir=./assets=.

You can then find the compiled version of the game inside the main_dist:

  • Windows:
    .\main_dist\main.exe

  • Linux:
    ./main_dist/main

  • MacOS:
    ./main.dist/main.bin

Settings

You can change game settings by manually editing the assets/settings.json file:

Debug

  • debug -> General debug setting, shows some useful features such as update time, render time and collisions.
  • show_collisions -> Specific debug setting, shows collisions, but only if debug is true
  • show_tiles_grid -> Specific debug setting, shows tilemap grid lines.
  • free_cam_bounds -> Specific debug setting, allows the player to see beyond camera bounds.

Texts

  • title -> Game title: defines the title of the game window.
  • font_name -> Game font; if you don't have the font installed, then an error will occur.

Rendering

  • view_width -> Base view width, defines the amount of pixels you can see horizontally
  • view_height -> Base view height, defines the amount of pixels you can see vertically
  • pixel_perfect -> Unused.
  • window_width -> Actual window width in pixels (only used if not fullscreen).
  • window_height -> Actual window height in pixels (only used if not fullscreen).
  • fullscreen -> Fullscreen mode toggle.

Misc

  • target_fps -> Target FPS; keep this value high if you don't want any lags.
  • camera_speed -> The speed at which the camera follows the player, the higher the speed, the closer it will be to the player.
  • layers_z_spacing -> Distance between rendered layers on the Z axis.
  • tilemap_buffer -> Width (in tiles number) of tilemap buffer, a higher tilemap buffer will reduce room size.

Sound

  • sound -> General sound setting, defines whether the game plays audio or not.
  • music -> Specific sound setting, defines whether the game plays music or not.
  • sfx -> Specific sound setting, defines whether the game plays sound effects or not.

Idle props

Simple prop can be added by defining an appropriate json file.
Idle prop files are defined as follows:

  • animation_specs[array]: array of all animation definitions. Every element is structured as follows:
    • path[string]: a path to the animation file (starting from the application-defined assets directory).
    • name[string]: a name used to reference the single animation across the file.
    • center_x[bool][optional]: whether the animation should be centered on its x-axis.
    • center_y[bool][optional]: whether the animation should be centered on its y-axis.
    • anchor_x[int][optional]: the x component of the animation-specific anchor point. This is ignored if "center_x" is true.
    • anchor_y[int][optional]: the y component of the animation-specific anchor point. This is ignored if "center_y" is true.
    • loop[bool][optional]: whether the animation should loop or not. Defaults to true. This is useful when a non looping state should stick for a long time (e.g. destroyed or destroy when no destroy is provided).
  • animations[object]: object defining all animations by category. Categories are "idle", "meet_in", "meeting", "meet_out", "interact", "hit" and "destroy". Every element in each category is defined as follows:
    • name[string]: the name of the animation name, as defined in animation_specs.
    • weight[int]: the selection weight of the specific animation, used during the animation selection algorithm. Probability for a specific animation is calculated as animation_weight / category_weight_sum
  • anchor_x[int][optional]: x component of the global animation anchor point, this is used when no animation-specific anchor point is defined.
  • anchor_y[int][optional]: y component of the global animation anchor point, this is used when no animation-specific anchor point is defined.
  • layer[string][optional]: layer in which to place the prop. Possible options are "dig", "rat" and "pid", which respectively place the prop below, in or above the player movement layer. Defaults to "rat".
  • health_points[int][optional]: amount of damage the prop can take before breaking. If this is not set, then an infinite amount is used, aka the prop cannot be broken.
  • colliders[array][optional]: array of all colliders (responsible for "blocking" collisions). Every element in defined as follows:
    • tags[array]: array of all collision tags the single collider reacts to.
    • offset_x[int]: horizontal displacement, relative to the prop's position.
    • offset_y[int]: vertical displacement, relative to the prop's position.
    • width[int]: collider width
    • height[int]: collider height
    • anchor_x[int]: x component of the collider's anchor point.
    • anchor_y[int]: y component of the collider's anchor point.
  • sensors[array][optional]: array of all sensors (responsible for "non blocking" collisions). Every element in defined as follows:
    • meet_tags[array]: array of all collision tags causing meeting.
    • interact_tags[array]: array of all collision tags causing interaction.
    • hit_tags[array]: array of all collision tags causing hit.
    • offset_x[int]: horizontal displacement, relative to the prop's position.
    • offset_y[int]: vertical displacement, relative to the prop's position.
    • width[int]: sensor width
    • height[int]: sensor height
    • anchor_x[int]: x component of the sensor's anchor point.
    • anchor_y[int]: y component of the sensor's anchor point.

Examples

Animations

All animations can be defined via a simple json definition file.
Animation files are defined as follows:

  • name[string]: name of the animation.
  • path[string]: path to the animation file (starting from the application-defined assets directory).
  • anchor_x[int][optional]: the x component of the animation anchor point.
  • anchor_y[int][optional]: the y component of the animation anchor point.
  • center_x[bool][optional]: whether the animation should be centered on the x axis. If present, this overrides the "anchor_x" parameter.
  • center_y[bool][optional]: whether the animation should be centered on the y axis. If present, this overrides the "anchor_y" parameter.
  • duration[float][optional]: the duration of each animation frame.
  • loop[bool][optional]: whether the animation should loop or not.

Examples

Inventory

The inventory structure (sections, sizes etc) is defined by a json file made up as follows:

  • sections[array]: array of all inventory sections, each defined as follows:
    • size[string]: string representation of the section size (in slots count), encoded as "[width],[height]".
    • name[string]: name of the section, used to section to section linkage.
    • overflows[object]: links to other sections upon overflow: tells which section the cursor should go to when overflowing in each direction. The go to for each overflow can be the name of another section or the "wrap" keyword, which means wrapping around itself keeping the other index unchanged.
      • top[string]: section to go to when overflowing to the top.
      • bottom[string]: section to go to when overflowing to the bottom.
      • left[string]: section to go to when overflowing to the left.
      • right[string]: section to go to when overflowing to the right.

Wallmaps

All walls for a room can be defined via a simple json placement file.
#TODO

Examples

Doormaps

All doors for a room can be defined via a simple json placement file.
#TODO

Examples

About

Adventure RPG game written in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages