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 / 2D Space Flight Program

Author
Message
Zen Master
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location:
Posted: 25th Nov 2008 20:08
Ok i've spent a lot of time pondering this one until i posted took me forever to get the bullet to fire and go to the top of the screen i just need help to allow the loop below to run at the same time as the main loop.



If you do just wish to tell me the code is written in a poor way or anything like that please dont post, just looking for help on this problem. Thanks for your time guys!




"Face it, if crime didnt pay there would be very few criminals."
Laughton Lewis Burdock
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Nov 2008 21:30
You're very close already.

What I'd do is separate out the firing of the bullet and the moving of the bullet into two subroutines.

The firing part would only be called if your BulletFired variable was set to zero, and if the spacekey is pressed - it would initialise the bullet, and set the BulletFired variable to 1.

The moving part would be called if the BulletFired variable was set to non-zero - it would move the bullet one step only, and if the bullet reaches the top of the screen, would hide the bullet and set the BulletFired variable back to zero.

Here's what I mean:


I used DOT and GET IMAGE because I haven't got your sprites and didn't want to find any - basically, I was lazy

I've also added SYNC ON/SYNC RATE/SYNC commands in the relevant places - this allows the game to run at a fixed rate. There are other alternatives, but you'd be better sticking to this right now.

Zen Master
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location:
Posted: 25th Nov 2008 21:55
Ah! IanM your a champion thank you very much! Had a lot of trouble with this one

The sync rate, is that to stabalize the movement of the sprites?

"Face it, if crime didnt pay there would be very few criminals."
Laughton Lewis Burdock
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Nov 2008 22:06
Yes, it does that, plus it also controls when the drawing of the display takes place. Without it, the drawing will happen whenever DBPro chooses to draw. With it, it will only draw when you call SYNC.

For example, if you had 2 sprites that needed to move together (ship + powerup maybe), and the syncing was controlled by DBPro, you could move one sprite, then DBPro could draw, then you move the next - they'll be out of step, sometimes fairly obviously.

Zen Master
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location:
Posted: 26th Nov 2008 14:07 Edited at: 26th Nov 2008 14:11
Hehe spent a lot of time on this one but having a lot of trouble scoured the forums for hours and tried many a thing, The attached sprite is 2 by 4 grid of 32 x 32 pixels, shouldnt this make the Sprite run from frame 1 to 8 when the enemy is shot?


Appreciate any help this ones been tickling my brain since last night now lol!


Solved this now thanks forgot the Sprite 4,Enemyx,Enemyy,4 command !

"Face it, if crime didnt pay there would be very few criminals."
Laughton Lewis Burdock

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-24 16:26:25
Your offset time is: 2024-11-24 16:26:25