Skip to content

Instantly share code, notes, and snippets.

View anthonyec's full-sized avatar
🐢
eat the food and live

Anthony Cossins anthonyec

🐢
eat the food and live
View GitHub Profile
@anthonyec
anthonyec / notes.md
Last active January 25, 2024 21:54
Godot C++ notes

I couldn't get icons to working using this:

get_editor_theme_icon(SNAME("Pin"));

It shows as a broken icon, I think I'm missing an #include but I don't know what header file to include. Even where it does work, VSCode shows a red underline under the function name get_editor_theme_icon saying it's undefined.

I did get it working using the editor singleton though:

@anthonyec
anthonyec / bottom_panel_plugin.gd
Last active January 1, 2024 21:37
Example of showing a bottom panel in a Godot plugin
@tool
extends EditorPlugin
const control_scene = preload("res://addons/plugin/plugin.tscn")
var control: Control
func _enter_tree() -> void:
control = control_scene.instantiate()
add_control_to_bottom_panel(control, "Plugin")
@anthonyec
anthonyec / simple_godot_things.gd
Last active January 5, 2024 16:21
Little Godot things to remember that I forget after a few months away
# How to do setters and getters in Godot 4:
var size: int: set = set_size
var forward: Vector3: get = get_forward
var files: Array: get = get_files, set = set_files # I think
# Getting the current active camera.
var main_camera: Camera3D = get_viewport().get_camera_3d()
# Direction based of keyboard input.
var input_direction: Vector2 = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
@anthonyec
anthonyec / stagger.gd
Last active July 10, 2023 22:06
Staggering tweens in Godot 4
for node in nodes:
# Important to create tween for each node instead of using `get_tree().create_tween()`
# because it binds it to each node and also using a single tween for all of them
# has problems when awaiting the interval.
var tween = placeholder.create_tween()
tween.set_parallel(true)
tween.tween_property(node, "position", Vector2(100, 100), 0.3)
await tween.tween_interval(0.05).finished
@anthonyec
anthonyec / README.md
Last active June 25, 2023 22:47
Draw a region and mark positions

Poster markup

A tiny tool to let you draw regions, mark positions inside the regions and export the positions as percentage coordinates.

How to use

Copy and paste all the code from poster_markup.js into the dev console, and press enter.

import path from "path"
import { APIGatewayProxyEvent } from "aws-lambda"
import { streamifyResponse, ResponseStream } from "lambda-stream"
import { S3Client, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3"
import { Upload } from "@aws-sdk/lib-storage"
const {
THIRD_PARTY_ASSETS_BUCKET,
} = process.env
@anthonyec
anthonyec / tooltip.jsx
Created April 17, 2023 10:05
Tooltip in Salad Room
import React, { useRef, useState } from 'react';
import { CSSTransition } from 'react-transition-group';
import TooltipBubble from './tooltip_bubble';
export default function Tooltip({ message, children }) {
const [showTooltip, setShowTooltip] = useState(false);
const childRef = useRef(null);
const child = React.Children.only(children);
@anthonyec
anthonyec / ts-pack-output.txt
Created April 13, 2023 20:21
TS Pack output for Vector2
🩺 Verifying Package.json...
Common JS Package Detected
✓ - Exports Common JS
✓ - Exported Common JS Correct File Extension
○ - Exports ES Module
○ - Exports Types for developers
Exporting types, while optional, aid developers who consume your library.
@anthonyec
anthonyec / composer.css
Last active April 1, 2023 20:14
Composer and text reference component
.composer {
background: white;
border-radius: 30px;
box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 8px 0 rgba(0,0,0,0.21);
display: flex;
align-items: flex-end;
height: 60px;
position: relative;
transition: height 250ms cubic-bezier(0.45, 0, 0.55, 1);
}