From 37378566f24d40abd6883758478586aaece3e416 Mon Sep 17 00:00:00 2001 From: chukobyte Date: Wed, 12 May 2021 12:36:14 -0400 Subject: [PATCH] First iteration of full documenation. --- README.md | 2 +- docs/index.md | 12 +- docs/python_api/audio.md | 58 ++++++++ docs/python_api/camera.md | 46 +++++++ docs/python_api/color.md | 43 ++++++ docs/python_api/engine.md | 27 ++++ docs/python_api/index.md | 13 +- docs/python_api/input.md | 153 +++++++++++++++++++++ docs/python_api/math.md | 111 +++++++++++++++ docs/python_api/network.md | 135 +++++++++++++++++++ docs/python_api/node.md | 270 +++++++++++++++++++++++++++++++++++++ docs/python_api/physics.md | 27 ++++ docs/python_api/scene.md | 33 +++++ mkdocs.yml | 10 ++ 14 files changed, 937 insertions(+), 3 deletions(-) create mode 100644 docs/python_api/audio.md create mode 100644 docs/python_api/camera.md create mode 100644 docs/python_api/color.md create mode 100644 docs/python_api/engine.md create mode 100644 docs/python_api/input.md create mode 100644 docs/python_api/math.md create mode 100644 docs/python_api/network.md create mode 100644 docs/python_api/node.md create mode 100644 docs/python_api/physics.md create mode 100644 docs/python_api/scene.md diff --git a/README.md b/README.md index f0951a13..5ec22942 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Roll Back Engine -A 2D game engine that's used for a work in progress fighting game. Windows only for now, but may support other platforms in the future. Documentation can be found [here](https://chukobyte.github.io/roll-back-engine/). +A 2D game engine that's used for a work in progress fighting game. Windows only for now, but may support other platforms in the future. Full documentation can be found [here](https://chukobyte.github.io/roll-back-engine/). ### Dependencies & Tools diff --git a/docs/index.md b/docs/index.md index eaedfa96..a325f175 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,13 @@ # Welcome to Roll Back Engine Documentation -Roll Back Engine is made for an upcoming online fighting game. Use the left panel to navigate the documentation. +### About + +[Roll Back Engine](https://github.com/Chukobyte/roll-back-engine) is a 2D game engine made for an upcoming online fighting game. Use the left panel to navigate the documentation. + +### Features + +* Entity Component System +* Scene System +* Python scripting +* Networking system for online multiplayer +* Collision system diff --git a/docs/python_api/audio.md b/docs/python_api/audio.md new file mode 100644 index 00000000..6ccc12da --- /dev/null +++ b/docs/python_api/audio.md @@ -0,0 +1,58 @@ +# roll.audio + +## Audio + +Interface for music and sound effects. Music will continue to loop until stopped and sound is only played once. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +play_music(music_id: str) -> None: +``` + +Plays music. + + +```python +stop_music() -> None: +``` + +Stops currently playing music. + +```python +set_music_volume(volume: int) -> None: +``` + +Sets volume for music. + +```python +play_sound(sound_id: str) -> None: +``` + +Plays a sound. + +```python +set_sounds_volume(volume: int) -> None: +``` + +Sets volume for sounds. + +```python +set_all_volume(volume: int) -> None: +``` + +Sets volume for all audio. + +--- \ No newline at end of file diff --git a/docs/python_api/camera.md b/docs/python_api/camera.md new file mode 100644 index 00000000..cf13d631 --- /dev/null +++ b/docs/python_api/camera.md @@ -0,0 +1,46 @@ +# roll.camera + +## Camera + +Engine representation of a camera. + + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +set_zoom(zoom: rool.math.Vector2) -> None: +``` + +Sets the camera's zoom. + +```python +get_zoom() -> rool.math.Vector2: +``` + +Gets the camera's zoom. + +```python +set_viewport_position(zoom: rool.math.Vector2) -> None: +``` + +Sets the camera's viewport position. + +```python +get_viewport_position() -> rool.math.Vector2: +``` + +Gets the camera's viewport position. + +--- diff --git a/docs/python_api/color.md b/docs/python_api/color.md new file mode 100644 index 00000000..6d1dd4e2 --- /dev/null +++ b/docs/python_api/color.md @@ -0,0 +1,43 @@ +# roll.color + +## Color + +Engine representation of color. + +### Variables + +``` +r : float +``` +Red color. + +``` +g : float +``` +Green color. + +``` +b : float +``` +Blue color. + +``` +a : float +``` +Alpha or transparency of the color. + +--- + +### Methods + +**Static functions that return specific values** + +``` +WHITE() -> Color(1.0, 1.0, 1.0, 1.0): +BLACK() -> Color(0.0, 0.0, 0.0, 1.0): +RED() -> Color(1.0, 0.0, 0.0, 1.0): +GREEN() -> Color(0.0, 1.0, 0.0, 1.0): +BLUE() -> Color(0.0, 0.0, 1.0, 1.0): +``` + +--- diff --git a/docs/python_api/engine.md b/docs/python_api/engine.md new file mode 100644 index 00000000..bb30c2eb --- /dev/null +++ b/docs/python_api/engine.md @@ -0,0 +1,27 @@ +# roll.engine + +## Engine + +Interface for miscellaneous operations for the game engine. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +exit(code=0) -> None: +``` + +Exits the engine returning the value of `code` as the exit code. + +--- \ No newline at end of file diff --git a/docs/python_api/index.md b/docs/python_api/index.md index c4417bd1..608cf6b3 100644 --- a/docs/python_api/index.md +++ b/docs/python_api/index.md @@ -1,3 +1,14 @@ # Python API -Python API TBD. +Contains information about the Python scripting API used for Roll Back Engine. + +* [Node](node.md) +* [Math](math.md) +* [Color](color.md) +* [Camera](camera.md) +* [Audio](audio.md) +* [Input](input.md) +* [Engine](engine.md) +* [Physics](physics.md) +* [Scene](scene.md) +* [Network](network.md) diff --git a/docs/python_api/input.md b/docs/python_api/input.md new file mode 100644 index 00000000..1b4805f9 --- /dev/null +++ b/docs/python_api/input.md @@ -0,0 +1,153 @@ +# roll.input + +## Input + +Class for handling input. + +### Variables + +Mouse Action Values + +``` +Mouse.LEFT_BUTTON = "mb_left" # Left Mouse Button +Mouse.RIGHT_BUTTON = "mb_right" # Right Mouse Button +``` + +Keyboard Action Values + +``` +Keyboard.NUM_0 = 0 # Zero +Keyboard.NUM_1 = 1 # One +Keyboard.NUM_2 = 2 # Two +Keyboard.NUM_3 = 3 # Three +Keyboard.NUM_4 = 4 # Four +Keyboard.NUM_5 = 5 # Five +Keyboard.NUM_6 = 6 # Six +Keyboard.NUM_7 = 7 # Seven +Keyboard.NUM_8 = 8 # Eight +Keyboard.NUM_9 = 9 # Nine + +Keyboard.A = "a" +Keyboard.B = "b" +Keyboard.C = "c" +Keyboard.D = "d" +Keyboard.E = "e" +Keyboard.F = "f" +Keyboard.G = "g" +Keyboard.H = "h" +Keyboard.I = "i" +Keyboard.J = "j" +Keyboard.K = "k" +Keyboard.L = "l" +Keyboard.M = "m" +Keyboard.N = "n" +Keyboard.O = "o" +Keyboard.P = "p" +Keyboard.Q = "q" +Keyboard.R = "r" +Keyboard.S = "s" +Keyboard.T = "t" +Keyboard.U = "u" +Keyboard.V = "v" +Keyboard.W = "w" +Keyboard.X = "x" +Keyboard.Y = "y" +Keyboard.Z = "z" + +Keyboard.UP = "up" # Up Arrow Key +Keyboard.DOWN = "down" # Down Arrow Key +Keyboard.LEFT = "left" # Left Arrow Key +Keyboard.RIGHT = "right" # Right Arrow Key +Keyboard.SPACE = "space" # Space Key +Keyboard.ESC = "esc" # ESC Key +Keyboard.RETURN = "return" # Enter Key + +Keyboard.F1 = "f1" +Keyboard.F2 = "f2" +Keyboard.F3 = "f3" +Keyboard.F4 = "f4" +Keyboard.F5 = "f5" +Keyboard.F6 = "f6" +Keyboard.F7 = "f7" +Keyboard.F8 = "f8" +Keyboard.F9 = "f9" +Keyboard.F10 = "f10" +Keyboard.F11 = "f11" +Keyboard.F12 = "f12" +``` + +Joystick Action Values + +``` +Joystick.A_BUTTON = "joystick_button_a" # XBOX A +Joystick.B_BUTTON = "joystick_button_b" # XBOX B +Joystick.X_BUTTON = "joystick_button_x" # XBOX X +Joystick.Y_BUTTON = "joystick_button_y" # XBOX Y + +Joystick.KEYPAD_UP = "joystick_keypad_up" +Joystick.KEYPAD_DOWN = "joystick_keypad_down" +Joystick.KEYPAD_LEFT = "joystick_keypad_left" +Joystick.KEYPAD_RIGHT = "joystick_keypad_right" + +Joystick.LEFT_ANALOG = "joystick_left_analog" +Joystick.LEFT_ANALOG_LEFT = "joystick_left_analog_left" +Joystick.LEFT_ANALOG_RIGHT = "joystick_left_analog_right" +Joystick.LEFT_ANALOG_UP = "joystick_left_analog_up" +Joystick.LEFT_ANALOG_DOWN = "joystick_left_analog_down" +Joystick.RIGHT_ANALOG = "joystick_right_analog" +Joystick.RIGHT_ANALOG_LEFT = "joystick_right_analog_left" +Joystick.RIGHT_ANALOG_RIGHT = "joystick_right_analog_right" +Joystick.RIGHT_ANALOG_UP = "joystick_right_analog_up" +Joystick.RIGHT_ANALOG_DOWN = "joystick_right_analog_down" + +Joystick.START_BUTTON = "joystick_start_button" +Joystick.BACK_BUTTON = "joystick_back_button" + +Joystick.SHOULDER_LEFT = "joystick_left_shoulder" +Joystick.SHOULDER_RIGHT = "joystick_right_shoulder" +Joystick.TRIGGER_LEFT = "joystick_left_trigger" +Joystick.TRIGGER_RIGHT = "joystick_right_trigger" +``` + +--- + +### Signals + +None. + +--- + +### Methods + +```python +add_action(action_name: str, value: str) -> None: +``` + +Adds an input action. Multiple input values can be added to the same `action_name`. See `Variables` for possible values. + +```python +remove_action(action_name: str) -> None: +``` + +Completely removes action. + + +```python +is_action_pressed(action_name: str) -> bool: +``` + +Returns true if an action input is currently being held down. + +```python +is_action_just_pressed(action_name: str) -> bool: +``` + +Returns true if an action input was just pressed. + +```python +is_action_just_released(action_name: str) -> bool: +``` + +Returns true if an action input was just released. + +--- diff --git a/docs/python_api/math.md b/docs/python_api/math.md new file mode 100644 index 00000000..9f8556ca --- /dev/null +++ b/docs/python_api/math.md @@ -0,0 +1,111 @@ +# roll.math + +## Vector2 + +Engine representation of a two-dimensional vector. + +### Variables + +```python +x : float +``` +X coordinate. + +```python +y : float +``` +Y coordinate. + +--- + +### Methods + +```python +dot_product(value: seika.math.Vector2) -> float: +``` + +Returns the dot product of two Vector2 items. + +--- + +**Static functions that return specific values** + +```python +ZERO() -> Vector2(0.0, 0.0): +LEFT() -> Vector2(-1.0, 0.0): +RIGHT() -> Vector2(0.0, 1.0): +UP() -> Vector2(0.0, -1.0): +DOWN() -> Vector2(0.0, 1.0): +``` + +--- + +## Vector3 + +Engine representation of a two dimensional vector. + +### Variables + +```python +x : float +``` + +X coordinate. + +```python +y : float +``` + +Y coordinate. + +```python +z : float +``` + +Z coordinate. + +--- + +### Methods + +None. + +--- + +## Rect2 + +Engine representation of a rectangle vector. + +### Variables + +```python +x : float +``` + +X coordinate. + +```python +y : float +``` + +Y coordinate. + +```python +w : float +``` + +Rectangle's width. + +```python +h : float +``` + +Rectangle's height. + +--- + +### Methods + +None. + +--- diff --git a/docs/python_api/network.md b/docs/python_api/network.md new file mode 100644 index 00000000..db1cbfff --- /dev/null +++ b/docs/python_api/network.md @@ -0,0 +1,135 @@ +# roll.network + +## Network + +Interface for network related operations for multiplayer. + +### Variables + +None. + +--- + +### Signals + +**[Server](#server) and [Client](#client) signals.** + +```python +peer_connected +``` + +Emitted once a peer is connected to the [Server](#server). + +```python +peer_disconnected +``` + +Emitted once a peer is disconnected from the [Server](#server). + +```python +message_received +``` + +Emitted once a message is received from the network. + +**[Client](#client) only signals.** + +```python +connected_to_server +``` + +Emitted once a client successfully connects to a [Server](#server). + +```python +connection_to_server_failed +``` + +Emitted once a client fails to connect to a [Server](#server). + +--- + +### Methods + +```python +connect_signal(signal_id: str, listener_node: roll.node.Node, function_name: str) -> None: +``` + +Connects to network related signal. + +--- + +## Server + +Interface for server related operations for multiplayer. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +start(port: int) -> None: +``` + +Starts server on designated `port`. + +```python +stop() -> None: +``` + +Stops previously started server. + +```python +send_message_to_all_clients(message: str) -> None: +``` + +Sends message to all connected clients. + +--- + +## Client + +Interface for client related operations for multiplayer. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +connect(endpoint: str, port: int) -> None: +``` + +Connects to a server with the passed in `endpoint` and `port`. + +```python +disconnect() -> None: +``` + +Disconnects from a server. + +```python +send_message_to_server(message:str) -> None: +``` + +Sends message to the server. + +--- diff --git a/docs/python_api/node.md b/docs/python_api/node.md new file mode 100644 index 00000000..36be1493 --- /dev/null +++ b/docs/python_api/node.md @@ -0,0 +1,270 @@ +# roll.node + +## Node + +**Inherits**: N/A. + +Class used as an interface for scene node functionality. Base class for all scene node types. + +### Variables + +```python +name : str +``` + +Unique name of node once added to the scene. + +```python +entity_id : int +``` + +Unique id of entity. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +new() -> seika.nodes.Node: +``` + +Used to create a new node and maps an engine entity to the script's node instance. If the intent is for a node to eventually be deleted, it should be done either with `queue_free()`, once the node's parent is deleted, or once the scene that the node is currently in is changed/deleted. + +```python +queue_deletion() -> None: +``` + +Queues a node to be deleted and removed from a scene if it's currently added to the scene tree. + +```python +add_child(node: Node) -> None: +``` + +Adds a node as a child to the current node. + +```python +create_signal(signal_id: str) -> None: +``` + +Creates a signal for subscribers to listen to. + +```python +connect_signal(signal_id: str, listener_node: seika.nodes.Node, function_name: str) -> None: +``` + +Connects source node's signal to listener node. + +```python +emit_signal(signal_id: str, args=[]) -> None: +``` + +Emits signal from source node. + +```python +_start() -> None: +``` + +Called when entity is loaded into scene tree with all dependencies and children. + +```python +_physics_process(delta_time: float) -> None: +``` + +Called every frame. `delta_time` is passed in to have a frame consistent with CPU speed. + +```python +_end() -> None: +``` + +Called before entity exits scene tree. + +--- + +## Node2D + +**Inherits**: [Node](#node) + +Class used as an interface for scene 2D functionality. Base class for all 2D scene node types. + +### Variables + +```python +position : roll.math.Vector2 +``` + +Current position of entity. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +get_position() -> seika.math.Vector2: +``` + +Get node's current position. + +```python +set_position(value: seika.math.Vector2) -> None: +``` + +Set node's current position. + +```python +add_to_position(value: seika.math.Vector2) -> None: +``` + +Add to node's current position. For example, if this line of code is within the `_process` function, the output of this line of code `node.add_to_position(Vector(5, 10))` within 3 frames will be `[(5, 10), (10, 20), (15, 30)]`. + +--- + +## Sprite + +**Inherits**: [Node2D](#node2d) -> [Node](#node) + +### Variables + +```python +flip_h: bool +``` + +Detemines whether the x axis is flipped. + +```python +flip_v: bool +``` + +Detemines whether the y axis is flipped. + +--- + +### Signals + +None. + +--- + + +### Methods + +None. + +--- + +## AnimatedSprite + +**Inherits**: [Node2D](#node2d) -> [Node](#node) + +### Variables + +```python +animation: seika.assets.Animation +``` + +Current node's animation. + +```python +current_index: int +``` + +Current node's animation index. + +```python +is_playing: bool +``` + +Returns `True` if an animation is currently playing. + +```python +flip_h: bool +``` + +Detemines whether the x axis is flipped. + +```python +flip_v: bool +``` + +Detemines whether the y axis is flipped. + +--- + +### Signals + +```python +animation_finished +``` + +Emitted when an animations is finished. + +```python +frame_changed +``` + +Emitted when an animation frame changes. + +--- + +### Methods + +```python +play(animation_name: str, start_frame = 0) -> None: +``` + +Plays animation based on the name passed in. + +```python +stop() -> None: +``` + +Stops currently playing animation. + +--- + +## TextLabel + +**Inherits**: [Node2D](#node2d) -> [Node](#node) + +### Variables + +```python +text: str +``` + +Node's label text. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +get_text() -> str: +``` + +Get node's label text. + +```python +set_text(value: str) -> None: +``` + +Set node's label text. + +--- diff --git a/docs/python_api/physics.md b/docs/python_api/physics.md new file mode 100644 index 00000000..4dd54111 --- /dev/null +++ b/docs/python_api/physics.md @@ -0,0 +1,27 @@ +# roll.physics + +## Collision + +Interface for collisions between entities. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +get_collided_nodes(node: roll.node.Node) -> bool: +``` + +Returns a `list` of nodes that collided with the passed in `node`. + +--- \ No newline at end of file diff --git a/docs/python_api/scene.md b/docs/python_api/scene.md new file mode 100644 index 00000000..4f6cba74 --- /dev/null +++ b/docs/python_api/scene.md @@ -0,0 +1,33 @@ +# roll.scene + +## Scene Tree + +Represents the scene tree which handles operations related to the scene system. + +### Variables + +None. + +--- + +### Signals + +None. + +--- + +### Methods + +```python +change_scene(scene_path: str) -> None: +``` + +Change the scene to the current scene defined by `scene_path`. + +```python +get_current_scene_node() -> roll.node.Node: +``` + +Returns the root node of the current scene. + +--- \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index c36f8a16..e0844b83 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -5,5 +5,15 @@ nav: - Home: index.md - Python API: - Index: python_api/index.md + - Node: python_api/node.md + - Camera: python_api/camera.md + - Audio: python_api/audio.md + - Input: python_api/input.md + - Engine: python_api/engine.md + - Scene: python_api/scene.md + - Network: python_api/network.md + - Physics: python_api/physics.md + - Math: python_api/math.md + - Color: python_api/color.md theme: readthedocs