Invalid memory access of location
in
Programming Questions
•
2 years ago
hi guys
i was playing with a frind with some supersimple 2d graphics
i'm on imac with mac os-x 10.5.8
every time i run this sketched i get this error:
Invalid memory access of location 0xb0fb6e8b eip=0x94ba7931
this is the bad code,
i'm not an hard coder but it doesn't look like a great memory waster
- int circle_radius = 5;
- int c = 255;
- float speed = 0, spring = 0.4, resistence = 0.08;
- float delta = 1;
- float rot = 0;
- void setup() {
- size(800,800);
- smooth();
- }
- void draw() {
- background(0);
- translate(width/2, height/2);
- rotate(rot);
- float angle = 0;
- float sin_angle = 0;
- for (int i=600; i>0; i-=circle_radius) {
- sin_angle = wave_function(angle);
- fill(c);
- c = switchColor(c);
- ellipse(sin_angle,sin_angle, i, i);
- angle += delta;
- }
- delta = spring(delta, 0);
- rot+=0.08;
- //delta = map(mouseX, 0, width, 0, 1);
- }
- float wave_function(float angle) {
- return sin(angle)* 4;
- //return noise(angle)*4;
- }
- float spring(float x, float target) {
- speed += (target - x) * spring;
- speed *= resistence;
- x += speed;
- println(x);
- if(x<=0.01)x = 0;
- return x;
- }
- int switchColor(int c) {
- c = (c==255) ? (0) : (255);
- return c;
- }
- void mousePressed() {
- //spring = random(0.8);
- //resistence = random(0.8);
- delta = 1;
- println(spring);
- println(resistence);
- }
1