Skip to content

Instantly share code, notes, and snippets.

@Shaptic
Shaptic / Init.cpp
Created June 29, 2012 02:09
TTF_Font* vs. MediaManager::Font
/* Load the Arial 16pt. font, render some text,
* resize the font to 32pt, and render some more text.
*
* Comparison of TTF_Font* vs my Font class wrapper.
*/
const SDL_Color Black = {0, 0, 0};
int main()
{
@Shaptic
Shaptic / MusicPlayer.cpp
Created June 29, 2012 02:17
MediaManager::MusicPlayer
int main()
{
bool quit = false;
MediaManager::MusicPlayer MusicPlayer;
MusicPlayer.AddSongToQueue("Song1.ogg");
MusicPlayer.AddSongToQueue("Song2.ogg");
while(!quit)
{
@Shaptic
Shaptic / TileFinder.py
Created July 13, 2012 19:46
Find all map tile files
import os
# Finds all image files starting with
# Map_ and ending with the .png extension.
# Returns a list of all images.
def find_tiles(directory):
textures = []
for root, dirs, files in os.walk(directory):
for tmp_file in files:
@Shaptic
Shaptic / Ray2.cpp
Created July 19, 2012 19:28
Line and line collision detection
/**
* Checks for intersection with another line segment. Touching at
* endpoints qualifies as intersections.
*
* @param math::Ray2 The other line
*
* @return TRUE if they intersect, FALSE otherwise.
* @see http://gamedev.stackexchange.com/questions/26004/how-to-detect-2d-line-on-line-collision
*/
bool Ray2::CheckCollision(const Ray2& Other) const
@Shaptic
Shaptic / Lighting.fs
Created September 21, 2012 23:32
Collapse point-lighting fragment shader
/**
* @file
* Fragment shader for lighting.
* Per-pixel point light lighting is done in this shader.
*
* @author George Kudrayvtsev (switch1440)
* @version 1.0
* @copyright Apache License v2.0
* Licensed under the Apache License, Version 2.0 (the "License").\n
* You may not use this file except in compliance with the License.\n
@Shaptic
Shaptic / Lighting.c
Created September 21, 2012 23:32
Collapse point-lighting fragment shader
/**
* @file
* Fragment shader for lighting.
* Per-pixel point light lighting is done in this shader.
*
* @author George Kudrayvtsev (switch1440)
* @version 1.0
* @copyright Apache License v2.0
* Licensed under the Apache License, Version 2.0 (the "License").\n
* You may not use this file except in compliance with the License.\n
@Shaptic
Shaptic / Lighting.c
Created September 21, 2012 23:33
Collapse point-lighting fragment shader
/**
* @file
* Fragment shader for lighting.
* Per-pixel point light lighting is done in this shader.
*
* @author George Kudrayvtsev (switch1440)
* @version 1.0
* @copyright Apache License v2.0
* Licensed under the Apache License, Version 2.0 (the "License").\n
* You may not use this file except in compliance with the License.\n
@Shaptic
Shaptic / RayCollision.cpp
Created September 27, 2012 22:54
Checks whether two line-segments interset.
/**
* Checks for intersection with another line segment. Touching at
* endpoints qualifies as intersections.
*
* @param math::CRay2 The other line
*
* @return TRUE if they intersect, FALSE otherwise.
* @see http://gamedev.stackexchange.com/questions/26004/how-to-detect-2d-line-on-line-collision
**/
bool CRay2::CheckCollision(const CRay2& Other, math::CVector2* p_Intersection) const
@Shaptic
Shaptic / Shadows.cpp
Created September 30, 2012 01:21
Render shadows in OpenGL
void RenderShadows(const math::CVector2& LightPos),
const std::vector<Object*>& shadowCastingObjects)
{
// Set up rendering modes
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_BLEND);
glColor4f(0.3f, 0.3f, 0.3f, 1.0f); // Dark gray
@Shaptic
Shaptic / Shadows.cpp
Created October 1, 2012 01:46
Render shadows in OpenGL
void RenderShadows(const math::CVector2& LightPos),
const std::vector<Object*>& shadowCastingObjects)
{
// Set up rendering modes
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_BLEND);
glColor4f(0.3f, 0.3f, 0.3f, 1.0f); // Dark gray