Skip to content

Instantly share code, notes, and snippets.

View demonixis's full-sized avatar

Yannick Comte demonixis

View GitHub Profile
@demonixis
demonixis / ListQueue.cs
Created August 17, 2012 14:17
An hybrid collection who work like a Queue with the advantages of a List
using System;
using System.Collections.Generic;
namespace Yna.Utils
{
/// <summary>
/// An hybrid collection who work like a Queue with the advantages
/// of a List. It's a List object with 3 extension methods who simulates a Queue
/// </summary>
/// <typeparam name="T"></typeparam>
@demonixis
demonixis / MenuItem.cs
Created August 21, 2012 12:38
Transition on MenuItem with YnTransition
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Yna;
using Yna.Display;
using Yna.Display.Effect;
namespace SpaceGame.States.Menu
{
@demonixis
demonixis / CustomEvents.js
Created October 7, 2012 10:02
Utilisation d'events perso en JavaScript
// Fonction pour déclencher un évènement sur un élément du dom
function triggerEvent(element, eventName)
{
if ((element[eventName] || false) && typeof element[eventName] == 'function')
{
element[eventName](element);
}
}
// Récupération d'un élément du dom
@demonixis
demonixis / boolParameters.js
Created October 23, 2012 09:23
Paramètres booléens par défaut en JavaScript
function foo (params)
{
// Paramètres de la fonctions ils peuvent être vide
var params = params || {};
// Prendra toujours true à cause de l'opération ||
var add = params.add || true;
// Là la variable add prendre la bonne valeur
var add;
@demonixis
demonixis / synchro.js
Created October 25, 2012 13:19
test synchro JS
// Tant que les modèles ne sont pas tous chargés on affiche rien
var waiting = setInterval(function(t)
{
if (player1.loaded && player2.loaded && player3.loaded && player4.loaded)
{
clearInterval(waiting);
setupGame("canvasContainer");
contextPlayer = player1;
document.getElementById("canvasContainer").removeChild(document.getElementById("loadingPage"));
}
@demonixis
demonixis / SharpDX.TookKit.BatchTest.cs
Created October 31, 2012 21:25
SpriteBatch & SpriteFont with SharpDX 2.4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using SharpDX.Toolkit;
using SharpDX.Toolkit.Content;
using SharpDX.Toolkit.Graphics;
@demonixis
demonixis / Level.2DArrayTo1D.cs
Created November 2, 2012 10:18
2D Array to 1D Array
[Serializable]
public class Level
{
public int Id { get; protected set; }
public Point3 Position { get; set; }
public Size3 Sizes { get; set; }
public string WallTexture { get; protected set; }
public string GroundTexture { get; protected set; }
public string TopTexture { get; protected set; }
public int Width { get; protected set; }
@demonixis
demonixis / BoundingBoxRenderer.cs
Created November 2, 2012 18:00
BoundingBoxRenderer for XNA 4.0 Reach profile
public static class BoundingBoxRenderer
{
#region Fields
static VertexPositionColor[] verts = new VertexPositionColor[8];
static short[] indices = new short[]
{
0, 1,
1, 2,
2, 3,
@demonixis
demonixis / notifiy.js
Created November 19, 2012 16:15
A custom event notifier in JavaScript
var events = [];
ujs.notify = function (name, params)
{
if (typeof(events[name]) != "undefined") {
var event = events[name];
if (params instanceof Object) {
for(var i in params) {
@demonixis
demonixis / mouseState.js
Created November 22, 2012 10:03
A simple mouseState written in JavaScript
var mouseState = {
x: 0,
y: 0,
last: { x: 0, y: 0 },
delta: { x: 0, y: 0 },
click: false,
release: true,
drag: false,
updatePositions: function (event) {
this.last.x = this.x;