This file contains 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
BBox::GetWorldBBox(): | |
return world bbox | |
end | |
BBox::CheckCollisionType( box ): | |
myBox = GetWorldBBox() | |
//I know this part | |
if inside return inside | |
if outside return outside |
This file contains 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 <fstream> | |
#include <cstring> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
int main(int argc, char* argv[]) { | |
if (argc != 3) { |
This file contains 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 "sqlite3.h" | |
#include <iostream> | |
#include <cstring> | |
using namespace std; | |
int charcount(char* str, const char c) { | |
int count = 0; | |
while(*str) { |
This file contains 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
#ifndef LINKEDLIST_HPP_ | |
#define LINKEDLIST_HPP_ | |
class Node { | |
public: | |
Node() { | |
next = nullptr; | |
} | |
virtual ~Node() {} |
This file contains 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
#ifndef NETWORK_HPP_ | |
#define NETWORK_HPP_ | |
/* Unless noted otherwise, functions return 0 on success, or -1 on error. | |
* There are NO blocking functions. | |
* | |
* This is my idea for a minimalist networking interface. This is what I | |
* /wish/ existed. I might try and make this work, but I'm inexperienced | |
* with networking and making APIs. | |
*/ |
This file contains 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
#ifndef SINGLETON_HPP_ | |
#define SINGLETON_HPP_ | |
template<typename T> | |
class Singleton { | |
public: | |
static T* GetSingletonPtr() { | |
return &singleton; | |
} | |
static T& GetSingletonRef() { |
This file contains 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 "image.hpp" | |
#include "sprite_sheet.hpp" | |
#include "raster_font.hpp" | |
#include "surface_manager.hpp" | |
#include "button.hpp" | |
#include "SDL/SDL.h" | |
#include <iostream> | |
#include <chrono> |
This file contains 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
while(1) | |
{ | |
calculateDT | |
disaptch inbound packets (you don't pass DT here, instead, this should have a reference to your gamestate object) | |
update accordingly (pass DT HERE) | |
render | |
} |
This file contains 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
int thread(void*) { | |
SDL_mutexP(lock); //remember: p for pause | |
if (/* not ready */) { | |
SDL_CondWait(cond, lock); | |
} | |
//do something | |
SDL_mutexV(lock); | |
SDL_CondSignal(otherCond); | |
} |
This file contains 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> | |
using namespace std; | |
/* this is the most efficient prime number algorithm I could come up with | |
* the speed is worst case O(n) | |
*/ | |
bool isPrime(int n) { | |
//two is the only even prime | |
if (n == 2) { | |
return true; |
OlderNewer