Skip to content

Instantly share code, notes, and snippets.

View yknishidate's full-sized avatar

Yuki Nishidate yknishidate

View GitHub Profile
import math
import random
import matplotlib.pyplot as plt
class UniformDistribution:
def __init__(self, a: float, b: float) -> None:
self.a = a
self.b = b
struct Array1D
{
float vals[WIDTH];
float& operator[] (int index)
{
return vals[index];
}
};
#include <chrono>
struct Timer
{
void start()
{
startTime = std::chrono::steady_clock::now();
}
long long elapsed()
// create images
std::vector<vk::Image> images = ...;
// gather information
uint32_t memoryTypeBits = ~0; // 0b11111111...
vk::DeviceSize totalSize = 0;
std::vector<vk::DeviceSize> offsets;
for (auto&& image : images) {
offsets.push_back(totalSize);
#include <iostream>
#include <array>
class Particle
{
public:
Particle() : m_frameLeft(0) {}
void init(double x, double y, int lifeTime)
{
#include <iostream>
#include <vector>
#include <array>
#include <chrono>
class AIComponent
{
public:
void update()
{
#include <iostream>
class Audio
{
public:
virtual ~Audio() {}
virtual void playSound(int soundId) = 0;
virtual void stopSound(int soundId) = 0;
};
#include <iostream>
#include <queue>
struct PlayMessage
{
int soundId;
int volume;
};
class Audio
#include <iostream>
#include <vector>
#include <string>
class GameObject;
class Component
{
public:
virtual void update(GameObject &gameObject) = 0;
#include <iostream>
#include <vector>
#include <array>
#include <stack>
struct Wizard
{
int health;
int wisdom;
};