Coder Social home page Coder Social logo

ladroid / goku Goto Github PK

View Code? Open in Web Editor NEW
32.0 1.0 1.0 39.69 MB

Goku Game Engine - simple, easy to use GUI based game engine

Home Page: https://gokuengine.com/

License: Apache License 2.0

Rust 95.10% Python 4.90%
2d 2d-game 2d-game-engine game game-development game-engine gamedev rust rust-lang gameengine gameengine2d sdl2 multiplatform open-source deep-learning pytorch deeplearning gpu opengl gui

goku's Introduction

Goku Engine

GitHub Workflow Status GitHub Repo stars Documentation Repo Size License

[ English | Deutsch | Español | Français | 日本語 ]

Goku is a 2D game development application for Rust (in the future integration with 3D games). Written purely in Rust.

It’s available for macOS, Windows and Linux.

Based on SDL2 (currently).

Goku is focused, lightweight and has few dependencies (mostly SDL2). It provides:

  • a window and a main loop

  • 2D graphics and text

  • sounds and music

  • keyboard, mouse, and gamepad input

  • GUI interface for development

  • Pixel character generator using AI

third party libraries which used Goku currently:

  • SDL2

  • nalgebra

  • imgui

  • serde

  • rfd

  • glow

  • webbrowser

How to use

IMPORTANT!!!

  • A quick overview is located here -> Goku Engine
  • The documentation is located here -> Gitbook
  • A development blog that covers our progress, plans and shiny new features is located here -> News
  • All examples are located here -> Official Examples

Requirements

Linux

Install these through your favourite package management tool, or via http://www.libsdl.org/

Ubuntu example:

sudo apt-get install libsdl2-dev

Fedora example:

sudo dnf install SDL2-devel

Arch example: (Arch doesn't have separate regular and development packages, everything goes together.)

sudo pacman -S sdl2

You might also need a C compiler (gcc).

Static linking in Linux

You can choose to link SDL2 statically instead of dynamically with the static-link feature. On Linux, you will need to additionally do one of the following:

  • use the bundled feature
  • use the feature use-pkgconfig so that rustc knows where to look for your SDL2 libraries and its dependencies for static linking. This is required because there is no built-in way to find the resources needed to link statically SDL2 from your system
  • install development libraries with [vcpkg][vcpkg]. Instructions to generate a static binary on Linux and other operating systems using vcpkg are [here][cargo-vcpkg-usage]

macOS

Homebrew

On macOS, it's a good idea to install these via [homebrew][homebrew].

brew install sdl2

In recent versions of Homebrew, the installed libraries are usually linked into $(brew --prefix)/lib. If you are running an older version, the symlink for SDL might reside in /usr/local/lib.

To make linking libraries installed by Homebrew easier, do the following for your respective shell.

Add this line to your ~/.zshenv or ~/.bash_profile depending on whether you use ZSH or Bash.

export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"

Windows (MSVC)

  1. Download MSVC development libraries from http://www.libsdl.org/ (SDL2-devel-2.0.x-VC.zip).

  2. Unpack SDL2-devel-2.0.x-VC.zip to a folder of your choosing (You can delete it afterwards).

  3. Copy all lib files from

    SDL2-devel-2.0.x-VC\SDL2-2.0.x\lib\x64\

    to (for Rust 1.6 and above)

    C:\Program Files\Rust\lib\rustlib\x86_64-pc-windows-msvc\lib

    or to (for Rust versions 1.5 and below)

    C:\Program Files\Rust\bin\rustlib\x86_64-pc-windows-msvc\lib

    or to your library folder of choice, and ensure you have a system environment variable of

    LIB = C:\your\rust\library\folder

    For Rustup users, this folder will be in

    C:\Users\{Your Username}\.rustup\toolchains\{current toolchain}\lib\rustlib\{current toolchain}\lib

Where current toolchain is likely stable-x86_64-pc-windows-msvc.

  1. Copy SDL2.dll from

    SDL2-devel-2.0.x-VC\SDL2-2.0.x\lib\x64\

    into your cargo project, right next to your Cargo.toml.

  2. When you're shipping your game make sure to copy SDL2.dll to the same directory that your compiled exe is in, otherwise the game won't launch.

Static linking with MSVC

The MSVC development libraries provided by http://libsdl.org/ don't include a static library. This means that if you want to use the static-link feature with the windows-msvc toolchain, you have to do one of

  • build an SDL2 static library yourself and copy it to your toolchain's lib directory; or
  • also enable the bundled feature, which will build a static library for you; or
  • use a static SDL2 library from vcpkg as described below.

Pixel Character Generator Setup

For the new feature pixel character generator make sure that Python 3 and PyTorch is installed. Currently the AI is written in Python however there is a plan to rewrite it in Rust by using tch-rs.

How to install PyTorch

pip3 install torch torchvision torchaudio

For more information chack out here

How to set up PyO3

PyO3 uses a build script (backed by the pyo3-build-config crate) to determine the Python version and set the correct linker arguments. By default it will attempt to use the following in order:

  • Any active Python virtualenv.
  • The python executable (if it's a Python 3 interpreter).
  • The python3 executable.

You can override the Python interpreter by setting the PYO3_PYTHON environment variable, e.g. PYO3_PYTHON=python3.6, PYO3_PYTHON=/usr/bin/python3.9, or even a PyPy interpreter PYO3_PYTHON=pypy3.

Sometimes PyO3 can give an error with linking Python libs for this case environment variable can be used:

For Windows:

$env:LIB += ";<location_of_python_lib>"

For UNIX:

export LIB=$LIB:/location_of_python_lib

Features

  • Graphics:

    • a window and a main loop

    • 2D graphics and text

      • Button
      • Slider
      • Checkbox
      • TextBox
      • Fonts (only ttf format)
      • Particle system (sparks)
      • Parallax background
    • GUI interface for development

      • built-in Text Editor
      • Debug Console
    • Multiple image file formats: JPG and PNG

    • Lighting:

      • Point Light
      • Spot Light
      • Ambient Light Filter
  • Audio

    • Play
    • Loop
    • Pause
    • Resume
    • Multiple audio file formats: OGG, MP3, FLAC, MOD
  • Input handler:

    • keyboard, mouse, and gamepad input
  • Math types:

    • Vector2 Vector3, Vector4
    • Matrix33, Matrix34, Matrix43, Matrix44
  • Physics:

    • Collisions
    • Rigid body (currently we don't have a Kinematic rigid body)
  • Scene:

    • Flexible JSON file format: Could describe either a whole scene or individual meshes.
  • Animation

  • AI system:

    • Behaviour Tree
  • Timer

  • Dialogue System

  • Profiler

  • Support VSCode

  • Supports several languages:

    • German
    • Spanish
    • Japanese
    • French
  • Support Platform:

    • Windows / Mac / Linux
    • Web (WASM not integrated fully) (addition references Emscripte / SDL-WASM / Web )
    • Android in the future

How to run

  1. git clone https://github.com/ladroid/goku.git
  2. extract everything
  3. command to run: cargo run

Important!!! Currently GUI is still under the development, I'm trying to combine imgui and sdl2 together but need sometime to make it full compatible. Thus, if someone wants to use it is possible to add component Scene and write there a script. If you know how to combine them will be really great!

How to build for Web

  1. Press Tools
  2. Press Build and choose Web

How to enable Viewport

To enable Viewport go to Preferences -> General -> Enable canvas the same is with Grid View mode

TODO (is prioritised)

  • make finally a separate .rs file instead of one big

  • make a viewport instead of current solution with canvas (probably need a separate window inside of app with combination of sdl2 and OpenGL)

  • combine with wgpu (Example from sdl2 lib and imgui renderer for wgpu-rs)

  • improve physics

  • add/improve UI system (make possible to add image for buttons)

  • improve lights and shadows

  • draw simple shapes (cirlce, rectangle, triangle, etc.)

  • tabs

  • profiler improve

  • add/improve particle system

  • improve engine's GUI as well as text editor (probably instead of built-in text editor make an integration with VSCode or other ide)

  • add blueprints (probably imgui node graph https://github.com/benmkw/imnodes-rs)

  • building games for mobiles iOS, Android

  • building games for consoles (PS4-5), Xbox, Nintendo Switch

  • physics material

  • integration with C++ (probably something like a bindgen)

Examples

1. Tetris

Example of building tetris game can be found here

2. Roguelike prototype (Prototype)

Example of building roguelike prototype can be found here

3. Visual effects

  1. Sparks -> use a function spawn_particles_sparks from here
  2. Fire -> use a function spawn_particles_fires from here
  3. Rain -> use a function spawn_particles_rain from here

4. Side scrolling game

Example of building sie scrolling prototype can be found here

5. Platformer

Example of building platformer prototype can be found here

6. Set simple states for enemy(chasing/following)

Example of building platformer prototype can be found here

Japanese ver.

Japenese version can be found here

French ver.

French version can be found here

German ver.

German version can be found here

Spanish ver.

Spanish version can be found here

How to Contribute

Submitting Issues

Use the Issue Tracker to submit bug reports and feature/enhancement requests. Before submitting a new issue, ensure that there is no similar open issue.

Manual Testing

Anyone manually testing the code and reporting bugs or suggestions for enhancements in the Issue Tracker are very welcome!

Submitting Pull Requests

Patches/fixes are accepted in form of pull requests (PRs). Make sure the issue the pull request addresses is open in the Issue Tracker.

Submitted pull request is deemed to have agreed to publish under Apache 2.0 License.

Community

Discord

GitHub Discussion

License

Goku is licensed under Apache license version 2.0. See LICENSE file.

goku's People

Contributors

ladroid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mustafaelms

goku's Issues

Fix Loading Texture Path in GUI

Description:

The current implementation requires explicitly writing a path for loading textures in the GUI. This should be replaced with a more user-friendly component that allows users to choose a file using a window explorer.

Affected Lines of Code:

File: src/gui/gui.rs
Lines: 213-216
Current Code:

// Example of the current implementation (lines 213-216)

let (_, tileset_width, tileset_height) = load_texture_from_path("your_path_to_tilemap.png")?;
// ... rest of the code

Proposed Solution:

Replace the explicit path string with a file chooser component that opens a window explorer to select the texture file. This will improve the usability of the GUI.

Steps to Reproduce:

  1. Open the application.
  2. Navigate to the texture loading section in the GUI.
  3. Notice the requirement to manually enter the texture path.

Expected Behavior:

The GUI should present a button or similar component that opens a file chooser dialog, allowing the user to select the texture file from the file system.

Many examples have hard-coded asset paths

ie: &std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetHouse_1.png") which points to a Windows specific path, and prevents a Linux build from working.

./examples/gui_interface.rs:    let source_path = std::path::PathBuf::from("E:\\Projects\\RustProj\\GameEngine\\goku\\emsdk");
./examples/behaviour_tree_implementation.rs:    player.load_texture("idle", std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\10chars\\character_idle_anim.png"), 16, 18, 150, 0)?;
./examples/behaviour_tree_implementation.rs:    player.load_texture("walk_down", std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\10chars\\character_walk_anim.png"), 16, 18, 150, 0)?;
./examples/behaviour_tree_implementation.rs:    player.load_texture("walk_up", std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\10chars\\character_walk_anim.png"), 16, 17, 150, 1)?;
./examples/behaviour_tree_implementation.rs:    player.load_texture("walk_right", std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\10chars\\character_walk_anim.png"), 16, 17, 150, 2)?;
./examples/behaviour_tree_implementation.rs:    t1.load_texture(&std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetField_1.png"))?;
./examples/behaviour_tree_implementation.rs:    t2.load_texture(&std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetField_2.png"))?;
./examples/behaviour_tree_implementation.rs:    t3.load_texture(&std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetHouse_1.png"))?;
./examples/behaviour_tree_implementation.rs:    let tile_map = two_d::Tile::new(std::path::Path::new("E:\\Projects\\RustProj\\GameEngine\\goku\\test_assets\\map.txt"), vec![
./examples/enemy_behaviour.rs:    t1.load_texture(&Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetField_1.png"))?;
./examples/enemy_behaviour.rs:    t2.load_texture(&Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetField_2.png"))?;
./examples/enemy_behaviour.rs:    t3.load_texture(&Path::new("E:\\Projects\\RustProj\\GameEngine\\NinjaAdventure\\Backgrounds\\Tilesets\\TilesetHouse_1.png"))?;
./examples/simple_parallax_example.rs:    texture_manager_1.load_texture(Path::new("E:\\Projects\\RustProj\\GameEngine\\Tall Forest Files\\Layers\\back.png"))?;
./examples/simple_parallax_example.rs:    texture_manager_2.load_texture(Path::new("E:\\Projects\\RustProj\\GameEngine\\Tall Forest Files\\Layers\\far.png"))?;
./src/gui/gui.rs:    let source_path = std::path::PathBuf::from("E:\\Projects\\RustProj\\GameEngine\\goku\\emsdk");

Update Documentation in GitBook Based on Recent Changes

Description:

The project's documentation in GitBook needs to be updated to reflect the numerous changes listed in the changes.txt file. Ensuring the documentation is current will help users understand and utilize the new features and modifications effectively.

Links:

Changes to Document:

Below are the changes that need to be documented as per the changes.txt file:

Version 0.1.3 [Star Sprint]:

  1. Moved input handler into Preferences and removed unused parts of preferences in GUI
  2. Added Ambient Filter Component in GUI
  3. Added Audio Player in GUI
    • Added file dialogue for track path in Audio Player Component
  4. Modified saving part and logging in GUI
  5. Added build possibility on Windows, Linux, and MacOS in GUI
  6. Enabled color selection in Ambient Filter in GUI
  7. Allowed changing font and font size in Preferences, saved in settings.json in GUI
  8. Added Light component in GUI
  9. Split one big file gui.rs into smaller sub-files
  10. Added deep learning model for generating pixel character and modified GUI to show it
  11. Improved Particle System by adding new shape - circle
  12. Fixed bug with AI model system and added emscripten for generating a web-based game
  13. Added possibility to build for Web using WASM
  14. Added simple raycast
  15. Added icon and made simple platformer
  16. Added Rect class and improved Camera in two_d API, enhanced simple platformer
  17. Added fullscreen mode to Window, modified examples
  18. Modified Rect class, added WASM example, improved simple platformer

Version 0.1.2 [Galactic Gateway]:

  1. Split two_d.rs into smaller sub-files
  2. Created first game with various features (random dungeon, point light, enemies, health bar, etc.)
  3. Fixed bug with AudioPlayer, added example
  4. Updated README file
  5. Separated gui into gui folder
  6. Enabled docking - drag&drop components
  7. Added logging for GUI
  8. Modified translation to other languages in GUI
  9. Modified execute_code and execute_code_web for Linux and Windows in GUI
  10. Improved Texture component in GUI, added animation tags
  11. Added Input Handler in GUI
  12. Improved DisplayComponentTree in GUI
  13. Integrated VSCode in GUI
  14. Added logging for some parts of execution
  15. Fixed function
  16. Modified execute_code, logging updates
  17. Modified launch project and execute_code in GUI

Version 0.1.1 [Quasar Quest]:

  1. Improved Animation class
  2. Enhanced PointLight
  3. Added AmbientLightFilter
  4. Improved examples, added more examples
  5. Added Spot Light
  6. Added rounded/not rounded buttons
  7. Added simple profiler
  8. Integrated GEvent for keyboards
  9. Improved Dialogue System

Steps to Update:

  1. Review the changes.txt file for all listed modifications and enhancements.
  2. Update the relevant sections in the GitBook documentation to reflect these changes.
  3. Ensure that new features are documented with usage examples and any necessary setup instructions.
  4. Verify that all modified examples in the codebase are reflected in the documentation.
  5. Update the changelog or release notes in the documentation accordingly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.