forums

TNT Basic Forums > Programming Q&A
attempting to make matrix text
< Last Thread     Next Thread >
Author
Thread        Post A Reply

05-10-2007 01:46

Posted by:
Hendo

Location:
Barrie, Ontario

Click Here to Email Hendo   Find more posts by Hendo

Hi, I tried to do that "Matrix falling text" effect using tnt basic...I know this code is a little long and annoying but I have no clue how to fix it...Im trying to port it from another language that has some similarities to TNT but is still different...I think the actual coding in theory is fine but I need a syntax update:P


Code:
window mode 640,480
hide mouse
string symbol[300]
string symx, symy, symspeed[300]
global int i

for i = 1 to 300
if random (1,5) = 1
symbol (i) := "M"
else if random (1,5) = 2
symbol (i) := "Y"
else if random (1,5) = 3
symbol (i) := "Z"
else if random (1,5) = 4
symbol (i) := "X"
else if random (1,5) = 5
symbol (i) := "E"
end if
randint (symx (i), 1, maxx)
randint (symy (i), maxy, maxy + maxy)
randint (symspeed (i), 5, 10)
next i
repeat
draw frame

set pen colour black
paint canvas
for i : 1 .. 300
set pen colour green
draw text (symbol (i), symx (i), symy (i))
draw text (symbol (i), symx (i), symy (i) + 15)
if symspeed (i) > 6 then
draw text (symbol (i), symx (i), symy (i) + 30)
end if
symy (i) -= symspeed (i)
if symy (i) < -35 then
if random (1,5) = 1

symbol (i) := "M"
else if random (1,5) = 2
symbol (i) := "Y"
else if random (1,5) = 3
symbol (i) := "Z"
else if random (1,5) = 4
symbol (i) := "X"
else if random (1,5) = 5
symbol (i) := "E"
end if
random (symx (i), 1, maxx)
random (symy (i), maxy, maxy + maxy)
random (symspeed (i), 5, 10)
end if
next i
draw frame
forever

05-10-2007 16:05

Posted by:
JHVipond

Location:
South Dakota

Find more posts by JHVipond

The last "else if" line can be replaced by "else last command" since by that time, all the other tests will have failed. I still don't fully understand TNT Basic myself, so I'm not sure about the rest of your code.

05-10-2007 17:42

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

well that's not the right syntax, TNT doesn't use := at all, only = -you should check the docs and the samples i think you can get the changes very quickly if you understand this basic code

05-10-2007 21:21

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

This works but not quite the effect I imagine you want.
Not too sure what you wanted but this code is TNT "compliant

cheers

barry

window mode 640,480
hide mouse
global string symbol[300]
global int symx[300] , symy[300] , symspeed[300]
global int i,maxx=480,maxy=640

for i = 1 to 299
if random (1,5) = 1
symbol = "M"
else if random (1,5) = 2
symbol = "Y"
else if random (1,5) = 3
symbol = "Z"
else if random (1,5) = 4
symbol = "X"
else if random (1,5) = 5
symbol = "E"
end if
symx = random (1, maxx)
symy =random (maxy, maxy + maxy)
symspeed =random ( 5, 10)
next i
repeat
draw frame

set pen colour black
paint canvas
for i = 1 to 299
set pen colour green
draw text symx , symy ,symbol
draw text symx , symy +15,symbol

if symspeed > 6
draw text symx , symy +30,symbol
end if

symy = symy - symspeed

if symy < -35
if random (1,5) = 1
symbol = "M"
else if random (1,5) = 2
symbol = "Y"
else if random (1,5) = 3
symbol = "Z"
else if random (1,5) = 4
symbol = "X"
else if random (1,5) = 5
symbol = "E"
end if
symx = random (1, maxx)
symy =random (maxy, maxy + maxy)
symspeed =random ( 5, 10)
end if
next i
draw frame
forever

05-11-2007 02:10

Posted by:
Hendo

Location:
Barrie, Ontario

Click Here to Email Hendo   Find more posts by Hendo

SwagIT

Your code came up with some 35 errors...I don't really understand them but just letting you know...

05-11-2007 03:05

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

make sure there are no "phantom" spaces in front of code lines......

or email me at: swagitdev AT frankenspud DOT com

And I will send it to you - it's only 8k compressed....


really - it works....

=)

05-11-2007 03:09

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

I tried copy andd pasting from the post - it is the spaces in front of code lines....

05-11-2007 11:35

Posted by:
Hendo

Location:
Barrie, Ontario

Click Here to Email Hendo   Find more posts by Hendo

I don't know what spaces but...could you just send it to spikeit_13 AT hotmail DOT com

Thanks!!

05-11-2007 16:09

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

done

05-11-2007 17:00

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

When that happens, select and copy one of the spaces. Then find and replace that fake space with a real space.

05-12-2007 12:42

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I think its a Hieroglyph-Incompatible line ending.

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.