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 / Someone help me please!!!! Looping problems!!!!!

Author
Message
Trizt
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location:
Posted: 13th Dec 2003 22:57
Heya all,
My problem is as follows:
I am making a program and I have two separate loops, one controlling the camera, and one controlling the movement of an object. I really need to know if it is possible to have two separate loops running simultaneously. I would use both codes in the same loop, but after each movement, the object pauses, and I don't want the camera to pause as well.
SOMEONE PLEASE HELP ME!!!!!
thanks,
--Trizt
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 13th Dec 2003 23:02
Post some code in the code box so we can see the problem.
Trizt
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location:
Posted: 13th Dec 2003 23:10
it requires some images to run it, so how do I attach them?
(ive attached the code anyway)
Daris Xiao or Benjy Wright
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: Face first in a bowl of soup.
Posted: 13th Dec 2003 23:15
Only move the object every 3 or so frames by taking out the wait commands and replace them with something like:

wait#=wait#+1
if wait=3 then move object up 1,1
if wait=6 then move object down 1,1 : wait#=0

Then you should be able to put both parts into one loop.
Trizt
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location:
Posted: 13th Dec 2003 23:26
thanks Daris, but I'm very new to DarkBasic Pro so I'm not sure exactly what you mean. If you have time, could you please explain it to me? Thanks.
--Trizt
Daris Xiao or Benjy Wright
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: Face first in a bowl of soup.
Posted: 13th Dec 2003 23:33

Basically,
wait# is a variable.
variables are kinda like a space in the computer where you can store a number.
This number can be changed at any time.

what you're doing when you type this is saying that you want the computer to reserve the space called "wait#" to store your number.
then you are changing it to wait#+1. just adding 1 to wait#.
wait#=wait#+1

Here you are saying that when wait#=3 you want the object to move up and when wait#=6 to move it down.

if wait=3 then move object up 1,1
if wait=6 then move object down 1,1 : wait#=0

Also when wait#=6 it will be changed to 0 so that it can again become 3. Every time your loop runs, wait# will be increased by 1. 1 out of 6 times it will move up, and 1 out of 6 times it will move down. this way the camera will refresh 6 times and the object will stay still then move, stay still and then move...etc.

Do you understand it now?
Trizt
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location:
Posted: 13th Dec 2003 23:36
i think i get it now
thanks a lot Daris
Daris Xiao or Benjy Wright
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: Face first in a bowl of soup.
Posted: 13th Dec 2003 23:38
No Problem,
Please don't leave out my "X" when you use my name...
Happy Programming!
Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 16th Dec 2003 01:30
The OTHER way - the way I'm trying to use is to use a timer for "anything" you manipulate, so things work the same way - using the highest frame rate the computer can do, but still give you the same exact game play - appearance - movement speeds etc. Like rather than figuring if you should move 1, 2 or 3... how about how much per millisec? if 10milliseconds elapsed since the last time thorugh the loop - move the object "ELAPSED MILLISECONDS" * DISTANCETOMOVE

I usually refer to Distance to Move as a SPEED thingy.

By having a loop go through all things you are tracking:




Then in your loop you can move each object, and cam, whatever to its new place - store the info in this type (in an array) the last time ya did it, and have code to decide what its gonna do for each "thing" or Object or whatever.

(Vague... sorta - still trying to get solid codebase with it that's easy to manipulate various numbers of objects without overhead of tracking dynamic arrays or looping through a big hardcoded array that may have empty "slots" during game play....though timing would make game smooth if done this way cause timing code would balance it out)


-=/Jaze/=-
Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 16th Dec 2003 02:55 Edited at: 16th Dec 2003 03:00
here is a code snippet that is the GROUND work I'm building my stuff with. Basically - its a "loop" with timer based motion on it - and its set up so you can use the same array for multilple things... sound, sprite, camera - and apply the same motion (timer based) stuff to all. By adding one more vari to the structure I used - you can make all OBJECTS have a type of their own: iObjType = 1=BAdGuy - do this, 2: Good Guy - do this and even further with animations and stuff.

This snip makes 30 objects - (cubes) and give 1 of them a velocity (and changes the appearance so you'll reckognize it)

Just run this code snipp - and use arrows to turn to the right a little. This snip just has an example of a white box set with a slow velocity.... regardless of computer speed - it will always move the same speed - regardless of framerates!

Try giving them random velocity values for all 30 and you'll see the basis of how I did this:

http://www.wimbleoffice.com/demo1.zip
and
http://www.wimbleoffice.com/xmascard.zip

These have physics applied, and the first one accomplishes bouncing with and without a gravity force. Change direction without any energy absorbtion is simply V=V(-1) or velocity = velocity * -1

Works on all velocity vectors xv#, yv#, zv#

(My understanding of velocity anyways)


-=/Jaze/=-

Login to post a reply

Server time is: 2024-11-25 20:46:41
Your offset time is: 2024-11-25 20:46:41