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.

Author
Message
Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 23rd Feb 2010 13:46
My program got lots of images and sprites comming and going, what do u guys think is the best option for me so it runs well and smooth?

Ty
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Feb 2010 13:59
Normally you only have one Sync in your program - at the end of your main program loop. However, it's not uncommon to have more than one loop - like Main Menu screens - and they often need them too.

But, the point is that the Sync command tells DB to refresh the screen with all the changes your program has made so to keep your program running smoothly you should do it at the end of each loop cycle... and use it only when necessary.

TDK

Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 23rd Feb 2010 23:19
Ok ty, and... theres no other way to make it run better? Ty
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Feb 2010 17:07
Also, if you are putting sync at the end of your main loop, make sure you put

SYNC ON

at the top of your program. Otherwise DBPro is syncing in it's own time, and then you are forcing another one.

Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 24th Feb 2010 22:57
Ty, i think that will rly help, the only problem is that for some reason, when i put sync on at the top of my program, my sprites wont appear, idk y... somebody have had this problem?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Feb 2010 23:28 Edited at: 9th Jul 2010 21:29
Try establishing a sync rate for the program to maintain at, like this:

SYNC ON : SYNC RATE 60


Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 25th Feb 2010 00:15
Nope, the same problem =/
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Feb 2010 00:31 Edited at: 9th Jul 2010 21:29
SYNC ON in and of itself will not make your sprites disappear. It simply is a way to make your program run more smoothly, by updating the screen only when it needs to. If you have indeed placed SYNC at the end of your game loop, I would need to see some code in order to help you further.


KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 25th Feb 2010 17:47
If I recall, sprites don't stay between syncs. So if you aren't positioning them every loop, then yes, they will disappear.

Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 25th Feb 2010 23:56
Ok, here is my code, its a little too long, but it may help



Soo, i dont see whats wrong with my syncs, idk maybe u guys know, the only sprite that appears is the 19, all the others dont.
But without the sync on command they all appear normaly, though i would like it to run more smoothly, so... what should i do?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Feb 2010 15:40 Edited at: 9th Jul 2010 21:30
How can you decipher how your code even runs? Not to be harsh, but this is a prime example of why GOTO should not be used. The first thing I would do is get rid of all of them, re-write the majority of code if you have to, but get rid of them all. You need structure to your code. For example, you need one main Do - Loop (or repeat - until loop). From this, you can call the subroutines / functions needed. Normally, you will get user input, move the user, move enemies, move shots, move the background, do collision, etc. and then place a sync just before the end of the loop. I would try to give you some example code using your code, but I honestly can't figure out what you want to do if you say, push the left arrow button, for example.

I would remove the function call to lol() and put a main loop in it's place.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Feb 2010 17:51
LBFN is correct. There's a right and a wrong way to write computer programs - if that is you want to make life easier for yourself.

Unfortunately, your code is a fine example of how to do it the wrong way.

But, if you are new to programming, then you won't know about the right way. With that in mind, check out tutorial 2 here:

http://forum.thegamecreators.com/?m=forum_view&b=10&t=99497&p=0

There may be lots of other info you might find useful in that thread - particularly Tutorials For Beginners Parts 1 to 4.

It might seem a lot of bother for nothing, but believe me, ignore the advice and you'll soon be wishing you hadn't!

TDK

Daryn Alsup
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 27th Feb 2010 00:31
I've had a bit of trouble with sprite - I think we all have - but something that has always helped when I am using sprites up the ying-yang is

sync on : sync rate ...

do
sync
all your code
sync
loop

the reason for the double sync is simple, check going in, check going out. You will find that there will be times when more than one sync is needed.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 27th Feb 2010 10:09
Daryn, that looks a bit wierd, I mean, as the code loops through, you do the following activities in your code:

sync
code
sync
sync
code
sync
sync
... etc etc etc

since there is no updating of any variable states, objetcs, or anything, you are sync'ing twice in a row, taking the performance hit of a double sync

I may well be wrong, but thats how I see it

This is not the Sig you are looking for....
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Feb 2010 17:57 Edited at: 9th Jul 2010 21:31
Quote: "the reason for the double sync is simple, check going in, check going out. You will find that there will be times when more than one sync is needed."


I always put one sync at the end of my main loop. I have never seen a need for a second sync at the start of the main loop in order to display sprites. Sync tells the computer to draw everything to the screen. There is no reason that I know of to do that twice. I agree with Dia, you simply will take a performance hit by doing that.


Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 27th Feb 2010 21:10
Does it matters if my game and sprites r all 2d? or it doesnt have to do with this?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Feb 2010 21:39 Edited at: 9th Jul 2010 21:32
Yitzu,

I believe that your code has been laid out in such a way that the sync is not being executed in a timely fashion. Whether you are using 2D or 3D graphics makes no difference. By using the sync command, you are telling the computer to redraw all of the graphics.

I have taken your code and edited it into a revised version that you can plug in what you want it to do. I hope you can see the benefits of writing a program in a more structured way. You obviously can use subroutines instead of functions if you want.





Please bear in mind that I cannot run this to make sure it is 100% correct because I don't have all of your media.


Yitzu
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 28th Feb 2010 17:19
Ty very much, I rly can learn a lot from this code, ok, ill use all the info u guys gave me, thx everybody =)
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th Feb 2010 20:18 Edited at: 1st Mar 2010 04:32
Yitzu,

I appreciate your good attitude. It is good that you are teachable, as you can develop your skills further. I will be glad to try and help if you need further assistance putting things together.

Good luck,

LB

Login to post a reply

Server time is: 2024-09-28 14:24:45
Your offset time is: 2024-09-28 14:24:45