Skip to content

Instantly share code, notes, and snippets.

@timcash
timcash / HarmonicSeries.cpp
Created December 9, 2012 20:55
Harmonic series
#include <iostream>;
#include <string>;
#include <cmath>;
using namespace std;
int main()
{
int n=0; //counter
int t=0; //user-input number of iterations
double young=0.0; //the new sum
@timcash
timcash / Material Load
Created June 10, 2012 01:58
Material Load
using UnityEngine;
using System.Collections;
public class maker : MonoBehaviour {
// Use this for initialization
void Start () {
Material mat = Resources.Load("unlit",typeof(Material)) as Material;
if(mat == null)
@timcash
timcash / zeromq_pub.js
Created April 7, 2011 10:31
a test for publish speed of zeromq in nodejs
var cnt, mes, s, sender, util, zmq;
zmq = require('zeromq');
util = require('util');
s = zmq.createSocket('pub');
s.bind('tcp://127.0.0.1:5559', function(err) {
if (err) {
throw err;
}
util.puts('binding');
Planet = function(_a, _b, _c, _d) {
this.y = _d;
this.x = _c;
this.size = _b;
this.name = _a;
return this;
};
this.ships = {};
this.damage_pool = {};
class Planet
constructor: (@name,@size,@x,@y) ->
@ships = {}
@damage_pool = {}
add_ships: (player,amount) ->
#add ships to an array based on the player who owns them
log("adding #{amount} ships to player #{player}")
if @ships[player]?
class Planet
constructor: (@name,@size,@x,@y) ->
# I want an empty object to store ship in later
@ships = {}
battle: ->
#if more then one player has ships at this planet run the battle simulation
for p of @ships
damage = randint(@ships[p])
# todo, remove ships based on damage here