Skip to content

Instantly share code, notes, and snippets.

View flightcrank's full-sized avatar

flightcrank

  • Gold Coast, Australia
View GitHub Profile
PImage generateTex(int w, int h) {
PImage img = createImage(w, h, ARGB);
//size of each checker square
int size = 64;
color c = color(0);
//loop through each pixel in the image (img)
for(int i = 0; i < img.width; i++) {
@flightcrank
flightcrank / drawline.c
Created October 16, 2012 18:20
Bresenham's line algorithm
void draw_line(int x1, int y1, int x2, int y2) {
int dx = x2 - x1;
int dy = y2 - y1;
float slope = (float)dy / (float)dx;
float error = 0;
int y = y1;
int i;
@flightcrank
flightcrank / loadimage.c
Created September 28, 2012 13:13
sdl load image function
//Global variables
SDL_Surface *title_screen;
int load_image(char filename[], SDL_Surface *surface) {
SDL_Surface *temp;
//load image
temp = SDL_LoadBMP(filename);
@flightcrank
flightcrank / challange_1_i.c
Created April 27, 2012 09:33
challange_1_i
/*
create a program that will allow you to enter events organizable by hour.
There must be menu options of some form, and you must be able to easily edit, add, and delete events
without directly changing the source code.
(note that by menu i dont necessarily mean gui. as long as you can easily access the different
options and receive prompts and instructions telling you how to use the program, it will probably be fine)
*/
#include <stdio.h>
@flightcrank
flightcrank / challange_1_e.c
Created April 26, 2012 02:40
challange_1_e
/*
create a program that will ask the users name, age, and reddit username.
have it tell them the information back, in the format:
your name is (blank), you are (blank) years old, and your username is (blank)
for extra credit, have the program log this information in a file to be accessed later.
*/
#include <stdio.h>