Skip to content

Instantly share code, notes, and snippets.

View 8Observer8's full-sized avatar

Ivan 8Observer8

View GitHub Profile
grid = [
[" ", " ", " "],
[" ", " ", " "],
[" ", " ", " "]]
def is_winner(player):
return (
# Rows
grid[0][0] == player and grid[0][1] == player and grid[0][2] == player or
grid[1][0] == player and grid[1][1] == player and grid[1][2] == player or
@8Observer8
8Observer8 / Main.py
Created May 27, 2020 20:18
Port a console app example to PySide2 from the theme: https://stackoverflow.com/questions/10641055
from PySide2 import QtCore
class Console(QtCore.QObject):
def __init__(self, msg):
super(Console, self).__init__()
self.msg = msg
self.timer = QtCore.QBasicTimer()
self.timer.start(500, self)
@8Observer8
8Observer8 / Program.cs
Last active June 14, 2020 10:08
ColoredTriangleVaoOpenTK4OpenGL31 (Added shaders to Program.cs)
using OpenToolkit.Graphics.OpenGL;
using OpenToolkit.Windowing.Desktop;
using OpenToolkit.Mathematics;
using System.IO;
using System;
namespace ColoredTriangleVaoOpenTK4OpenGL31
{
class Program
{
@8Observer8
8Observer8 / SfmlNetAndOpenTK4DotNetCore.cs
Created June 14, 2020 10:32
The example shows how to use OpenGL 3.1 graphics inside SFML.NET window using OpenTK4 and .NET Core
using SFML.Window;
using SFML.Graphics;
using SFML.System;
using OpenToolkit.Graphics.OpenGL;
using OpenToolkit.Windowing.Desktop;
using System.IO;
using System;
namespace SfmlNetAndOpenTK4DotNetCore
{
@8Observer8
8Observer8 / Float32_Base64_Encoding_Decoding.js
Created December 13, 2021 22:19 — forked from sketchpunk/Float32_Base64_Encoding_Decoding.js
Encode Float32Array to base64 , then decode it back
let verts = new Float32Array( [ 0, 2, 0, -1, 0.2, 0, 1, 0.2, 0 ] );
let v = base64_test( verts );
function base64_test( fary ){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ENCODING TEST
console.log("Origin Data", fary );
let uint = new Uint8Array( fary.buffer );
console.log( "Convert F32 to Uint8 : Byte Length Test", fary.length * 4, uint.length );
@8Observer8
8Observer8 / makefile
Created March 13, 2022 19:03
MinGW makefile for SDL2 and Box2D
CC = g++
INC = -I"E:\Libs\SDL2-2.0.12-mingw-32bit\include" -I"E:\Libs\box2d-2.4.0-mingw-32bit\include"
LIB = -L"E:\Libs\SDL2-2.0.12-mingw-32bit\lib" -L"E:\Libs\box2d-2.4.0-mingw-32bit\lib"
FLAGS = -c
all: main.o
$(CC) main.o $(LIB) -lSDL2.dll -lbox2d -o app
main.o: main.cpp
$(CC) $(FLAGS) $(INC) main.cpp
@8Observer8
8Observer8 / sdl2_opengl_skeleton.py
Created September 3, 2022 19:56 — forked from kiwwisk/sdl2_opengl_skeleton.py
Skeleton for SDL2/OpenGL application in Python 3. Game loop has fixed time step, rendering is going at full speed.
#
# Skeleton for SDL2/OpenGL application in Python
# with fixed logic time step, rendering is going still at full speed.
#
# To turn debug logging messages on, run with -v parameter:
# python <script_name.py> -v
#
import argparse
import logging
@8Observer8
8Observer8 / main.cpp
Last active October 9, 2022 14:36
Very Simple Triangle using OpenGL2, Qt6, and C++
// To run on laptops:
#ifdef _WIN32
#include <windows.h>
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
#endif
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QSurfaceFormat>
#include <QtOpenGL/QOpenGLBuffer>
@8Observer8
8Observer8 / AmmoProvider.ts
Created October 12, 2022 14:08 — forked from Sumechoo/AmmoProvider.ts
Class for simplified usage of typed Ammo.js API inside ES6 modules
import Ammo from 'ammojs-typed';
export class AmmoProvider {
private static api: typeof Ammo;
public static async getApi() {
if (!AmmoProvider.api) {
AmmoProvider.api = await Ammo();;
}
@8Observer8
8Observer8 / main.cpp
Last active October 19, 2022 01:34
bouncing-ball-bullet-opengl1-freeglut-cpp
#define FREEGLUT_STATIC
#include <GL/freeglut.h>
#include <GL/glu.h>
#include <iostream>
#include <btBulletDynamicsCommon.h>
GLfloat floorMaterialDiffuse[] = { 0.55f, 0.64f, 0.36f, 1.f };
GLfloat sphereMaterialDiffuse[] = { 0.06f, 0.29f, 0.65f, 1.f };
GLfloat platformMaterialDiffuse[] = { 0.74f, 0.53f, 0.19f, 1.f };
GLfloat light0Diffuse[] = { 1.f, 1.f, 1.0f };