
-----------------------------------
dymd3z
Wed Jun 20, 2007 6:40 pm

Moving Asterisks
-----------------------------------
How would I make one asterrisk from the left side of the screen and the right side move towards the middle, bounce off each other and back to the right and left side of the screen? Of course, it's easy to make it shift one way, but to appear as though they bounce off each other, just boggles tyhe mind.

-----------------------------------
Albrecd
Thu Jun 28, 2007 9:14 pm

Re: Moving Asterisks
-----------------------------------
Well, start by using variables to hold the number of spaces before the first asterisx and between the two.
then use for loops to draw the situation.
put the whole thing in a loop that will modify the numbers of spaces.


for i : 1 .. numSpaces
    put " "..
end for


-----------------------------------
Nick
Wed Aug 15, 2007 5:43 am

Re: Moving Asterisks
-----------------------------------
var ast : array 1 .. 2 of int
var changeAst : array 1 .. 2 of int
ast (1) := 1
ast (2) := 80
changeAst (1) := 1
changeAst (2) := -1
loop
    cls
    locate (10, ast (1))
    put "*" ..
    locate (10, ast (2))
    put "*" ..
    ast (1) += changeAst (1)
    ast (2) += changeAst (2)
    if ast (1) >= ast (2) then
        changeAst (1) := -1
        changeAst (2) := 1
    end if
    if ast (1) = maxcol then
        changeAst (2) := -1
    end if
    delay (10)
end loop




well thats pretty much it...
also to make it look like they're actually bouncing and not just travelling through each other you could give each a dif color with colourback(color) right before the put

-----------------------------------
Aziz
Wed Aug 15, 2007 8:16 am

RE:Moving Asterisks
-----------------------------------
Three things, momop:

1) You can use [ code ] tags instead of quotes.
2) Glad to see you helping out
3) Don't do it for him :) Give him hints, tips, pseudo-code, string him along. Believe me, you won't want to after the 50th time doing it 