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

Username:   Password: 
 RegisterRegister   
 Sweet vortex controlled by mouse
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
petree08




PostPosted: Mon Oct 23, 2006 10:51 am   Post subject: Sweet vortex controlled by mouse

This is a little diddy i wrote that kind of looks like a vortex
you can move it around with the mouse make it implode or explode by holding the mouse buttons down, or leaving them up.

--
Was the first program I made that uses arrays



code:

const C_OF_B := 12
const C_OF_B2 := 12
const NUMOFBALLS := 1000
const PROX := 11
const EX_SIZE := 400
const SIZE := 3
const M_S := 20
const MIDX := maxx div 2
const MIDY := maxy div 2
var Xm, Ym, Click : int
const SPEED := 9
var Length : array 1 .. NUMOFBALLS of real4
var X : array 1 .. NUMOFBALLS of int
var Dx : array 1 .. NUMOFBALLS of int
var Y : array 1 .. NUMOFBALLS of int
var Dy : array 1 .. NUMOFBALLS of int
var C : array 1 .. NUMOFBALLS of int
var SX : array 1 .. NUMOFBALLS of int
var SY : array 1 .. NUMOFBALLS of int
process Clear
    loop
        delay (500)
        cls
    end loop
end Clear
setscreen ("graphics:max,max,nobuttonbar,offscreenonly,nocursor")
for Index : 1 .. NUMOFBALLS
    Y (Index) := 1
    X (Index) := 1
    randint (C (Index), 1, 15)
end for

colorback (7)
cls
%fork Clear
loop
    cls
    mousewhere (Xm, Ym, Click)
    for Index : 1 .. NUMOFBALLS

        Length (Index) := sqrt ((X (Index) - Xm) ** 2 + (Y (Index) - Ym) ** 2)
        SX (Index) := X (Index) - Xm
        SY (Index) := Y (Index) - Ym

    end for

    if Click = 0 then
        for Index : 1 .. NUMOFBALLS
            if Length (Index) > PROX then
                Dx (Index) := SX (Index) div (Length (Index) div SPEED)
                Dy (Index) := SY (Index) div (Length (Index) div SPEED)
            end if
        end for
    else

        for Index : 1 .. NUMOFBALLS
            if Length (Index) > PROX then
                Dx (Index) := 0
                Dy (Index) := 0
                Dx (Index) := - (SX (Index) div (Length (Index) div SPEED))
                Dy (Index) := - (SY (Index) div (Length (Index) div SPEED))
            end if
        end for

    end if


    %  drawfilloval (Xm, Ym, M_S, M_S, C_OF_B2)
    for Index : 1 .. NUMOFBALLS

        X (Index) := X (Index) + (Dx (Index))
        Y (Index) := Y (Index) + (Dy (Index))

        if /*Length (Index) > EX_SIZE then */ X (Index) > maxx + 200 or X (Index) < -200 or
                Y (Index) > maxy + 200 or Y (Index) < -200 then
            loop
                randint (X (Index), Xm - 40, Xm + 40)
                randint (Y (Index), Ym - 40, Ym + 40)
                Length (Index) := sqrt ((X (Index) - Xm) ** 2 + (Y (Index) - Ym) ** 2)
                exit when Length (Index) > 4
            end loop

        end if
        %drawline (X (Index), Y (Index), Xm, Ym, C_OF_B)
        %drawoval (Xm, Ym, EX_SIZE, EX_SIZE, C_OF_B2)
        if Click = 1 then
            drawfilloval (Xm, Ym, 2, 2, 12)
        end if
        drawfilloval (X (Index), Y (Index), SIZE, SIZE, C (Index))
        % drawfilloval (X (Index), Y (Index), SIZE, SIZE, C_OF_B)
    end for
    exit when hasch
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
Prince Pwn




PostPosted: Tue Oct 24, 2006 10:33 am   Post subject: (No subject)

sweet
Windsurfer




PostPosted: Tue Oct 24, 2006 3:34 pm   Post subject: (No subject)

Nice! Good job. Not exactly a "vortex" per se, so check out my Forces engine and make some sparkels, then hold down the middle mouse button. Laughing
iamcow




PostPosted: Wed Oct 25, 2006 4:37 pm   Post subject: (No subject)

pretty neat
Silent Avenger




PostPosted: Wed Oct 25, 2006 8:13 pm   Post subject: (No subject)

That's pretty cool. Nice job!
Hackmaster




PostPosted: Thu Nov 02, 2006 4:50 pm   Post subject: (No subject)

Well Done! you seem to post a lot of programs, and the ones i've seen are very good! keep it up!
jr.ranger.33




PostPosted: Sat Nov 04, 2006 4:45 pm   Post subject: Pretty Kewl

Pretty cool program.
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 1  [ 7 Posts ]
Jump to:   


Style:  
Search: