Skip to content

Instantly share code, notes, and snippets.

View Sephi-Chan's full-sized avatar

Romain Tribes Sephi-Chan

  • Nîmes, France
View GitHub Profile
<?php
require __DIR__ . '/vendor/autoload.php';
use \Firebase\JWT\JWT;
$salt = "crevettes au Nutella"; // Le même clé secrète que celle transmise à JeuWeb Push.
// La payload:
// - DOIT contenir une clé "user" qui identifie votre joueur et sera utilisée par votre système (généralement un ID).
// - PEUT contenir une clé "allowed_channels", un tableau contenant les noms des canaux privés autorisés.
$payload = [
"user" => 42,
import random
PIERRE = 0
FEUILLE = 1
CISEAUX = 2
def shifumi(action_ordi, action_joueur):
if action_ordi == PIERRE and action_joueur == CISEAUX: return True
elif action_ordi == FEUILLE and action_joueur == PIERRE: return True
const image = $('img#my-image');
const images = $$('img');
const imagesColliding = imagesCollidingWithImage(image, images);
function imagesCollidingWithImage(image, images) {
const rectangle = image.getBoundingClientRect();
images.filter(function(otherImage){
if (image == otherImage) return false; // Ignore self.
const otherRectangle = image.getBoundingClientRect();
# {:ok, pid} = Rts.RoomEngine.start_link([%{id: "Corwin", location: {0, 200}}])
# Rts.RoomEngine.move_to(pid, "Corwin", {200, 0})
# Rts.RoomEngine.stop(pid)
defmodule Rts.RoomEngine do
use GenServer
@speed 200/1000 # per seconds.
@step_duration round(1000/5) # milliseconds
def start_link(units) do
@Sephi-Chan
Sephi-Chan / test.ex
Created February 19, 2020 19:01
Diggers simple game test
test "Start the exploration phase when all players disabled three tiles on each board" do
:ok = Diggers.Application.dispatch(%Diggers.PlayerOpensLobby{game_id: "game_1", player_id: "Corwin"})
:ok = Diggers.Application.dispatch(%Diggers.PlayerJoinsLobby{game_id: "game_1", player_id: "Mandor"})
:ok = Diggers.Application.dispatch(%Diggers.PlayerStartsGame{game_id: "game_1", player_id: "Corwin"})
# Corwin has board 0, Mandor has board 1.
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "1_3"})
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "0_1"})
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "3_4"})
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "1_0"})
@Sephi-Chan
Sephi-Chan / WAT.md
Last active November 1, 2019 16:32

Test 1

test "foo" do
  :ok = Seelies.Router.dispatch(%Seelies.StartGame{game_id: "42", board: Seelies.Test.board(), teams: Seelies.Test.teams()})
end
➜  seelies git:(master) ✗ mix test test/seelies_test.exs:5
math.randomseed(os.time())
local score = 0
local game_over = false
local ecran = {}
ecran.largeur = 800
ecran.hauteur = 600
local panier = {}
defmodule Tanks.Games do
use GenServer
def start_link([]) do
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
end
def create(map, player_1, player_2) do
--
-- json.lua
--
-- Copyright (c) 2018 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-- of the Software, and to permit persons to whom the Software is furnished to do
local sprite = app.activeSprite;
local data_layer = get_layer(sprite, "Data")
local cel = data_layer.cels[1]
local image = cel.image
local red_pixel = app.pixelColor.rgba(255, 0, 0)
local origin = nil
print("sprite.width " .. sprite.width)
print("sprite.height " .. sprite.height)
print("image.width " .. image.width)