Skip to content

Instantly share code, notes, and snippets.

View Mulperi's full-sized avatar
🎯
Focusing

Mika Mulperi Lakanen Mulperi

🎯
Focusing
View GitHub Profile
@Mulperi
Mulperi / main.py
Created May 30, 2021 08:22
Flash restful example
from flask import Flask
from flask_restful import reqparse, abort, Api, Resource
import uuid
app = Flask(__name__)
api = Api(app)
todoParser = reqparse.RequestParser()
todoParser.add_argument('description', type=str, help='Description of todo item.')
@Mulperi
Mulperi / breadcrumb.component.tsx
Created May 28, 2021 04:21
React breadcrumb example
import React from 'react';
import { NavLink } from 'react-router-dom';
import { Feature } from '../models/feature.model';
function getBreadcrumbStep(path: string[], iterationLimit: number): string {
let breadcrumb = '';
for (let i = 0; i < iterationLimit + 1; i++) {
breadcrumb += `/${path[i]}`;
}
@Mulperi
Mulperi / InputManager.cs
Created January 25, 2021 11:54
Simple gamepad manager, Unity new Input System
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputController : MonoBehaviour
{
public List<GameObject> players;
public Dictionary<int, GameObject> inputPlayerMap = new Dictionary<int, GameObject>();
@Mulperi
Mulperi / look.cs
Last active January 21, 2021 08:18
Unity gamepad and mouse look with new Input System
public void UpdateDirectionToGamePadRightStick(InputAction.CallbackContext context)
{
angle = Mathf.Atan2(context.ReadValue<Vector2>().y, context.ReadValue<Vector2>().x) * Mathf.Rad2Deg;
}
public void UpdateDirectionToMousePosition(InputAction.CallbackContext context)
{
Vector3 position = new Vector3();
position.x = context.ReadValue<Vector2>().x;
position.y = context.ReadValue<Vector2>().y;
position.z = 0.0f;
@Mulperi
Mulperi / weapon.cs
Created January 18, 2021 13:20
Weapon rotate script, new InputSystem
using UnityEngine.InputSystem;
public class WeaponController : MonoBehaviour
{
private Vector3 direction;
private float angle;
public void Rotate(InputAction.CallbackContext context)
{
Vector3 position = new Vector3();
@Mulperi
Mulperi / main.cpp
Created August 14, 2020 07:07
GLFW & GLEW, OpenGL rectangle using Shader class and uniform change.
/*
// shader1_vertex.glsl
#version 330 core
layout (location = 0) in vec3 aPos; // Attribute 0.
layout (location = 1) in vec3 aColor; // Attribute 1.
out vec3 color;
uniform float myColor;
void main()
@Mulperi
Mulperi / main.cpp
Created August 13, 2020 11:54
GLFW & GLEW Simple rectangle.
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <iostream>
const char *vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
@Mulperi
Mulperi / main.cpp
Created August 13, 2020 11:13
Simple GLFW window init
#include <GLFW/glfw3.h>
#include <stdio.h>
/**
Compile with MinGW on Windows:
mingw32-g++ main.cpp -I C:\libs\prebuilt\glfw-3.3.2.bin.WIN32\include -LC:\libs\prebuilt\glfw-3.3.2.bin.WIN32\lib-mingw -lglfw3 -lGdi32 -lOpengl32 -o main
**/
int main()
{
@Mulperi
Mulperi / main.c
Last active July 3, 2020 19:29
Game template SDL
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
typedef struct
{
int x;
@Mulperi
Mulperi / Makefile
Created July 3, 2020 07:09
Simple makefile for compiling a file that uses SDL
OBJS = main.c
OUTPUT = main
all : $(OBJS)
gcc $(OBJS) -IC:\libs\SDL2-2.0.12\i686-w64-mingw32\include -LC:\libs\SDL2-2.0.12\i686-w64-mingw32\lib -Wall -lmingw32 -lSDL2main -lSDL2 -o $(OUTPUT)