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 to implement Threading in DBPro

Author
Message
Kenzenray
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: India
Posted: 1st Jan 2003 15:15
Good Day,

I am an aspring programmer from India. Recently I am greatly interested in DB. I have the trial versions of DB v1.06,v1.13 and the trial version of DBPRO.

I am starting to learn programming with the Space Invaders type game. I have a problem.

I have a sprite ( a spaceship) from which I have programmed a bullet fire sequence from the ship. The bullet fire is also an image(as a sprite). When the SPACEBAR on the keyboard is pressed (Spacekey()), I am using a 'gosub' statement, and showing the bullet sprite and changing its coordinates from ship to move to the top of the screen. This takes the bullet some time, during which I am unable to move the ship. How is it possible to control the spaceship movements during which another operation like firing of bullets or movements of other sprites are happening. Do you have some facility like threading ?

Please help me.
Thank you for kind interest in vieweing my request.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 1st Jan 2003 18:11
Well- it seems like when you are gosubing, it is going directly from the main loop where the ship is. While the code goes to the gosub- it is ignoring all other code. You could try just keeping your commands in the gosub.

If you just have your commands in the gosub for shooting the bullet, you could also include if leftkey() and such move the ship. You could try including that in the bullet gosub and see what you get.

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
k0shi
21
Years of Service
User Offline
Joined: 30th Dec 2002
Location: Cyberspace
Posted: 1st Jan 2003 21:17
you could try placing a loop within a loop.when the space bar is hit you could have the inside loop with the bullet shooting and movement to continue the cycle of movement without it having been inturupted by the bullet.
try this:


What you give is what you get.
.....:::<>-<K0shi>-<>:::.....
Kenzenray
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: India
Posted: 2nd Jan 2003 14:55
It was very nice of you to send a code snippet. Thankyou

Login to post a reply

Server time is: 2024-11-23 20:43:50
Your offset time is: 2024-11-23 20:43:50