Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some presets of scripts as examples #1

Open
williamd1k0 opened this issue Mar 16, 2019 · 6 comments
Open

Add some presets of scripts as examples #1

williamd1k0 opened this issue Mar 16, 2019 · 6 comments

Comments

@williamd1k0
Copy link
Owner

Suggestion made by Triptych

@williamd1k0
Copy link
Owner Author

@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/

@regakakobigman
Copy link

regakakobigman commented Mar 22, 2019

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

@nitodico
Copy link

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

@triptych
Copy link

@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.

@williamd1k0
Copy link
Owner Author

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!

@dirkk0
Copy link

dirkk0 commented Feb 14, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants