Skip to content

Instantly share code, notes, and snippets.

View OmarShehata's full-sized avatar

Omar Shehata OmarShehata

View GitHub Profile
@OmarShehata
OmarShehata / Pixi.js Smoke Shader
Created May 16, 2016 14:45
Example of smoke shader in Pixi.js
<!DOCTYPE html>
<html>
<head>
<title>PixiJS Shaders</title>
<style type="text/css">
body {
margin: 0;
overflow: hidden;
}
</style>
@OmarShehata
OmarShehata / socket.js
Last active January 8, 2023 10:11
Socket.io simple cheat sheet
io.on('connection', function(socket){
/* 'connection' is a special event fired on the server when any new connection is made */
})
socket.on('disconnect', function(){
/* When this individual socket has disconnected, this special event fires */
})
/* This will send the event 'foobar' with the data to
every connected to socket */
@OmarShehata
OmarShehata / ArcadeGame.js
Created July 31, 2018 18:14
CesiumJS Experimental Camera Tacking Class
/*global define*/
define([
'./Mine',
'./Boundary',
'./CameraTracking',
'./Coin',
'./postJson',
'./Ring',
'./Sound',
'./Drone',
@OmarShehata
OmarShehata / Text.js
Created February 10, 2017 17:33
Create an in-game text object in the PlayCanvas engine
var Text = pc.createScript('text');
Text.attributes.add('text', { type: 'string', default:'Hello World!' });
Text.attributes.add('fontsize', { type: 'number', default:70, title:"Font Size" });
// initialize code called once per entity
Text.prototype.initialize = function() {
// Create a canvas to do the text rendering
this.canvas = document.createElement('canvas');
this.canvas.height = 128;
@OmarShehata
OmarShehata / RebindAction.cpp
Created June 1, 2017 21:42
Rebinding Keys at runtime in Unreal Engine 4.
void RebindAction(FName ActionName, FKey NewKey) {
// Adapted from Rama's VictoryBPFunctionLibrary (https://wiki.unrealengine.com/Rebinding_Keys_At_Runtime_in_Packaged_Game)
UInputSettings* Settings = const_cast<UInputSettings*>(GetDefault<UInputSettings>());
if (Settings) {
TArray<FInputActionKeyMapping>& Actions = Settings->ActionMappings;
for (FInputActionKeyMapping& Each : Actions)
{
if (Each.ActionName == ActionName) {
Each.Key = NewKey;
UE_LOG(LogTemp, Warning, TEXT("%s is triggered by %s"), *Each.ActionName.ToString(), *Each.Key.ToString());
@OmarShehata
OmarShehata / bitmap.html
Last active February 5, 2019 21:21
Benchmark for createImageBitmap. Live version: http://omarshehata.me/static/bitmap.html
<!DOCTYPE html>
<html>
<head>
<title>createImageBitmap</title>
</head>
<style>
canvas {
width:100%;
height:100%;
}
@OmarShehata
OmarShehata / TypedArrays.html
Last active October 6, 2018 16:24
Sample test of Javascript Typed Arrays
<!DOCTYPE html>
<html>
<head>
<title>Javascript Typed Arrays</title>
<meta charset="UTF-8">
<script type="text/javascript" src="https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js"></script>
</head>
<body>
<script type="text/javascript">
// Here's a sample string
@OmarShehata
OmarShehata / Water.vert
Created February 3, 2018 16:44
Answer to the water waves challenge
attribute vec3 aPosition;
uniform mat4 matrix_model;
uniform mat4 matrix_viewProjection;
uniform float uTime;
void main(void)
{
vec3 pos = aPosition;
@OmarShehata
OmarShehata / index.html
Created June 5, 2017 06:40
Final client code for step 1 of the Tuts+ Multiplayer Pirate Game Tutorial.
<html>
<head>
<meta charset="UTF-8" />
<title>Multiplayer Experiment</title>
<!-- Load the Phaser game library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.4.2/phaser.min.js"></script>
<!-- Load the Socket.io networking library -->
<script src="/socket.io/socket.io.js"></script>
<!-- Some simple styles and fonts -->
<html>
<head>
<meta charset="UTF-8" />
<title>hello phaser!</title>
<script src="phaser.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function() {