Skip to content

Instantly share code, notes, and snippets.

/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
class A {
private:
int p_i;
public:
A(int i) : p_i(i){}
A(const A& a) : p_i(a.p_i){}
operator int(){ return p_i; }
};
int main(){
#include <cmath>
#include <vector>
#include <SDL/SDL.h>
#include <IL/il.h>
#include <math.h>
const float PI = 3.14159265359f;
typedef struct {
unsigned int id;
c*x^2-2*b*x^2+a*x^2+2*b*x-2*a*x+a
Derive formula for quadratic bezier curve:
Interpolate from start point towards control point:
v1 = a + (b-a)*t
Interpolate from control point towards end point:
v2 = b + (c-b)*t
Interpolate between the two points computed from v1 and v2 (v is our point on the curve for any t in [0, 1]):
v = v1 + (v2 - v1)*t
@Madsy
Madsy / array2.c
Last active September 3, 2016 21:19
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void sumSubArraysFast(int* arr, size_t size){
int i,j,k;
int matsize = size * size;
int matsizebytes = sizeof(int) * matsize;
int* mat = malloc(matsizebytes);
memset(mat, 0, matsizebytes);
#include <stdio.h>
static void printSubArrays(int* arr, size_t size){
int i,j,k;
/* subarray sizes */
for(i = 1; i < size; i++){
printf("Subarrays with size %d:\n", i);
/* start position of subarray */
for(j = 0; j <= (size - i); j++){
log2_integer_recur(x, integer_result, error, multiplier, level):
if x > multiplier:
x = log2_integer_recur(x, integer_result, error, multiplier*multiplier, level*2)
while x > multiplier:
x := x / multiplier
integer_result := integer_result + level
return x
else:
return x
class Asteroid;
class Ship;
class Bullet;
class GameObject;
class CollisionDispatcher {
public:
virtual bool collidesWith(Asteroid* obj1, GameObject* obj2){
return obj2->collidesWithAsteroid(obj1);
}
With glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), scaling both source and destination with the same factor:
Note that:
(src*a*k) + (dst*(1-a)*k) = ((src*a) + (dst*(1-a)))*k
But since k is a part of a, we have to do some trickery:
alpha = (1.0 - (1.0 - alpha)*factor)
alpha = 1.0 - (factor - alpha*factor)
alpha = 1.0 + (alpha-1)*factor
How to cross-compile guile guile-2.0.9.241-950a-dirty or later for Windows, from a GNU Linux-distro (without thread support for now)
0.) If you have Wine installed, make sure it is not associated with .exe files, as it messes up
./configure's cross-compiler detection. Run "sudo update-binfmts --disable wine" if this is the case.
1.) Compile guile locally
2.) Cross-compile all dependencies normally, except libgc which requires special treatment. The libraries you need are the
versions below, or later:
gettext-0.18.3.1
gmp-5.1.3