|
-
Feb 16th, 2010, 11:27 AM
#1
Thread Starter
PowerPoster
[VB6] - i nee some code advices
how many more controls i put in my game, more slow will be
the problem is my control code
what i need is sugestions for don't use so many processing power.
(here a text file for show something that i belive is slowing the pc)
and anotherthing i have 1 timer(with 1 ms) for catch the key down event(for avoid the delay).
the text file is for show you how i do the colision test. some of i need update(for avoid the Extender object).
can anyone advice me?
thanks
Last edited by joaquim; Mar 17th, 2010 at 04:23 PM.
-
Feb 16th, 2010, 12:12 PM
#2
Re: [VB6] - i nee some code advices
It might be the low Interval value of the Timer, causing the overhead to the CPU....!
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 16th, 2010, 12:28 PM
#3
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
 Originally Posted by akhileshbc
It might be the low Interval value of the Timer, causing the overhead to the CPU....!
in these event what is the minium that you advice me?
-
Feb 16th, 2010, 06:20 PM
#4
Re: [VB6] - i nee some code advices
A couple of ideas to speed things up.
1. Unless you need to test collisions with multiple controls, Exit the loop after you find a collision and raise the event.
2. You have the following code deep in your IF statements. Suggest moving it closer to the top so you are not wasting time calculating position for a control you won't be testing
Code:
If IsControlArray(ctlTemp) = True And IndexControlArray(ctlTemp) = -1 Then
'do nothing
3. Your CollisionPrecise function may be able to be optimized too?
If you are calling this every 1 ms, it may be overkill. You should cache and check whatever values/variables you are using to determine when a collision should be checked. Only do the collision test when those variables change values.
-
Feb 16th, 2010, 06:42 PM
#5
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
1. Unless you need to test collisions with multiple controls, Exit the loop after you find a collision and raise the event.
- i try before, but don't give me the right control. the control can stay in a picturebox, but stills in form too. that's why i give up from exit loop
2. You have the following code deep in your IF statements. Suggest moving it closer to the top so you are not wasting time calculating position for a control you won't be testing
Code:
If IsControlArray(ctlTemp) = True And IndexControlArray(ctlTemp) = -1 Then
'do nothing
i don't thot in that way, but thanks
3. Your CollisionPrecise function may be able to be optimized too?
-honestly i don't know, but i will see it
If you are calling this every 1 ms, it may be overkill. You should cache and check whatever values/variables you are using to determine when a collision should be checked. Only do the collision test when those variables change values.
- the colision test is only call, if the move event is activated(or when i change the control size, when i show a new image).
LaVolte, what can you tell me about variable types?
-
Feb 16th, 2010, 06:48 PM
#6
Re: [VB6] - i nee some code advices
 Originally Posted by joaquim
1. Unless you need to test collisions with multiple controls, Exit the loop after you find a collision and raise the event.
- i try before, but don't give me the right control. the control can stay in a picturebox, but stills in form too. that's why i give up from exit loop 
I don't understand, if you know you have a collision, why not exit the loop since you know what control you collided with?
 Originally Posted by joaquim
LaVolte, what can you tell me about variable types?
What do you mean exactly?
-
Feb 16th, 2010, 07:00 PM
#7
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
I don't understand, if you know you have a collision, why not exit the loop since you know what control you collided with?
i understand what you mean, but think in these way:
your control is in a picturebox, but colides with other control. in these case your control colides with 2 controls. and if i put the exit loop i recive only 1 of them(but i don't need the picturebox).
that's why i can change my control colision list
What do you mean exactly?
-what can you tell me about variable types?
i know that variables types use memory. what i need is use less possivel memory.
thanks
-
Feb 16th, 2010, 07:53 PM
#8
Re: [VB6] - i nee some code advices
Ok, looking at your code a bit more closely and assuming you cannot exit the loop sooner (which is what you want to do if you can figure it out), there may be some other optimizations you can make.
What is lngOldPosX & lngOldPosY?
Are you moving your control during the CollisionPrecise function?
The reason I ask is that you calculate L1 & T1 before your loop starts and are recalculating them in your loops. If your control is not moving during the ColisionTest function, you should not have to recalcuate the position/dimensions.
Are you sure this is the function that is taking so much time? How many controls are you collision testing against? Unless you are collision testing against 100s of controls I would not think your function is the slow-down.
Regarding variable types. Bytes=1 byte, Integer/Boolean=2, Single/Long=4, Date/Currency=8, Variant=16, Strings=6+2*Len(String). Arrays use 16 + 8 bytes (per dimension) more bytes for each variable type. But unless you are creating 1000s of variables, I doubt these are the problem -- images & windowed controls will use more memory.
-
Feb 17th, 2010, 06:24 AM
#9
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
What is lngOldPosX & lngOldPosY?
these variables is for change.
Are you moving your control during the CollisionPrecise function?
The reason I ask is that you calculate L1 & T1 before your loop starts and are recalculating them in your loops. If your control is not moving during the ColisionTest function, you should not have to recalcuate the position/dimensions.
i must calculate, because, by tests, can give me round resolts. but with new changes i will see it
Are you sure this is the function that is taking so much time? How many controls are you collision testing against? Unless you are collision testing against 100s of controls I would not think your function is the slow-down.
honestly i simply don't know
but how many controls i put in game more slow can be
Regarding variable types. Bytes=1 byte, Integer/Boolean=2, Single/Long=4, Date/Currency=8, Variant=16, Strings=6+2*Len(String). Arrays use 16 + 8 bytes (per dimension) more bytes for each variable type. But unless you are creating 1000s of variables, I doubt these are the problem -- images & windowed controls will use more memory.
in stoped controls(controls that don't move), these variables aren't created.
i will do the changes and test it. thanks
-
Feb 17th, 2010, 02:23 PM
#10
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
in my control i'm using vb6 timers. these timers can block or slow very the cpu?
-
Feb 18th, 2010, 03:54 PM
#11
Thread Starter
PowerPoster
Re: [VB6] - i nee some code advices
finally i resolve the problem
LaVolpe let me ask you 1 thing: very api timers(2, in these case) working in same time, interval diferent, they can "crash"(give problems)?
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|