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.

Dark GDK / 2d Rocket Movement,

Author
Message
Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 5th Apr 2013 04:26 Edited at: 8th Apr 2013 19:04
I have a partial scrolling background with rockets, I am trying to get the rockets to "launch" when they get to a certain point ( I have it at 300 on the X axis for testing purpose ) I have two problems with the code right now that I cant seem to get. The first problem is when the first sprite hits the launch point it starts to launch, but still travels on the x cordinates, then when the second one hits the launch point it seems to get the Y cordinate of the first one and starts to travel from higher up and also travesl the x plane. This is the test code that I have for it..
the sprite i am using is just a quick 32 x 32 bmp i did in windows paint. And i hope i have this all in the code blocks. Thank to all in advance for any help.


test code block

Attachments

Login to view attachments
Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 6th Apr 2013 23:47
Sorry about the code blocks, I have no idea how to use them on this board. I will attach the files to this post, the first post does have the sprite attached.
Again thank you for your time, if someone can walk me through the code blocks i will make sure that kind of post does not happen again

Dave

Attachments

Login to view attachments
Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 11th Apr 2013 02:12
I have made some progress, the rockets now launch at the trigger point, they hold there X values and launch up straight which is what I wanted. The only problems I have now, are the sprites when they hit the trigger point do not get deleted at the launch point but stay showing, not sure why at all, and the FPS is very bad after just a few rockets come out to get launched. This problem I think might be how I am checking the arrays each cycle to see if they are alive or not, but I am not sure about this, since the array just checks a boolian value it should not cause a bottle neck.

this is the code
Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 13th Apr 2013 19:43
I have the code to hide the sprites after they launch, simple call to dbHideSprite fixed it, did not realize that if I called dbSprite after that call it would re " display " the sprite with out calling dbShowSprite.

still no luck at all with the fps problem, does anyone have any ideas to point me in the right direction? I have tryed to eliminate the launch function to make sure it is not my scrolling screen code, and the code for just scrolling seems fine, no issues at all. But when I call the launch function after just a few rockets it lags right out, so I know it is my code. I have tryed dbpastesprite, movesprite, and dbsprite all have the same effect so no gains in speed. so must be my array checking.
Thanks for any help Dave.
Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 22nd Apr 2013 00:59 Edited at: 22nd Apr 2013 13:57
Got the fps problem fixed, was the array checking as far as I could track down. The scrolling stays smooth, the rockets launch at any of the speeds I would want them to, I have only the sprites not deleting when they are past a certain point, i.e the X cord and or the y cord ( think off screen ) so they get "repasted" at their last x's.

Attachments

Login to view attachments
prasoc
10
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Apr 2013 14:24
Is the Launch function running every frame for each rocket? A 10*160 loop each frame per each rocket is a huge strain on CPU


Boca
8
Years of Service
User Offline
Joined: 25th Nov 2010
Location:
Posted: 22nd Apr 2013 20:39
Quote: "
Is the Launch function running every frame for each rocket? A 10*160 loop each frame per each rocket is a huge strain on CPU
"


Prasoc, I have the code run the launch function only under certain conditions, if the sprite exists,if the ARRAY == true and also only ifthe array == number 2, so it is limited in the amount of calls, and after the calls it does a quick check to see if said sprite(s) are still on screen and if so "should" delete them. I say should because in my code I am odviously recalling them some how and as of yet don't see where. The fps is better now, stays at very stable rate of 60, which is what I want.
When I delete the sprites they appear deleted but if I call the spritesX cords, the still go even to - numbers, which should not happen ( I check to see if they are off the screen X cord wise also).
Thank you for the tip, this is the help I am sure looking for.
Dave

Login to post a reply

Server time is: 2019-09-22 03:09:27
Your offset time is: 2019-09-22 03:09:27