Skip to content

Instantly share code, notes, and snippets.

View NovemberDev's full-sized avatar
🌊
somewhere out there

NovemberDev

🌊
somewhere out there
View GitHub Profile
@NovemberDev
NovemberDev / raycast_godot.gd
Created April 2, 2024 12:35
Raycast from mouse position in 3D space in Godot
func raycast(camera: Camera3D):
var rayOrigin = camera.project_ray_origin(get_viewport().get_mouse_position())
var query = PhysicsRayQueryParameters3D.create(rayOrigin, rayOrigin + camera.project_ray_normal(get_viewport().get_mouse_position()) * 200);
return camera.get_world_3d().direct_space_state.intersect_ray(query)
@NovemberDev
NovemberDev / loop_array_both_directions.cs
Created March 13, 2022 11:30
Infinitely loops an array in both directions while respecting the array bounds
using System;
public class Program
{
public static void Main()
{
var index = 0;
var arr = new int[] { 1, 2, 3, 4 };
for(int i = 0; i < 20; i++) {
@NovemberDev
NovemberDev / vuex_typescript_autoimport.ts
Last active November 25, 2021 22:42
Vuex auto import store modules with typescript
/**
* This script loads and registers store modules automagically from the same folder.
*
* Assuming following setup:
* src/store-modules/index.ts
* src/store-modules/ui-store.ts
*
* Produces:
* store
* store/ui
@NovemberDev
NovemberDev / smooth_look_at.gd
Created October 22, 2021 18:53
Smoothly look_at in 2D for Godot
extends Node2D
# These helper functions smoothly look at any object in 2D space.
# To avoid wrong rotations over +180 degrees, lerp_angle is used.
# Everything happens in global space, so the rotations should be applied properly.
func _process(delta):
$icon.global_rotation = look_at_position($icon, get_global_mouse_position(), 5.0 * delta)
func look_at_position(source: Node2D, target: Vector2, delta: float):
@NovemberDev
NovemberDev / _run_postgres_in_docker.cmd
Created September 14, 2021 20:52
Run a postgres db really quick in a docker container (cmd)
docker network create -d bridge internal-network
docker pull postgres
docker run --network=internal-network --name postgres-db --publish 5432:5432 -e POSTGRES_PASSWORD=root -d postgres
@NovemberDev
NovemberDev / _run_mysql_in_docker.cmd
Last active August 23, 2021 22:58
Run a mysql really quick in a docker container (cmd)
docker network create -d bridge internal-network
docker pull mysql
docker run --network=internal-network -p 3306:3306 --name mysql-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_ROOT_HOST=% -d mysql
@NovemberDev
NovemberDev / TransitionPanel.gd
Last active January 8, 2022 20:47
Reusable TransitionPanel-Script for Godot UI
extends Panel
# Add this script to a panel node
# Panel <-- contains script
# |- Page1
# |--Button <-- calls get_node("../../").transitionTo("Page2")
# |- Page2
# |--Button <-- calls get_node("../../").transitionTo("Page1")
var old_ui : Control
@NovemberDev
NovemberDev / GenericBinaryTree.cs
Last active March 22, 2021 10:31
Generic Binary Tree implementation I built
using System;
using System.Collections.Generic;
// Author: NovemberDev
public class Program
{
///
/// TreeNode baseclass
///
extends KinematicBody2D
const HALT_SPEED = 0.325
const MAX_SPEED = 750.0
const GRAVITY = 1200.0
const MAX_JUMP = 725.0
const MAX_JUMP_TIME = 1.5
const MAX_JUMP_FORGIVENESS_TIME = 0.5
public static bool IsEven(int i) {
return (i & 1) == 0;
}
/*
Returns if the given integer is even using Bitwise & AND operator:
1010 equals 10 in decimal
0001 equals 1 in decimal
0000 AND returns 0 so it is even (0 of 10, 1 of 1)