Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
// main.cpp
#include <iostream>
#include "GameLibrary.hpp"
int main() {
GameLibrary gameAssets;
// Add some assets
gameAssets.addSprite("Hero", "assets/hero.png");
gameAssets.addSprite("Enemy", "assets/enemy.png");
// GameLibrary.cpp
#include "GameLibrary.hpp"
#include <stdexcept>
// Sprite Methods
void GameLibrary::addSprite(const std::string& name, const std::string& filepath) {
sprites.push_back(Sprite{name, filepath});
}
const Sprite& GameLibrary::getSprite(size_t index) const {
// GameLibrary.hpp
#pragma once
#include <vector>
#include <string>
// Structure for a sprite
struct Sprite {
std::string name;
std::string filepath; // Path to the sprite image
#include <dshow.h>
#include <windows.h>
#include <iostream>
#pragma comment(lib, "Strmiids.lib")
#pragma comment(lib, "Quartz.lib")
using namespace std;
// Initialize the Windows DirectShow system (think of it like waking up the webcam)
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main() {
// Open default webcam
VideoCapture cap(0); // Open the default camera (0 for default webcam)
package {
import flash.display.Sprite;
import flash.media.Camera;
import flash.media.Video;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
public class WebcamStream extends Sprite {
private var camera:Camera;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Webcam Stream with Custom FPS</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
int main() {
std::vector<int> vec = {1, 2, 3, 4};
std::set<std::string> mySet = {"apple", "banana", "cherry"};
std::map<std::string, int> myMap = {{"cat", 1}, {"dog", 2}};
#include <algorithm> // std::find
#include <string> // std::string
#include <map> // std::map
#include <unordered_map>// std::unordered_map
#include <type_traits> // std::enable_if_t, std::is_same
#include <iterator> // std::begin, std::end
// Helper to detect if a type is a map
template<typename T>
struct is_map : std::false_type {};
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<int> vec = {1, 2, 3, 4};
std::string text = "hello world";
int arr[] = {10, 20, 30};
if (in(3)(vec)) {