Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pow! A very simple source code.
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Foundation




PostPosted: Mon Sep 18, 2006 8:11 pm   Post subject: Pow! A very simple source code.

Just for entertainment, please reply for ways to make this better. I'm new to programming, so I'll need all the help I can get. Thanks.

code:

const centerx := maxx div 2
const centery := maxy div 2
var c : int
loop
    for i : 1 .. 3
        for radius : 1 .. centerx + 90
            randint (c, 1, 15)
            drawoval (centerx, centery, radius, radius, c)
            delay (5)
        end for
        for decreasing radius : centerx + 90 .. 1
            randint (c, 1, 15)
            drawoval (centerx, centery, radius, radius, c)
            delay (5)
        end for
    end for
    for decreasing radius : centerx + 90 .. 1
        c := 0
        drawoval (centerx, centery, radius, radius, c)
        delay (10)
    end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Mon Sep 18, 2006 9:45 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=7734

Its been done 1000 times, and it takes very little effort. Follow the rule: Stare at it for 2 minutes. If you still love watching it, then consider posting it...
blaster009




PostPosted: Mon Sep 18, 2006 11:00 pm   Post subject: (No subject)

Haha, oh Jeremy. Take it easy on the guy. He IS new.

Anyhow, try procedures! Might take you a few clicks to get them, but it's well worth it! Also, code format. I suggest a better way of naming your variables to make it easier to read. Try cAmElCaSe. Basically, you capitalize the first letter of individual words (but not the first letter). Ex: mystringlength becomes myStringLength. Otherwise, a fairly well-written donothing program.

code:

var centerX : int := maxx div 2
var centerY : int := maxy div 2

proc upCountDraw (setCircleColour, circleX, circleY, delayTime : int)
    var drawCircleColour : int := setCircleColour
    for radius : 1 .. circleX + 90
        if setCircleColour = -1 then
            drawCircleColour := Rand.Int (0, 255)
        end if
        drawoval (circleX, circleY, radius, radius, drawCircleColour)
        delay (delayTime)
    end for
end upCountDraw

proc downCountDraw (setCircleColour, circleX, circleY, delayTime : int)
    var drawCircleColour : int := setCircleColour
    for decreasing radius : circleX + 90 .. 1
        if setCircleColour = -1 then
            drawCircleColour := Rand.Int (0, 255)
        end if
        drawoval (circleX, circleY, radius, radius, drawCircleColour)
        delay (delayTime)
    end for
end downCountDraw


loop
    for i : 1 .. 3
        upCountDraw (-1, centerX, centerY, 5)
        downCountDraw (-1, centerX, centerY, 5)
    end for
    downCountDraw (0, centerX, centerY, 10)
end loop


In this fashion, all you need to do is pass different parameters (input numbers) to the procedures, and you'll get a whole crazy slew of different outputs. Cheers!

(Oh, and Jeremy's right. No more trippy flash programs.)
Foundation




PostPosted: Tue Sep 19, 2006 7:38 am   Post subject: (No subject)

Thanks. I won't put up any more weird programs now. Embarassed
ericfourfour




PostPosted: Tue Sep 19, 2006 9:04 pm   Post subject: (No subject)

If you think your program's weird check this one out.

code:

setscreen ("graphics:max;max,nobuttonbar")
var x := maxx / 2
var y := maxy / 2
var offset := 0.0
var offset_inc := 0.001
var clrlimit := 20
var radx := 10
var rady := 10
loop
    for angle : 1 .. 360
        offset += offset_inc
        var x_ := round (x + offset * sind (angle))
        var y_ := round (y + offset * cosd (angle))
        Draw.FillOval (x_, y_, radx, rady, angle rem clrlimit)
    end for
end loop


With simple trig you can make some pretty cool effects. Try playing around with the variables. Especially the radius (a cool one is radx = 50 and rady = 10).
Foundation




PostPosted: Wed Sep 20, 2006 7:43 am   Post subject: (No subject)

Could you tell me how to use trig in turing? Question
ericfourfour




PostPosted: Wed Sep 20, 2006 2:51 pm   Post subject: (No subject)

There might already be a tutorial on using trig in turing. The sytax you want to look up though would be sin, cos, tan, arcsin, arccos, arctan, sind, cosd and tand (there may be more). I'd reccomend grade 10 math since that is where you start to learn triginometry.
ZeroPaladn




PostPosted: Fri Sep 22, 2006 12:30 pm   Post subject: (No subject)

there is no trig tut as far as i know. if you realy want to learn trig, go to school (grade 10 - 12 math and grade 11 - 12 physics should do ya)
Sponsor
Sponsor
Sponsor
sponsor
blaster009




PostPosted: Fri Sep 22, 2006 9:22 pm   Post subject: (No subject)

ericfourfour wrote:
If you think your program's weird check this one out.

code:

setscreen ("graphics:max;max,nobuttonbar")
var x := maxx / 2
var y := maxy / 2
var offset := 0.0
var offset_inc := 0.001
var clrlimit := 20
var radx := 10
var rady := 10
loop
    for angle : 1 .. 360
        offset += offset_inc
        var x_ := round (x + offset * sind (angle))
        var y_ := round (y + offset * cosd (angle))
        Draw.FillOval (x_, y_, radx, rady, angle rem clrlimit)
    end for
end loop


...Although this is a trippy flash program, I'ma give you some credit: That one is pretty awesome. Watching it looks like motion in a tunnel shooter. Perhaps you could use a similar, faster algorithm to simulate movement?
ericfourfour




PostPosted: Fri Sep 22, 2006 10:02 pm   Post subject: (No subject)

I don't know of any special algorithms to do it but I'm sure there is. Mine just keeps on increasing the distance from the middle and paces the circle in the correct spot according to the angle and distance. I'm sure you could do this with particle system aswell. Also, with the particle system you could have multiple effects at once so it would look really amazing.
wtd




PostPosted: Sun Oct 01, 2006 12:39 pm   Post subject: (No subject)

blaster009 wrote:
Try cAmElCaSe.


Or perhaps this_kind_of_name.
Foundation




PostPosted: Sat Oct 07, 2006 10:35 am   Post subject: (No subject)

Okay. I know trig, and I know sin, cos, tan etc.. Confused What I do want to know is how to utilize the knowledge of trig in turing. Like what I can do with it. I'm just a beginner at turing, and I would like some help on how to use my knowledge of trig to create cool graphics. Laughing
Jekate




PostPosted: Sat Oct 07, 2006 9:31 pm   Post subject: (No subject)

code:
loop
    for i : 0 .. 400
        for e : 1 .. 400 by 20
            drawarc (maxx div 2, maxy div 2, i, i, i + e, i + e + 10, black)
            drawarc (maxx div 2, maxy div 2, i, i, i + e + 10, i + e + 20, white)
        end for
    end for
    for decreasing i : 400 .. 0
        for e : 1 .. 400 by 20
            drawarc (maxx div 2, maxy div 2, i, i, i + e, i + e + 10, white)
            drawarc (maxx div 2, maxy div 2, i, i, i + e + 10, i + e + 20, black)
        end for
    end for
end loop

TheOneTrueGod




PostPosted: Sun Oct 08, 2006 4:16 pm   Post subject: (No subject)

Jakete, that really serves no purpose... read my first post in this thread.

Anyways, if you know trig, to utilize it, just use:

RADIANS
sin
cos
tan

arcsin
arccos
arctan

DEGREES
sind
cosd
tand

arcsind
arccosd
arctand

However, programming is far more than just making pretty effects. Try using trig to create AI: that is, create something that will follow your mouse around using the trig identities to start off with, then work from there. I made some pretty decent CTF AI using trig. Its worth a shot Smile.
Foundation




PostPosted: Sun Oct 08, 2006 5:41 pm   Post subject: (No subject)

First of all, thank you TheOneTrueGod, for following my post, and providing much needed advice. But people have been misunderstanding me ever since I posted that I wanted to learn trig. I am very new to programing, my first grade 11 programing class just started. (skipped grade 10 because ppl say it's substandard Laughing ) I understand the radian and degree measurements and the winding function and a certain amount about trig. What I would have liked to see is someone explaining How Razz to USE my knowledge of trig. Thanks for explaining that sind returns ( Question ) in degree and sin returns in radians. Please help me with utilizing trig in creating programs.

But I will try myself first, whatever is learnt by oneself is easier remembered. If I have too much trouble programming with trig myself, I will ask later.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: