# stokastic

Member Since 13 Jul 2011
Offline Last Active Nov 15 2012 11:56 PM

### Topics I've Started

15 November 2012 - 10:39 PM

Is it possible to create custom collision masks just through code? I want to use disk-type collisions based on the size of the planets I have, but because the size is dynamic, I don't want to have to create a sprite for every size of planet. The range from 1 pixel to circles 100 pixels in radius. I couldn't find any code for this, but I'm looking for something like sprite_set_mask(type, size) or something.

### Decimal accuracy

27 June 2012 - 07:52 AM

I'm writing a ray tracer simulator in GM. Basically what it does is take an already made image, and make it look as if it's being raytraced. I'm running into a problem however in that after a high number of samples per pixel, the image appears biased towards grey. I'm wondering if this is a decimal accuracy issue or algorithmic.

This is a sampling of a red color. How it works is you have your starting red color, 0 (technically NULL), and each sample picks either full red (255,0,0) or black (0, 0, 0). It then compares this value to a precomputed 'weight' value for that pixel. If the original image has a red value of 120 at (0,0) that becomes the red weight value. If a random number is greater than that weight, it returns full red, else full black. Over time this *should* average to 120, however it doesn't. It will approach 120, then slowly rise and the image becomes washed out. I think this may be because of decimal precision. It is taking large numbers, multiplying them by even larger numbers, and dividing by large numbers, so it seems a thousandth may be lost here or there.
```    num = irandom(255);
if(num < weightr[xx,yy]){
sat = 255;
}else{
sat = 0;
}
red[xx,yy] = (red[xx,yy] * samples[xx,yy] + sat)/(samples[xx,yy] + 1);
samples[xx,yy] += 1;
```

I'm hoping someone with raytracing experience can tell me if this is accurate math/methodology.

### draw_circle_aa and draw_getpixel()

26 July 2011 - 02:22 PM

Can someone make me an extension that will draw anti-aliased circles and one that will use draw_getpixel but faster?

### creating procedures

21 July 2011 - 11:09 PM

I couldn't find in the help file (probably because the search function in it is a peice of <noun>), but I know there must be a way that you can create procedures in GML. I want to use procedures so I can copy and paste one line instead of 10 or 15 lines all over my scripts.