forums

TNT Basic Forums > Programming Q&A
Line drawing
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-29-2002 11:01

Posted by:
mark_667

Click Here to Email mark_667   Find more posts by mark_667

Hi,
Just thought I'd try this, just to see if it could be done, but there are a couple of errors, the first is on line 8 and reads, "The index variable in a for loop must be an integer value or an item from the integer array." The second is on line 13 where 240 is highlighted, but the X co-ordinate is not. Anyone who knows why this is, and how it can be fixed please help, the source is included below...

graphics mode 640,480
frame rect 0,0 to 640,480

int pi=3.141596
int angle=pi/180

for
int angle=0 to 360
int R=300*cos(2*angle)
int X=R*cos(angle)
int Y=R*cos(angle)

x=320,y=240 'Draws it at centre of screen...
Next angle
wait mouse click
end

12-02-2002 00:27

Posted by:
Mark Tully

Find more posts by Mark Tully

Hi there,

You can't declare a variable inside a for statement in TNT Basic, and the entire for statement must also be on a single line. You also can't do multiple commands on the same line using the comma syntax. You example should read:

graphics mode 640,480
frame rect 0,0 to 640,480

int pi=3.141596
int angle=pi/180

for angle=0 to 360
int R=300*cos(2*angle)
int X=R*cos(angle)
int Y=R*cos(angle)

x=320
y=240 'Draws it at centre of screen...
... NOTE x and X are the same thing, so you're losing the value calculated above....
Next angle
wait mouse click
end


Cheers,

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.