Skip to content

Instantly share code, notes, and snippets.

Avatar
👾
Going deep with game development

Ryosuke whoisryosuke

👾
Going deep with game development
View GitHub Profile
@whoisryosuke
whoisryosuke / transparent-egui-window.rs
Created April 24, 2023 19:48
egui / Bevy - Transparent Window styling
View transparent-egui-window.rs
fn ui_example_system(mut contexts: EguiContexts) {
// Set window styles
let ctx = contexts.ctx_mut();
let old = ctx.style().visuals.clone();
ctx.set_visuals(egui::Visuals {
window_fill: Color32::TRANSPARENT,
panel_fill: Color32::TRANSPARENT,
window_stroke: egui::Stroke {
color: Color32::TRANSPARENT,
width: 0.0,
@whoisryosuke
whoisryosuke / body.css
Created November 12, 2022 09:04
Mastodon Theme - Dark Chakra UI - Based on Mastodon FlatCSS (https://github.com/trwnh/mastomods). Install using Stylus Chrome Extension
View body.css
/*
* OK, now back to business... the rest of this code applies only to the instance.
*/
/*------------------------------------------------------------------------------
* MISC TWEAKS
*
* Miscellaneous tweaks that are more like extensions of the theme,
* rather than subsets or features. These could ostensibly be their
* own user-styles, and are only bundled in here for convenience.
* Or, they are not supported in all browsers. They may be removed
@whoisryosuke
whoisryosuke / tasks.json
Created October 18, 2022 06:08
C++ / CMake / VSCode - Tasks for building and testing (using ModernCppStarter). Swap out `GreeterTests` with your test file's name.
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "CMake: build",
"command": "cmake --build build/standalone",
"group": "build",
"problemMatcher": [],
"detail": "CMake build task"
@whoisryosuke
whoisryosuke / cmake.bash
Last active October 17, 2022 08:07
C++ / CMake / Windows - Setup a new project for Visual Studio with a CMake file (see example here: https://github.com/SaschaWillems/Vulkan/blob/master/CMakeLists.txt or https://github.com/TheLartians/MiniCppStarter/blob/master/CMakeLists.txt)
View cmake.bash
# VS 2019
cmake -G "Visual Studio 16 2019" -A x64
# VS 2022
cmake -G "Visual Studio 17 2022" -A x64
@whoisryosuke
whoisryosuke / export.js
Created September 27, 2022 05:52
NodeJS - Parse MD/MDX files and copy images to another folder (blog migration script) - run using `node export.js`
View export.js
const fs = require('fs')
const path = require('path')
// Loop through all years
// Go into each folder
// Get MDX file
// Add template to frontmatter
// layout: "@/layouts/BlogLayout.astro"
@whoisryosuke
whoisryosuke / tasks.json
Last active August 19, 2022 07:18
Rust / VSCode - Tasks for Cargo Build and Check. CTRL + SHIFT + P, type Run Task, then select cargo run from list. This file goes in .vscode/tasks.json. @see: https://stackoverflow.com/questions/46885292/how-to-launch-a-rust-application-from-visual-studio-code
View tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cargo check",
"type": "shell",
"command": "~/.cargo/bin/cargo", // note: full path to the cargo
"args": [
@whoisryosuke
whoisryosuke / MultipleMaterials.tsx
Created August 1, 2022 21:19
R3F / ThreeJS - Multiple materials on each cube face. ThreeJS does not support stacking materials -- see instanced geometry + groups.
View MultipleMaterials.tsx
import * as THREE from "three";
import { MeshProps, useFrame } from "@react-three/fiber";
import { Mesh } from "three";
import { useRef } from "react";
type MultiMaterialMeshProps = MeshProps & {};
export default function MultiMaterialMesh({}: MultiMaterialMeshProps) {
const geom = useRef<Mesh>();
@whoisryosuke
whoisryosuke / CustomShaderWithUniforms.tsx
Created August 1, 2022 21:18
R3F / ThreeJS / Typescript - Custom shader types that support Uniform
View CustomShaderWithUniforms.tsx
import * as THREE from "three";
import { MeshProps, Object3DNode, useFrame } from "@react-three/fiber";
import { GlassViewMaterial } from "./shaders/GlassViewShader";
import { Mesh } from "three";
import { useRef } from "react";
// We extend Mesh and replace material with ShaderMaterial - which our custom shader is based off
interface GlassViewMesh extends THREE.Mesh {
material: THREE.ShaderMaterial;
}
@whoisryosuke
whoisryosuke / Example.tsx
Last active July 7, 2022 00:34
React - Frame/Game loop using requestAnimationFrame
View Example.tsx
import React, { useEffect, useRef } from "react"
import useLoop from "../hooks/useLoop"
import playerInput from "../utils/playerInput"
type Props = {
}
const Gamepad = ({ }: Props) => {
// The frame/game loop
// We run this 60fps (max) to sync gamepad input to Input class/store