Skip to content

Instantly share code, notes, and snippets.

View nezvers's full-sized avatar

Agnis Aldiņš "NeZvērs" nezvers

View GitHub Profile
@nezvers
nezvers / spring.gd
Created May 21, 2024 22:27
Spring delta time equation [Godot]
## Translated from EgoMoose tutorial of deriving formula for Unity
## https://youtu.be/FZekwtIO0I4
## https://gist.github.com/EgoMoose/777ed827e89b69d479ea407e79261b97
class_name SpringMath
extends Node
## zeta = damping ratio
## omega = angular frequency
static func vec1(value:float, target:float, velocity:float, delta:float, zeta:float = 0.3, omega:float = 20.0)->Array[float]:
@nezvers
nezvers / better_jumping_character_example.gd
Last active July 22, 2021 09:46 — forked from sjvnnings/better_jumping_character_example.gd
An easy to work with jump in Godot
# https://youtu.be/IOe1aGY6hXA
extends KinematicBody2D
export var move_speed = 200.0
var velocity := Vector2.ZERO
export var jump_height : float
export var jump_time_to_peak : float
export var jump_time_to_descent : float
@nezvers
nezvers / RigidBodyFPS_controller.py
Last active September 10, 2020 07:26
Translating DaniTutorial @DaniDevy controller
# original - https://github.com/DaniDevy/FPS_Movement_Rigidbody
extends RigidBody
var x:float
var y:float
var moveSpeed: = 4500
var maxSpeed: = 20.0
var slideCounterMovement: = 0.2
var threshold: = 0.01
onready var body: = $Body #child node used for rotation
@nezvers
nezvers / Platformer obstacle types.txt
Last active January 7, 2023 23:44
Collection of obstacle ideas for platformer games.
Springs - can be used as trap to throw at spike.
Dissapearing block - block that dissapears after landing on it or oscilates over time.
Abyss/ lava - mario abyss or static "floor is lava".
Air fan - constant speed added to the player (horizontal, vertical).
Spikes - visible and trap like.
Saw blades - static and moving.
Falling stuff - falling rocks or thing when player is under it.
Moving floor - factory assembly line floor.
Air current - lifting player up to certain height.
Raising lava - climbing floor of lava.
//Collection of all possible enemies to make easier on designing enemies
//Open for suggestions for entries or categories
walker
critter - just walking
Proximity runner
X proximity - ex: NES Batman 1st stage
Y proximity
guardian - object or position
patrolling
chaser
@nezvers
nezvers / RoundRobinPlayer.gd
Created September 18, 2019 09:43 — forked from noidexe/RoundRobinPlayer.gd
RoundRobinPlayer node for Godot Engine with sequence, random, and shuffle modes extending AudioStreamPlayer
tool
extends AudioStreamPlayer #exactly the same code should work for extending 2D and 3D versions
class_name RoundRobinPlayer
export(int, "sequence", "random", "shuffle") var queue_mode = 0
export(Array, AudioStream) var playlist = [] setget _set_playlist, _get_playlist
export(bool) var round_robin_playing = false setget _set_playing, _is_playing # can't override properties so use this for animations
var playlist_index = -1 # current position in the playlist
var shuffled_indices = [] # Array<int> of shuffled playlist indices