Skip to content

Instantly share code, notes, and snippets.

View RaheelYawar's full-sized avatar

Raheel Yawar RaheelYawar

View GitHub Profile
@RaheelYawar
RaheelYawar / .gitignore
Last active October 21, 2022 08:02
Godot .gitignore
# Godot-specific ignores
.import/
export.cfg
android/
build/
# Mono-specific ignores
.mono/
# VSCode specific ignores
@RaheelYawar
RaheelYawar / .gitignore
Last active February 10, 2021 19:44
Unity Gitignore
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
@RaheelYawar
RaheelYawar / CoroutineUtility.js
Created August 23, 2020 19:06
Coroutine class for JavaScript games (WIP)
/**
* A utility class to mimic the Phaser Timer class but dependent on an external delta time.
* */
export default class CoroutineUtility {
/**
* @param {Phaser.Game} game
* */
constructor(game) {
this.game = game;
@RaheelYawar
RaheelYawar / FindIndexAndCount.cs
Created August 10, 2020 12:55
Given an array of integers sorted in descending order and in the range 1 through n, write some code to find the index of the first instance of a specific number and the total number of instances that are in the array.
using System;
public class Program
{
public static void Main()
{
var ans = GetIndexAndCount(new int[] {10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3}, 9);
Console.Write(ans[0] + " " + ans[1]);
}
@RaheelYawar
RaheelYawar / GuidedProjectile.cs
Last active March 17, 2024 21:11
Guided Missile - positional update routine for a guided missile that tracks a player
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour
{
[SerializeField] private GameObject target = null;
private const float TURN_RATE = 0.5f;
@RaheelYawar
RaheelYawar / Physics.cpp
Last active January 29, 2023 01:45
Projectile Motion Trajectory Prediction: Use the Newton's Kinematic formula to find the the projectile distance covered and the time taken
struct QueryResult
{
QueryResult(): m_HitPos(0.0f), m_ValidHit(false) {}
Vec3 m_HitPos;
bool m_ValidHit;
};
QueryResult Raycast( const Vec3& p0, const Vec3& p1 );
@RaheelYawar
RaheelYawar / selectiveTint.fragment.glsl
Created October 4, 2018 16:30
Three.js (GLSL) Selective Tint Shader
// THREEjs build-in uniforms and attributes (Fragment)
// uniform mat4 viewMatrix - camera.matrixWorldInverse
// uniform vec3 cameraPosition - camera position in world space
varying vec2 vUv;
varying vec3 vTintColor;
uniform sampler2D albedo;
uniform sampler2D tintMask;
@RaheelYawar
RaheelYawar / memProfiler.go
Created July 31, 2018 16:25
Golang Memory Profiler
var memProfile = flag.String("memprofile", "./profile/mem.prof", "write profile to file")
// Run the memory profiler and write profile to file.
func executeMemoryProfiler() {
flag.Parse()
if *memProfile != "" {
f, err := os.Create(*memProfile)
if err != nil {
log.Fatal("could not create memory profile: ", err)
}
@RaheelYawar
RaheelYawar / bloom.fragment.glsl
Created June 22, 2018 08:36
Three.js (GLSL) basic bloom shader
// THREEjs build-in uniforms and attributes (Fragment)
// uniform mat4 viewMatrix - camera.matrixWorldInverse
// uniform vec3 cameraPosition - camera position in world space
varying vec2 vUv;
uniform sampler2D albedo;
void main() {
@RaheelYawar
RaheelYawar / SwipeControls.cs
Created October 15, 2017 19:49
Swipe Detection in Unity
using UnityEngine;
using System.Collections;
public enum SwipeDirection
{
Null = 0,//no swipe detected
Duck = 1,//swipe down detected
Jump = 2,//swipe up detected
Right = 3,//swipe right detected
Left = 4//swipe left detected