gdscript-playground icon indicating copy to clipboard operation
gdscript-playground copied to clipboard

Add some presets of scripts as examples

Open williamd1k0 opened this issue 5 years ago • 6 comments

@triptych Hey! I've refactored the entire UI and added a base for script examples!

image

What do you think?

Btw, I already deployed it for tests: https://gd.tumeo.space/

williamd1k0 avatar Mar 17 '19 06:03 williamd1k0

What would be some desired script presets? @williamd1k0

Some ideas off the top of my head:

  1. A simple FSM using a State class and a function to switch states
  2. Some kind of simple demo showcasing Thread, Mutex, and Semaphore
  3. A simple physics scene made with code. Maybe a KinematicBody2D moves in random directions, collides with obstacles, and prints its position after each move_and_slide()
  4. An example of how to use signals and maybe yield()

I think these could be demonstrated just using print(), although it might be difficult because I don't think you can create packed scenes from code, which means no instancing and no more than 1 script.

 

More general programming problems:

  1. Fizz Buzz
  2. Maybe the first few problems on Project Euler

regakakobigman avatar Mar 22 '19 01:03 regakakobigman

Some ideas for examples

  • arrays: play with arrays functions, add, delete, find, clear, loops
  • dictionaries: same as arrays but with more complex functions
  • htttprequests: send and get data online (specacilly for those interested in online capabilities)
  • vector2: calculations lenght,s angles...
  • vector3: IDEM

nitodico avatar Mar 13 '20 17:03 nitodico

@williamd1k0 Looks great! Glad to see it working! I could see the demos as a way to test out each api almost as a type of unit test style thing. Seeing the syntax in action is really a great way to learn more about GDScript.

triptych avatar Mar 13 '20 20:03 triptych

Sorry for the late reply, I was super busy at my main job. 😣

@regakakobigman Since the current implementation does not support non-blocking code (yet), it's a bit hard to add complex and/or async examples such as yields.

@nitodico @triptych I just added simple examples for arrays and dictionaries. When I get more free time, I will try to add more examples.

Thank you for being interested in this project!

williamd1k0 avatar Mar 14 '20 04:03 williamd1k0

First of all thanks for this project, it should get more attention! Secondly, more or less a note to self: the examples are in https://github.com/williamd1k0/gdscript-playground/blob/master/gdscript/static/js/snippets.js

I would consider it an enhancement if there was a directory with *.gd scripts, which would make it easier to add examples. Again, thank you!

dirkk0 avatar Feb 14 '21 07:02 dirkk0