This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) { |
NewerOlder