Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Quick Question

Author
Message
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 13th Jul 2008 05:19
Is it possible to have only certain commands in a loop be performed in the loop? For example, having a ball bounce around the screen and have text printed at the same time without having it printed over and over. Tell me if I am being unclear.
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 13th Jul 2008 08:16 Edited at: 13th Jul 2008 08:18
First, don't title your threads with generic text that does not hint at all as to the content of the thread. "Quick Question" could be about anything in the universe, at least put a keyword in there that can be picked up by a search should someone have the same problem in the future.

Second, the question requires more information because there are at least two scenarios that are possible:

A) you are in 2D render mode, which preserves text without erasing the screen each loop

B) you are in 3D render mode, which clears the whole screen every sync

(if you have any 3D objects, you are in 3D mode as DBP automatically switches, if you have no 3D objects, DBP remains in 2D mode until a 3D object is present)

If your scenario is 'A', then you should put your text on the screen before the loop. If your scenario is 'B', you can't avoid putting text on the screen every sync unless you don't want to see it.

As for excluding commands in a loop, you would use conditional statements such as IF...ENDIF or IF...THEN.

example:


You might even be using PRINT, which is not a great idea, you should be using TEXT.

_____________________
Windows Vista: Just say no.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 14th Jul 2008 22:07 Edited at: 14th Jul 2008 22:09
@cguy: Your question is a little unclear. If I'm understanding correctly, you could just use an IF statement within the loop, and then have a variable decide which parts get run. Maybe something like this? (It would be better organized as a SELECT/CASE statement):



cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 17th Jul 2008 02:14
I example I used was way off- sorry about that
What about making two balls of diffrent sizes and rates of speed bounce off the edges of the screen at the same time?
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 17th Jul 2008 03:41
Oh, and I was also wondering how you would go about changing window size, location,etc depending on the input of a player
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Jul 2008 11:45
Well, simply put, you just make them different sizes and give them different movement values for different bouncing speed.
If you want them to go off the screen at the same time whilst moving at different speeds, you would have to do some math to determine where the balls should originally be placed as well.

To change the window size and location, you use the display commands, namely set window size width, height and set window position x, y
To use these with user input, you would first have to get the input.
There are various ways to go about this (if you don't know of any, try searching the forums, or just give it a quick try with input promptText$, retrieveText$).
The issue you might be experiencing could be that most input is retrieved as strings, whereas you need numbers for the input of those functions that you listed.
For these situation, simply use inputValue = val(inputString$).

I hope that cleared something up

"I kören hörs de brummande busarna Björnligan och Gondolen"
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 17th Jul 2008 20:14 Edited at: 17th Jul 2008 20:15
Thanks for the answer to my first question - I just wasn't thinking along the correct logical lines. As for the second question, I realized that I had to put a loop statement around it...

Login to post a reply

Server time is: 2024-11-25 21:32:24
Your offset time is: 2024-11-25 21:32:24