Skip to content

Instantly share code, notes, and snippets.

@zachelko
zachelko / rotate.py
Created April 8, 2010 05:25
Roll the ball
# If we need to rotate our player (character is a ball, etc...)
if (self.rotate == True and moveX != 0):
if (moveX < 0): self.image = pygame.transform.rotate(self.image, -90)
else: self.image = pygame.transform.rotate(self.image, 90)
@zachelko
zachelko / skater.cpp
Created April 8, 2010 06:23
Basic C/C++ code obfuscator.
// Zach J. Elko
// 2010
// skater.cpp
//
// I've wanted to make one of these for a while now. I got bored and
// whipped this up in about 3 hours. There are a lot of improvements
// that can/should be made, but it's not bad for the short amount of
// time put into it.
//
// Basic C/C++ code obfuscator.
@zachelko
zachelko / templatetrick.cpp
Created April 10, 2010 04:01
Template tricks
// resource.h
//
#ifndef _RESOURCE_H
#define _RESOURCE_H
template <typename T>
class Resource
{
protected:
T* data;
@zachelko
zachelko / Vector2d.hpp
Created April 10, 2010 22:39
General-purpose 2d vector class
// Vector2d.hpp
//
// Zach Elko
// 2010
//
// General-purpose 2d vector class
//
#ifndef VECTOR2D_H
#define VECTOR2D_H
@zachelko
zachelko / SoundManager.cpp
Created April 11, 2010 00:04
A simple sound manager for SDL
// SoundManager.cpp
//
// Zach Elko
// 2010
//
// A simple sound manager for SDL.
//
#include "SoundManager.h"
#include "SDL/SDL_mixer.h"
#include "../ResourceManager.h"
@zachelko
zachelko / badbegin1.cpp
Created April 11, 2010 05:07
STL begin() 1
std::vector<int> foo;
// Set the iterator once we've created the container
std::vector<int>::iterator iter = foo.begin();
// Add some stuff to it
foo.push_back(2);
foo.push_back(3);
// Use the iterator... oops!
@zachelko
zachelko / badbegin2.cpp
Created April 11, 2010 05:10
STL begin() 2
std::vector<int> foo;
// Add an item before setting the iterator...
// Should work, right?
foo.push_back(2);
std::vector<int>::iterator iter = foo.begin();
// Add another item
foo.push_back(3);
#include <vector>
#include <iostream>
using namespace std;
int main() {
std::vector<int> foo;
// Add an item and then obtain an iterator to it
foo.push_back(3);
#include <vector>
#include <iostream>
using namespace std;
int main() {
std::vector<int> foo;
// Add an item and then obtain an iterator to it
foo.push_back(3);
// ResourceManager.cpp
//
// Zach Elko
// 2010
//
// Functions as a garbage collector for allocating and releasing SDL resources.
//
// Supports: SDL_Surface, Mix_Music, and Mix_Chunk.
//
// It improves program efficiency by only allocating one copy for each