help with lag

BlitzPlus Forums/BlitzPlus Programming/help with lag

fallegon(Posted 2014) [#1]
So I have a ton of variable in my game and its slowing down.. is there anyway to speed things up or maybe a different way of programming that will accomplish the same thing without using so much computer mem. Now all my variables are just plain (global playerx = 1) type of thing. will changing the type of variable make a difference?


Midimaster(Posted 2014) [#2]
how long ist your code really? How many variables do you use?

I cannot believe, that using a lot of variables slows down your computer and I would search for another reason....

Did you already check the millisecs() you need for one main loop?

Repeat
     time%=Millisecs()
     ; your code here
     ; .....
     Flip 0
     Debuglog Millisecs()-time
Until KeyHit(1)


In may cases the loading of files during main loop causes timing problems...


fallegon(Posted 2014) [#3]
I just typed that in and Im getting around 20 to 40 per loop.. Now when I first started this program I didnt have a graphics guy so all my graphics were made before the main loop starts do you think by taking all that out and using actual graphics files will help?


RemiD(Posted 2014) [#4]
I don't think that having many variables will slow down the game, except if the total size exceed the ram size.
A slow down can also be caused if the program searches in huge lists.

Post an example, we can't guess what you have written in your code.


do you think by taking all that out and using actual graphics files will help?


If the images have the same width, height, and use the same blend mode, it will be the same.


Midimaster(Posted 2014) [#5]
you should use my DEBUG idea in YOUR main loop, not as a stand alone code!

So if you did that in your code 40 msec is a lot but not too slow. You did write nothing about the size of your game. How many lines roundabout? How many graphics? What size have the big ones? Do you use sounds? how big are the big ones?

Can you publish here the main loop? I will have a look on it... And write you some ideas about measuring time.


fallegon(Posted 2014) [#6]
Well Iv been doing some experimenting and it seem the more instances of text I use the slower the program starts to run. The the reason Im posting my main loop is because it just pulls from functions and I know its not a programming fault is because my game works fine on one computer and slower on others. my friend has 16 gigs ram and it still didn't run as fast as I would like it. So I guess my question would be does Text play a role in it because thats the only thing I havent checked yet.


edit: sooo Im guessing its taking too much time to text and load all text during one loop thats why its lagging. Im in the prosses of removing all Text from the code so that its cleaner.


RemiD(Posted 2014) [#7]
If you are talking about the function Text(), what you can do is "predraw" your text on an image, and each frame draw the image, and only "redraw" the text on the image when it changes. This will be faster to render.


Midimaster(Posted 2014) [#8]
what means "load all text"?


fallegon(Posted 2014) [#9]
Yeah most of my types like bullets and enemy ships didn't have images to go with them so I just used the Text command to quickly continue without having to use images. I see now that it wont work in the long run, it takes too much time to render. Thanks for trying to help. If there are any other noob mistakes Im making Ill let you know.