goostengine / goost

A general-purpose, extensible and customizable C++ extension for Godot Engine.
https://goostengine.github.io/
MIT License
481 stars 18 forks source link

Add `Debug2D` singleton #162

Closed Xrayez closed 3 years ago

Xrayez commented 3 years ago

See discussion #161, this is meant to resolve godotengine/godot-proposals#112, resolve godotengine/godot-proposals#5196.

Notable features include:

To-do

Example

extends Node2D

func _ready():
    Debug2D.draw_circle(32, Vector2(), Color.orange)
    Debug2D.capture()

    Debug2D.canvas_item = $RigidBody2D
    Debug2D.draw_circle(32, Vector2(), Color.orange)
    Debug2D.capture()

    Debug2D.canvas_item = Debug2D.get_base()
    Debug2D.draw("rect", [Rect2(0, 0, 100, 100), Color.steelblue])
    Debug2D.draw_circle(32, Vector2(), Color.orange)
    Debug2D.capture()

func _input(event):
    if event.is_action_pressed("ui_left"):
        Debug2D.get_capture().draw_prev()
    elif event.is_action_pressed("ui_right"):
        Debug2D.get_capture().draw_next()

    if event.is_action_pressed("ui_cancel"):
        Debug2D.get_capture().reset()

Test project debug_2d.zip

Xrayez commented 3 years ago

Implemented draw_arrow() now.

image

Pushed a snippet in GDScript which I used during prototyping, in case modifications are needed: https://github.com/goostengine/goost-plugins/commit/354d4a07a076fcb371ce6e555abb6f8991bd32d4

Xrayez commented 3 years ago

I'm more or less satisfied with current API. Further enhancements and changes are fine to make further down the road because it only affects debug builds.

Things to do: