 Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki Blog Search Turing Chat Room Members
Creating shooting star effect       Author Message
Neja Posted: 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    Andy Posted: Sun Jun 15, 2003 3:07 pm   Post subject: (No subject)

just put cls after ur gatch statement  Posted: 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 Posted: Sun Jun 15, 2003 3:21 pm   Post subject: (No subject)

isn't there a echo u can do or somethin? Neja Posted: 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 Posted: 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 Posted: 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)  Posted: 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    krishon Posted: 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 Posted: Sun Jun 15, 2003 3:59 pm   Post subject: (No subject)

oh!
Thanks !!!!!!!!!!!  Homer_simpson  Posted: 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  Posted: Sun Jun 15, 2003 10:13 pm   Post subject: (No subject)

I think that needs a little bounce Homer 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 Posted: Mon Jun 16, 2003 9:29 am   Post subject: (No subject)

ya krishon ya there is setscreen("noecho") krishon Posted: Mon Jun 16, 2003 9:46 am   Post subject: (No subject)

that's the one Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First        Page 1 of 1  [ 14 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: