Computer Science Canada

Creating shooting star effect

Author:  Neja [ 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

Author:  Andy [ Sun Jun 15, 2003 3:07 pm ]
Post subject: 

just put cls after ur gatch statement

Author:  PaddyLong [ Sun Jun 15, 2003 3:17 pm ]
Post 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

Author:  krishon [ Sun Jun 15, 2003 3:21 pm ]
Post subject: 

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

Author:  Neja [ Sun Jun 15, 2003 3:40 pm ]
Post 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?

Author:  krishon [ Sun Jun 15, 2003 3:43 pm ]
Post subject: 

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

Author:  Neja [ Sun Jun 15, 2003 3:50 pm ]
Post 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)

Author:  PaddyLong [ Sun Jun 15, 2003 3:51 pm ]
Post 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

Author:  krishon [ Sun Jun 15, 2003 3:59 pm ]
Post 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

Author:  Neja [ Sun Jun 15, 2003 3:59 pm ]
Post subject: 

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

Author:  Homer_simpson [ Sun Jun 15, 2003 9:19 pm ]
Post 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

Author:  PaddyLong [ Sun Jun 15, 2003 10:13 pm ]
Post 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

Author:  Andy [ Mon Jun 16, 2003 9:29 am ]
Post subject: 

ya krishon ya there is setscreen("noecho")

Author:  krishon [ Mon Jun 16, 2003 9:46 am ]
Post subject: 

that's the one


: