Skip to content

Instantly share code, notes, and snippets.

View achernoprudov's full-sized avatar
🏠
Working from home

Andrei Chernoprudov achernoprudov

🏠
Working from home
View GitHub Profile
extension DispatchQueue {
static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) {
DispatchQueue.main.async {
background?()
if let completion = completion {
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
completion()
})
}
}
func shake() {
let shake = CABasicAnimation(keyPath: "position")
shake.duration = 0.05
shake.repeatCount = 2
shake.autoreverses = true
let fromPoint = CGPoint(x: center.x - 5, y: center.y)
let fromValue = NSValue(cgPoint: fromPoint)
let toPoint = CGPoint(x: center.x + 5, y: center.y)
let toValue = NSValue(cgPoint: toPoint)
shake.fromValue = fromValue
@kasthor
kasthor / Main.gd
Last active January 3, 2024 18:23
Minimum code to draw an image to screen in Godot
extends Node2D
var image
var should_update_canvas = false
var drawing = false
# Called when the node enters the scene tree for the first time.
func _ready():
create_image()
update_texture()