Skip to content

Instantly share code, notes, and snippets.

@OmarShehata
OmarShehata / bitmap.html
Last active Feb 5, 2019
Benchmark for createImageBitmap. Live version: http://omarshehata.me/static/bitmap.html
View bitmap.html
<!DOCTYPE html>
<html>
<head>
<title>createImageBitmap</title>
</head>
<style>
canvas {
width:100%;
height:100%;
}
@OmarShehata
OmarShehata / ArcadeGame.js
Created Jul 31, 2018
CesiumJS Experimental Camera Tacking Class
View ArcadeGame.js
/*global define*/
define([
'./Mine',
'./Boundary',
'./CameraTracking',
'./Coin',
'./postJson',
'./Ring',
'./Sound',
'./Drone',
@OmarShehata
OmarShehata / TypedArrays.html
Last active Oct 6, 2018
Sample test of Javascript Typed Arrays
View TypedArrays.html
<!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 Feb 3, 2018
Answer to the water waves challenge
View Water.vert
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 Jun 5, 2017
Final client code for step 1 of the Tuts+ Multiplayer Pirate Game Tutorial.
View index.html
<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 -->
@OmarShehata
OmarShehata / socket.js
Last active Aug 12, 2022
Socket.io simple cheat sheet
View socket.js
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 / RebindAction.cpp
Created Jun 1, 2017
Rebinding Keys at runtime in Unreal Engine 4.
View RebindAction.cpp
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 / Text.js
Created Feb 10, 2017
Create an in-game text object in the PlayCanvas engine
View Text.js
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 / Pixi.js Smoke Shader
Created May 16, 2016
Example of smoke shader in Pixi.js
View Pixi.js Smoke Shader
<!DOCTYPE html>
<html>
<head>
<title>PixiJS Shaders</title>
<style type="text/css">
body {
margin: 0;
overflow: hidden;
}
</style>
View Phaser Template.html
<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() {