Computer Science Canada Moving Asterisks |
Author: | dymd3z [ Wed Jun 20, 2007 6:40 pm ] |
Post subject: | 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. |
Author: | Albrecd [ Thu Jun 28, 2007 9:14 pm ] | ||
Post subject: | 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.
|
Author: | Nick [ Wed Aug 15, 2007 5:43 am ] |
Post subject: | Re: Moving Asterisks |
Quote: 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) <= 1 then changeAst (1) := 1 end if if ast (2) >= 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 |
Author: | Aziz [ Wed Aug 15, 2007 8:16 am ] |
Post subject: | 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 ![]() |
Author: | Nick [ Wed Aug 15, 2007 8:22 am ] |
Post subject: | RE:Moving Asterisks |
lmao thanks 1) i didnt see it... can i just replace the [quote/] with [code/]? 2) no problem glad to help 3) lol ill keep that in mind the next time so it wont reach the 50th ![]() |
Author: | Aziz [ Wed Aug 15, 2007 8:40 am ] | ||||
Post subject: | RE:Moving Asterisks | ||||
Yeaup, the code tags are what you use:
or even syntax tags:
|
Author: | Nick [ Wed Aug 15, 2007 8:43 am ] | ||||
Post subject: | Re: Moving Asterisks | ||||
|
Author: | Aziz [ Wed Aug 15, 2007 9:28 am ] | ||
Post subject: | Re: Moving Asterisks | ||
Okay, now actually helping: I think the best idea is for you to have two variables, each one holding the x position of one asterisk. Then, draw each asterisk at it's respective x value. Next iteration of the loop, increase the x value by a number. I would use a variable to store this number. When you notice that this move will bring it close to the opposite asterisk, negate that move value. Something like this:
Someone check that out and tell me if you can get it to work. |
Author: | Nick [ Wed Aug 15, 2007 9:33 am ] | ||
Post subject: | Re: Moving Asterisks | ||
there were 1 or 2 problrems but i fixed and also the code u wrote makes the asterisks bounce of the wall and dymd3z says Quote: How would I make one asterrisk[sin] 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[sin] mind.
|