Skip to content

Instantly share code, notes, and snippets.

View jotson's full-sized avatar

John Watson jotson

View GitHub Profile
@jotson
jotson / wall.shader
Created April 15, 2022 15:20
Gravity Ace wall texture shader
shader_type canvas_item;
uniform vec2 camera_pos;
uniform vec2 camera_zoom;
uniform vec2 viewport_size;
uniform vec2 viewport_size_override;
uniform sampler2D normal_tex : hint_normal;
uniform sampler2D noise_tex;
@jotson
jotson / FixedJoint.gd
Created April 18, 2021 17:22
A script for creating fixed joints from a PinJoint2D in Godot Engine
extends PinJoint2D
var rotation_fix = 0
# Connect both bodies to the joint, save the relative rotation, and
# connect signals to disconnect the joint if either body is deleted
func connect_bodies(body1 : PhysicsBody2D, body2 : PhysicsBody2D):
node_a = body1.get_path()
node_b = body2.get_path()
@jotson
jotson / shake.gd
Created April 10, 2021 18:47
Very simple camera shake
var cameraShakeIntensity = 0.0
var cameraShakeDuration = 0.0
func shake(intensity, duration):
if intensity > cameraShakeIntensity and duration > cameraShakeDuration:
cameraShakeIntensity = intensity
cameraShakeDuration = duration
func _physics_process(delta):
# Camera shake
@jotson
jotson / screenshot.gd
Last active March 15, 2024 14:40
Godot GDScript screenshot function
# This is a function for capturing screenshots with GDScript
func screenshot():
# Capture the screenshot
var size = OS.window_size
var image = get_viewport().get_texture().get_data()
# Setup path and screenshot filename
var date = OS.get_datetime()
var path = "user://screenshots"
var file_name = "screenshot-%d-%02d-%02dT%02d:%02d:%02d" % [date.year, date.month, date.day, date.hour, date.minute, date.second]
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://mask/transparent.png" type="Texture" id=1]
[resource]
albedo_texture = ExtResource( 1 )
metallic = 0.42
metallic_specular = 0.76
roughness = 0.3
emission_enabled = true
#!/usr/bin/python3
import version
import subprocess
import os
GODOT = '/home/john/apps/godot/godot3'
BUILDDIR = '/home/john/code/games/gravity/build'
PROJECT = '/home/john/code/games/gravity/game'
OPTIONS = ['--no-window', '--resolution', '640x360'] # --no-window doesn't work on linux
import subprocess
import configparser
import os
VERSION_FILE = '/home/john/code/games/gravity/game/version.cfg'
GITDIR = '/home/john/code/games/gravity/game'
'''
Fix for fatal: not a git repository: '.git'
Removed all os.chdir() statements
import json
import requests
BUILDDIR = '/home/john/code/games/gravity/build'
CHANGELOG = '/home/john/code/games/gravity/changelog.md'
def get_changelog():
f = open(CHANGELOG, 'r')
n = 0
log = ''
#!/usr/bin/python3
import subprocess
import discord
import version
BUILDDIR = '/home/john/code/games/gravity/build'
STEAM_COMMAND = '/home/john/code/games/gravity/build/sdk/tools/ContentBuilder/builder_linux/steamcmd.sh'
STEAM_APP_CONFIG = '/home/john/code/games/gravity/build/sdk/tools/ContentBuilder/scripts/app_build_1003860.vdf'
@jotson
jotson / redblue.shader
Created December 21, 2019 17:04
Chromatic aberration shader used in gravityace.com
shader_type canvas_item;
uniform float scale = 0.0;
uniform float max_scale = 10.0;
uniform float intensity = 2.0;
void fragment() {
vec2 offset = SCREEN_PIXEL_SIZE * scale;
offset.y = 0.0;