Computer Science Canada cool design maker |
Author: | flamemaster89 [ Sat Nov 12, 2005 2:33 pm ] |
Post subject: | cool design maker |
This is is an program that i found on this website and the person who created it should get credit for it but i edited a little to some thing different each time you run it. View.Set ("graphics:max;max, nobuttonbar,title:Mult-Ball Stream, offscreenonly") %Editable Constants% const BALLCOUNT := 1 const BALLRADIUS := 5 const BALLSPEED := 0 class RandomCircles import BALLRADIUS, BALLSPEED export StartValues, BallDirection, BallCreate var cx, cy, cdirectionx, cdirectiony, iColour : int := 0 var chars : string (1) procedure StartValues randint (cx, 0+BALLRADIUS*2, maxx-BALLRADIUS*2) randint (cy, 0+BALLRADIUS*2, maxy-BALLRADIUS*2) loop randint (iColour, 1, 103) randint (cdirectionx, -20, 20) randint (cdirectiony, -20, 20) exit when cdirectionx not = 0 exit when cdirectiony not = 0 end loop end StartValues %Wall collision procedure BallDirection cx := cx + cdirectionx cy := cy + cdirectiony if cx < BALLRADIUS or cx > maxx - BALLRADIUS then cdirectionx := -cdirectionx end if if cy < BALLRADIUS or cy > maxy - BALLRADIUS then cdirectiony := -cdirectiony end if end BallDirection %Ball Creation Procedure% procedure BallCreate Draw.FillOval (cx, cy, BALLRADIUS, BALLRADIUS, iColour) BallDirection delay (BALLSPEED) end BallCreate end RandomCircles procedure DrawBall var p : array 1 .. BALLCOUNT of pointer to RandomCircles for i : 1 .. BALLCOUNT new RandomCircles, p (i) end for loop for i : 1 .. BALLCOUNT p (i) -> StartValues end for loop for i : 1 .. BALLCOUNT p (i) -> BallCreate end for View.Update end loop end loop end DrawBall %Executes% DrawBall |
Author: | Cervantes [ Sat Nov 12, 2005 3:21 pm ] |
Post subject: | |
flamemaster89 wrote: the person who created it should get credit for it
Then you should give that person credit. Who? Also, you should state exactly what you altered. Second, please use [code ] [/code ] tags to surround your code. Even better, you could use [syntax="turing" ] [/syntax ] tags. Last, this falls under the category of "omfg sooo trippy cool flashes!". Capiche? |
Author: | flamemaster89 [ Sat Nov 12, 2005 5:55 pm ] |
Post subject: | |
thanks for the feedback |
Author: | Cervantes [ Sat Nov 12, 2005 6:12 pm ] |
Post subject: | |
flamemaster89 wrote: thanks for the feedback
I'd love to comment, but I don't know what you've done. I could comment on the whole thing, but most (probably all) of it wouldn't pertain to what you've done. |
Author: | [Gandalf] [ Sat Nov 12, 2005 10:24 pm ] |
Post subject: | |
Two things I can say: 1. Use [code][/code] and [syntax="turing"][/syntax] tags when posting code. 2. Indent your program please. Check out wtd's latest post in his Programming Tip of the Day topic: http://www.compsci.ca/v2/viewtopic.php?t=10119 |
Author: | Flikerator [ Sun Nov 13, 2005 12:35 am ] | ||
Post subject: | |||
I didn't know turing had pointers...lolz. Seems like an over complexed way to have a bouncing ball. EDIT - Very simple, 2 minute made (without the randomness)
|
Author: | Cervantes [ Sun Nov 13, 2005 8:37 am ] |
Post subject: | |
This example is very clumsily done. For example, constants that are used inside the class and only inside the class (BALLRADIUS and BALLSPEED) are declared outside the class, then imported. Very bad. It would be much better to declare the constants inside the class. Perhaps make them variables so they can be edited via a particular procedure (an initialization procedure). Flikerator: You should learn about classes! Check out Catalysts tutorial in [Turing Tutorials] |
Author: | Flikerator [ Sun Nov 13, 2005 10:18 am ] |
Post subject: | |
When are classes usefull? I read the tutorial, and understand them a little bit, but when would they be useful? Edit - I read it again, and I can see where it would be useful ^^; Do classes work the same way in other languages? Like C++? |
Author: | Cervantes [ Sun Nov 13, 2005 10:44 am ] | ||
Post subject: | |||
Flikerator wrote: When are classes usefull? I read the tutorial, and understand them a little bit, but when would they be useful?
Edit - I read it again, and I can see where it would be useful ^^; A good example you may wish to check out is my GUI classes. I was using classes extensively in that RTS engine I was working on a while ago, though I never did release the source to it, largely because I had modified the Turing predefs so much that it would be quite the hassel for people to test things out. If you want, I can send you the things you'd need to run it, however. Flikerator wrote: Do classes work the same way in other languages? Like C++? Essentially, though there are differences. Turing does not support multiple inheritence in any format. Also, in Turing, you've got to go to the trouble of declaring a pointer to the (parent) class, then creating a new instance of the class (or any of its daughter classes) with its reference being the pointer. In Ruby, for example, things are much neater:
|
Author: | Jorbalax [ Sat Nov 26, 2005 8:33 pm ] |
Post subject: | |
For reference, the original program was created by me. You can find it here. |