I'm making a game and the game loop has a lot of loops in it which are slowing the game down. Does anyone know a way to have the game loop continue while the Loop inside to Game Loop is running?
Printable View
I'm making a game and the game loop has a lot of loops in it which are slowing the game down. Does anyone know a way to have the game loop continue while the Loop inside to Game Loop is running?
paste the other loop code into the first loop instead...
That's what I'm doing.
What I want to do is let the game loop continue while the loop inside it is running.
... you will need two seperate game loops running simultaneously to accomplish this. but the DoEvents you would need to put in both to have it work would defeat the purpose. do what cyborg says and combine them - or make the inside loops VERY SHORT. sorry I can't be of more help.
I think what I need to do is create a new thread, but I don't think I can do that in VB.
hey....your code probably look something like this
VB Code:
While blah 'Some Code While blah2 'Some Other Code DoEvents Wend DoEvents Wend 'Change This to While blah 'Some Code 'Some Other Code DoEvents Wend
if you dont want the other "loop" to run at the same rate, just create a variable and use it to check if its time to do the code!
I know what you mean.
Well, your query to the creating a new thread is allright u can do that by calling the API :
SHCreatenewthread
look it up will u
But what i suggest is that you make movement quantised and not in loops.
For eg. (in ref to mario) :
mario must run with the keyboard movements now an enemy creature is moving across the screen and we need that when mario jumps, the creature must move at its normal rate while mario is in the jump.
If i place all the jump code in one hefty while loop, creature can't move until i have completed the jump. So...... i quantize the jump.
I allow mario to go only one step(depending on speed and gravity) upwards along the jump and with each step i also allow the creature to move, clouds to deform, birds to fly, system to breathe.... etc etc etc !
I think you get the point.
Hope it helps :):):):):)
:D:D:D