Who´s The Error In This Code?


Chipmunk

Still Fresh
Joined
Dec 26, 2004
Messages
2
[Sorry, i mean "Where is the error in this Code?"]

Hi everybody, a totaly Fenix newbie here! :)

Can anyone help me to search the error in my first code?
The Program hang up and i dont no why.

Hint: When i "//" the Drawing Lines out, the Programm run normal.

Greeting
Thomas

Code:
program apple_mountains;

global
	float xc;
	float yc;
	float xl;
	float xr;
	float yo;
	float yu;
	float dx;
	float dy;
	float yy1;
	float y2;
	float x2;
	float xx;
	float yy;
	bContinueLoop;
	t;
	s;
	xm;
	ym;
	n;
	m;
	k;
	u;
	u1; 
	v;
	v1;   
	color;


	begin
	set_mode(320,240,16);

	xc = 1;
	yc = 0;
	t = 20;
	s = 60;
	xl = -0.15;
	xr = 0.26;
	yo = 0.47;
	yu = 0.9;
	xm = 200;
	ym = 140;
	dx = (xr - xl) / xm;
	dy = (yu - yo) / ym;

  For(n= 0;n<ym;n++)
  	yy1 = yo + n * dy;
    For(m=0;m<xm;m++)
    	xx = xl + (m * dx);
    	yy = yy1;
    	k = 0;

    	bContinueLoop = 1;
      While (bContinueLoop==1)
      	x2 = xx * xx;
      	y2 = yy * yy;
      	yy = 2 * xx * yy - yc;
      	xx = x2 - y2 - xc;
      	k++;

      	If (k>t or x2 + y2 >= s) bContinueLoop=2;end

      	If(key(_esc)) exit("",0);End
      end


    	u =  m + 80 - n / 2;
  	
    	u1 = u + 1;
    	v = n + 67;
    	v1 = v - 3 * k - 1;

    	DELETE_TEXT(0);
    	write(0,10,10,0,u);
    	write(0,10,20,0,v);
    	write(0,10,30,0,u);
    	write(0,10,40,0,v1);
    	color=rgb(0,0,180);
    	DRAWING_COLOR(color);
    	DRAW_LINE (u,v,u,v1);
    	color=rgb(110,110,255);
    	DRAWING_COLOR(rgb(110,110,255)); 
    	DRAW_LINE(u1,v,u1,v1);
    	color=rgb(0,0,0);
    	DRAWING_COLOR(rgb(0,0,0));
    	DRAW_LINE(u,v1,u1,v1);
frame;
    	If(key(_esc)) exit("",0);End
    end
  end

    	loop     
      If(key(_esc)) exit("",0);End
    	frame;
      	end
	end    
 
You might want to change your variable names to more descriptive ones too, no point in making it harder for yourself ;). The error you were most likely getting was too many draws at a time. Draws are much like texts, you write them but then you need to remove them before they go away, and if you are drawing 3 lines every frame you will most likely reach the limit(256 or 512) pretty soon. Plus, you might want to write your variables with write_int or write_float, as they update the values automatically, saves the trouble of writing them again every frame.
 
Back
Top