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 / How do I perform simultaneous actions?

Author
Message
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 15th Apr 2011 21:06
I am close to giving up. I am going nowhere with my program since the skysphere I made doesn't work, and my program is purely linear since I have no idea how to structure, well... anything!

How do I perform simultaneous actions? Example in pseudocode

DO
If upkey is pressed then move object forward
LOOP

DO
If downkey is pressed then move object downward
LOOP

I ask this because my program appears to be confined to a purely linear structure, making me only able to do things in a preset order. This is really frustrating since both my steering and speed control are both controlled by the WAIT 100 delay I put at the end of the function.

Intel Core i5 3.2 GHz, 4 GB RAM, NVIDIA GeForce 9800 GT
Endangered City. An Endangered Species
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 15th Apr 2011 21:13
All the operations should be performed in the main loop. So in your pseudocode:

DO
If upkey is pressed then move object forward
If downkey is pressed then move object downward
LOOP

- Jambo
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 15th Apr 2011 21:19
Well I have a main loop which consists of functions:



And the Functions.dba source file:



I really don't like this, because its a linear only structure, so if I put a wait command in one of the functions the entire program has to suffer since it has to loop that command over and over.

Intel Core i5 3.2 GHz, 4 GB RAM, NVIDIA GeForce 9800 GT
Endangered City. An Endangered Species
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 15th Apr 2011 21:25
Rather than using a wait in one of the functions, use a timer as a delay, e.g.



This would cause MoveSomething() to only execute the move instruction every second.

This is a simple example, but do you see what I'm getting at?

Cheers

Jambo
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Apr 2011 21:26
It's a BASIC language, it's going to be linear. There is no object-oriented design. But I don't see why this should cause you any problems. Why are you putting "wait 100" in your code at all?

The Internet: Where men are men, women are men, and children are federal agents
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 15th Apr 2011 21:28
I put the wait 100 in because I suck at all programming in general. I put it there because I wanted to restrict the amount of time it takes for the speed bar to increase/decrease. Without it the entire program runs at about 4000 miles an hour and the ship becomes completely uncontrollable.

Intel Core i5 3.2 GHz, 4 GB RAM, NVIDIA GeForce 9800 GT
Endangered City. An Endangered Species
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Apr 2011 21:34
sync rate will lock the frame rates, but Jambo's idea is better. Using timer variables to control actions is much better since your game can continue to perform other actions, whereas wait will just pause everything.

The Internet: Where men are men, women are men, and children are federal agents
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2011 22:23
If your ship goes 1,000 times too fast, then divide your movement by 1,000.

Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 15th Apr 2011 22:28 Edited at: 15th Apr 2011 22:31


DarkBasic hates me with a passion.

EDIT: To elaborate the ENDIF's aren't recognised, so I take them out. The ship now will not move at all...

Intel Core i5 3.2 GHz, 4 GB RAM, NVIDIA GeForce 9800 GT
Endangered City. An Endangered Species
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 15th Apr 2011 23:00
There's various forms of if statement, single line and multi line.

IF / THEN is the single line comparison and action

IF / ENDIF is the multi line flavor

eg.


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 15th Apr 2011 23:07
Never mind, I got it.
Now, skyspheres. I made a hollow sphere in 3DS Max, but it looks so tacky and unbelievable. It is also tiny, as when I fly away from the earth then spin around to see it, it disappears from view since the skysphere is set central to the player ship.

Intel Core i5 3.2 GHz, 4 GB RAM, NVIDIA GeForce 9800 GT
Endangered City. An Endangered Species
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Apr 2011 01:44
Try somebody else's first till you get the hang of it, e.g...

http://forum.thegamecreators.com/?m=forum_view&t=178463&b=24

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 16th Apr 2011 11:43
Hey Thistle,

I just noticed something about your ENDIFs that you say don't get recognised. The reason for that is that you are putting a THEN at the end of your IF statement, which is wrong.

There are two ways to use IF...THEN, and here they are:

1)

IF a = b THEN c = 0

In this case the condition and the response is on the one line. You need a THEN in there to delineate the condition from the response.

2)

IF a = b
c = 0
d = 1
e = c
ENDIF

In this case you have several responses to the one condition, spread across multiple lines. You don't use a THEN here.

I'm surprised the code you specified that misused this even compiled, which must be adding to your confusion. I hope this clarifies that for you.

Edit: Oh, Kevin already covered this. <Shrug> I hope it's working for you now

Login to post a reply

Server time is: 2024-09-29 02:33:10
Your offset time is: 2024-09-29 02:33:10