This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class_name Audio | |
| var player: AudioStreamPlayer | |
| var info | |
| func _init(audio_player_instance): | |
| player = audio_player_instance | |
| func load_data(path: String): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node2D | |
| # Has a Line2D child node to plot a curve using each number of the series that tends to 1 | |
| const XSTEP = 10 | |
| var x = 0 | |
| func _ready(): | |
| calc(211) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Control | |
| # Fibonacci number calculation using recursion | |
| # This has some optimization where prior numbers are stored in an array | |
| # Also, the array is expanded in size as needed | |
| func _ready(): | |
| # Calculate the nth number and pass in the array to be referenced | |
| print(fibo(34, [1, 1])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends SceneTree | |
| var t = [] | |
| func _init(): | |
| for j in 5: | |
| var k = [] | |
| var p_time = OS.get_ticks_msec() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var target = get_node("new_parent_node") | |
| var source = get_node("child") | |
| self.remove_child(source) | |
| target.add_child(source) | |
| source.set_owner(target) # I think that this line of code is only needed in Editor scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Switch between saturated and pastel palettes | |
| var s = 0.5 if n > 15 else 1.0 | |
| button.modulate = Color.from_hsv(fmod(n / 15.0, 2.0), s, 1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://www.shadertoy.com/view/4tdSWr | |
| shader_type canvas_item; | |
| uniform float cloudscale = 1.1; | |
| uniform float speed = 0.03; | |
| uniform float clouddark = 0.5; | |
| uniform float cloudlight = 0.3; | |
| uniform float cloudcover = 0.2; | |
| uniform float cloudalpha = 8.0; | |
| uniform float skytint = 0.5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node2D | |
| """ | |
| See: https://www.geeksforgeeks.org/count-total-bits-number/ | |
| Given a positive number n, count total bit in it. | |
| Input : 183 | |
| Output : 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var keys = {} | |
| func _unhandled_input(event): | |
| if event is InputEventKey: | |
| # Add new key to dictionary | |
| if not keys.has(event.scancode): | |
| keys[event.scancode] = false | |
| # Respond to change in key state (pressed or released) | |
| if event.pressed != keys[event.scancode]: | |
| # Remember the current state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node2D | |
| export var nmax = 300 | |
| func _ready(): | |
| # Find prime numbers | |
| sieve_of_eratosthenes(nmax) | |
| func sieve_of_eratosthenes(n: int): |