Skip to content

Instantly share code, notes, and snippets.

@danielbierwirth
danielbierwirth / TCPTestClient.cs
Last active August 17, 2024 07:19
TCP Client-Server Connection Example | Unity | C# | Bidirectional communication sample: Client can connect to server; Client can send and receive messages: Server accepts clients; Server reads client messages; Server sends messages to client
// This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;

Generating Procedural Game Worlds with Wave Function Collapse

Wave Function Collapse (WFC) by @exutumno is a new algorithm that can generate procedural patterns from a sample image. It's especially exciting for game designers, letting us draw our ideas instead of hand coding them. We'll take a look at the kinds of output WFC can produce and the meaning of the algorithm's parameters. Then we'll walk through setting up WFC in javascript and the Unity game engine.

sprites

The traditional approach to this sort of output is to hand code algorithms that generate features, and combine them to alter your game map. For example you could sprinkle some trees at random coordinates, draw roads with a brownian motion, and add rooms with a Binary Space Partition. This is powerful but time consuming, and your original vision can someti

@msklywenn
msklywenn / fetch_steam_leaderboard.php
Last active July 19, 2025 19:03
Fetch & cache steam leaderboards to display on your website
<?php
// ref: https://partner.steamgames.com/doc/webapi/ISteamLeaderboards
$cache_filename = "leaderboard_cache";
$default_leaderboard = "Normal";
if (!file_exists($cache_filename) || time() - filemtime($cache_filename) > 3600)
{
$max = 10; // how many displayed scores
$key = ""; // steam webapi key, to get it: https://partner.steamgames.com/doc/webapi_overview/auth#create_publisher_key
$appid = ""; // your game's app id
// the names and corresponding leaderboard IDs
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 17, 2025 10:31
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@FadrikAlexander
FadrikAlexander / ProbabilitiesController.cs
Last active August 17, 2024 14:42
The Ultimate Probability Controller Script for Games in Unity
//Full Youtube Tutorial on this Script: https://youtu.be/84rs2Q0z9ak
//The script doesn't have any kind of Input Validation you should added to the lists before calling the functions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProbabilitiesController : MonoBehaviour
{
#region Basic Probability check
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active March 31, 2025 13:38
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;