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

Username:   Password: 
 RegisterRegister   
 Creating shooting star effect
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Neja




PostPosted: Sun Jun 15, 2003 2:59 pm   Post subject: Creating shooting star effect

I'm making a game (RPG, it's really cheap..anyways) and I want to have stars flying at the bottom screen along the x-axis. I used a for statement for that. What I can't figure out is how to have the stars repeatedly going across the screen without re-drawing them (loop) and have them stop when the user inputs their decision (get ans:*)

Here's a really simple bit of code that I'm trying to manipulate:

code:
proc Star
   
    var ans : string
    for x : 0 .. 660
        loop
            drawstar (x, 0, x + 8, 10, 14)
            drawstar (x + 8, 10, x + 16, 25, 14)
            drawstar (x + 16, 25, x + 24, 40, 14)
            drawstar (x + 24, 40, x + 32, 55, 14)
            drawstar (x + 16, 55, x + 24, 70, 14)
            drawstar (x + 8, 70, x + 16, 85, 14)
            drawstar (x, 85, x + 8, 100, 14)
            delay (5)
            drawstar (x, 0, x + 8, 10, 7)
            drawstar (x + 8, 10, x + 16, 25, 7)
            drawstar (x + 16, 25, x + 24, 40, 7)
            drawstar (x + 24, 40, x + 32, 55, 7)
            drawstar (x + 16, 55, x + 24, 70, 7)
            drawstar (x + 8, 70, x + 16, 85, 7)
            drawstar (x, 85, x + 8, 100, 7)
        end loop
        get ans : *
    end for

end Star
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Sun Jun 15, 2003 3:07 pm   Post subject: (No subject)

just put cls after ur gatch statement
PaddyLong




PostPosted: Sun Jun 15, 2003 3:17 pm   Post subject: (No subject)

something like this?

code:

proc Star

    var ans : string
    loop
        for x : 0 .. maxx
            drawstar (x, 0, x + 8, 10, 14)
            drawstar (x + 8, 10, x + 16, 25, 14)
            drawstar (x + 16, 25, x + 24, 40, 14)
            drawstar (x + 24, 40, x + 32, 55, 14)
            drawstar (x + 16, 55, x + 24, 70, 14)
            drawstar (x + 8, 70, x + 16, 85, 14)
            drawstar (x, 85, x + 8, 100, 14)
            exit when hasch
            delay (5)
            drawstar (x, 0, x + 8, 10, 7)
            drawstar (x + 8, 10, x + 16, 25, 7)
            drawstar (x + 16, 25, x + 24, 40, 7)
            drawstar (x + 24, 40, x + 32, 55, 7)
            drawstar (x + 16, 55, x + 24, 70, 7)
            drawstar (x + 8, 70, x + 16, 85, 7)
            drawstar (x, 85, x + 8, 100, 7)
        end for
        exit when hasch
    end loop
    get ans : *
end Star
krishon




PostPosted: Sun Jun 15, 2003 3:21 pm   Post subject: (No subject)

isn't there a echo u can do or somethin?
Neja




PostPosted: Sun Jun 15, 2003 3:40 pm   Post subject: (No subject)

YAY! Lol, ya, that's great...but, I've got an interview for this project where I have to explain how it all works, so, what the heck does hasch do? What is it?
krishon




PostPosted: Sun Jun 15, 2003 3:43 pm   Post subject: (No subject)

hasch is used to exit a loop (as he used in the example) when u press a character
Neja




PostPosted: Sun Jun 15, 2003 3:50 pm   Post subject: (No subject)

cool, but why is there two exit when hasch?
(Sorry, I'm prob getting really annoying, but this is my first semester with Comp. Sci)
PaddyLong




PostPosted: Sun Jun 15, 2003 3:51 pm   Post subject: (No subject)

because there's two loops (the for loop and the regular loop)

hasch is just something that returns true if a key has been pressed
Sponsor
Sponsor
Sponsor
sponsor
krishon




PostPosted: Sun Jun 15, 2003 3:59 pm   Post subject: (No subject)

ye, its fine if u ask questions, after all S.W.A.T is a help forum. just don't overdo it or post stupid stuff
Neja




PostPosted: Sun Jun 15, 2003 3:59 pm   Post subject: (No subject)

oh!
Thanks !!!!!!!!!!! Very Happy
Homer_simpson




PostPosted: Sun Jun 15, 2003 9:19 pm   Post subject: (No subject)

how bout adding a little curve... =)
code:
colorback (black)
cls
proc Star
    var ans : string
    var y := 0
    loop
        for x : 0 .. maxx
            y := round (1 * (x * .02) ** 2)
            %drawstar (x, 0, x + 8, 10, 14)
            drawstar (x + 8, y + 10, x + 16, y + 25, 14)
            drawstar (x + 16, y + 25, x + 24, y + 40, 14)
            drawstar (x + 24, y + 40, x + 32, y + 55, 14)
            drawstar (x + 16, y + 55, x + 24, y + 70, 14)
            drawstar (x + 8, y + 70, x + 16, y + 85, 14)
            drawdot(x,y,white)
            %drawstar (x, 85, x + 8, 100, 14)
            exit when hasch
            delay (5)
            drawstar (x + 8, y + 10, x + 16, y + 25, 7)
            drawstar (x + 16, y + 25, x + 24, y + 40, 7)
            drawstar (x + 24, y + 40, x + 32, y + 55, 7)
            drawstar (x + 16, y + 55, x + 24, y + 70, 7)
            drawstar (x + 8, y + 70, x + 16, y + 85, 7)
        end for
        exit when hasch
    end loop
    get ans : *
end Star
Star
PaddyLong




PostPosted: Sun Jun 15, 2003 10:13 pm   Post subject: (No subject)

I think that needs a little bounce Homer Very Happy

code:

colorback (black)
cls
proc Star
    var ans : string
    var y := 0
    loop
        for x : 0 .. maxx
            y := round (cosd (x * 10)) + round ((x * .02) ** 2)
            %drawstar (x, 0, x + 8, 10, 14)
            drawstar (x + 8, y + 10, x + 16, y + 25, 14)
            drawstar (x + 16, y + 25, x + 24, y + 40, 14)
            drawstar (x + 24, y + 40, x + 32, y + 55, 14)
            drawstar (x + 16, y + 55, x + 24, y + 70, 14)
            drawstar (x + 8, y + 70, x + 16, y + 85, 14)
            %drawdot (x, y, white)
            %drawstar (x, 85, x + 8, 100, 14)
            exit when hasch
            delay (5)
            drawstar (x + 8, y + 10, x + 16, y + 25, 7)
            drawstar (x + 16, y + 25, x + 24, y + 40, 7)
            drawstar (x + 24, y + 40, x + 32, y + 55, 7)
            drawstar (x + 16, y + 55, x + 24, y + 70, 7)
            drawstar (x + 8, y + 70, x + 16, y + 85, 7)
        end for
        exit when hasch
    end loop
    get ans : *
end Star
Star
Andy




PostPosted: Mon Jun 16, 2003 9:29 am   Post subject: (No subject)

ya krishon ya there is setscreen("noecho")
krishon




PostPosted: Mon Jun 16, 2003 9:46 am   Post subject: (No subject)

that's the one
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: