Skip to content

Instantly share code, notes, and snippets.

View chunkyguy's full-sized avatar

Sidharth Juyal chunkyguy

View GitHub Profile
@chunkyguy
chunkyguy / wl_texture_atlas_format
Created August 25, 2014 03:54
Texture Atlas format for use in an upcoming game engine. This format works with Zwoptex.app
<?xml version="1.0" encoding="UTF-8"?>
<TextureAtlas>
<meta>
<textureName>{{ metadata.target.textureFileName }}</textureName>
<textureExtension>{{ metadata.target.textureFileExtension }}</textureExtension>
<textureSize>{{ metadata.size }}</textureSize>
</meta>
<SubTextures>
{% for sprite in spritesAndAliases %}
<SubTexture>
#include <iostream>
struct Vector2 {
float x;
float y;
Vector2(float x = 0, float y = 0) {
this->x = x;
import UIKit
func clamp<T:Comparable>(value:T, lowerBound:T, upperBound:T) -> T {
return min(max(lowerBound, value), upperBound)
}
func clamp(value:Vector2, lowerBound:Vector2, upperBound:Vector2) -> Vector2 {
return min(max(lowerBound, value), upperBound)
}
@chunkyguy
chunkyguy / QuadTree.h
Created April 1, 2015 11:09
Quad Tree
//
// QuadTree.h
//
// Created by Sid on 24/01/14.
// Copyright (c) 2014 whackylabs. All rights reserved.
//
#ifndef QuadTree_h
#define QuadTree_h
@chunkyguy
chunkyguy / KingdomRush.c
Created April 28, 2012 03:44
Dead virgin code; couldn't even compile once :(
#include <iostream.h>
#define N_MAX 2048
typedef struct{
int num;
int easyDone;
int easyStar;
int hardDone;
int hardStar;
@chunkyguy
chunkyguy / createimp.c
Created July 1, 2012 10:35
Create ObjectiveC implementation file from interface file.
/*
Input:
- (void)viewWillDisappear:(BOOL)animated;
Output:
- (void)viewWillDisappear:(BOOL)animated{
[handler_ viewWillDisappear:animated];
}
*/
@chunkyguy
chunkyguy / DebugAlert.h
Created July 24, 2012 00:16
Debugging with UIAlertViews
#define POP_ALERT(title, msg) [[[[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]autorelease] show]
/*
Usage:
POP_ALERT(@"Title Here", @"Message Here");
*/
@chunkyguy
chunkyguy / twoChecWins.m
Created August 1, 2012 15:16
The two checkWin methods accomplish the same task
/** Logic 1 */
-(BOOL)funcOfBase:(int)b multiple:(int)n{
return ((_slots[b]==_aType) && (_slots[b+n*1]==_aType) && (_slots[b+n*2])==_aType);
}
-(BOOL)checkWin{
int bases[5] = {0, 1, 2, 3, 6};
int multiples[5][4] = {
{1, 3, 4, 0},
{3, 0, 0, 0},
if(troop_position == 4){
for(int possible_position = 0; possible_position < 9; possible_position++){
if(_slots[possible_position] == -1){
availPos[troop_number][available_position[troop_number]++] = possible_position;
}
}
}else{
for(int possible_position = 0; possible_position < 3; possible_position++){
if(_slots[_nextPossiblePositions[troop_position][possible_position]] == -1){
availPos[troop_number][available_position[troop_number]++] = _nextPossiblePositions[troop_position][possible_position];
@chunkyguy
chunkyguy / iOS_OpenGL_template.c
Created August 16, 2012 20:37
Apple OpenGL template for iOS uses two sets of enums
/*
At create setup stage
*/
glEnableVertexAttribArray(GLKVertexAttribPosition);
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0));
glEnableVertexAttribArray(GLKVertexAttribNormal);
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12));
/*
At binding stage