GPWiki.org
GPWiki.org
It is currently Fri May 24, 2013 4:12 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Apr 23, 2011 4:44 pm 
Prolific Poster

Joined: Sat Apr 23, 2011 4:39 pm
Posts: 15
i'm build 1 control(Sprite2D) for be more easy building games in VB6. these control works fine, but my collision sub is very slow(depending on how many controls i'm suing).
see these code:
Code:
.........................
ElseIf ColisionObjectList = ObjectListColisionAutomatic Then
       
        With Extender
            If ColisionDetectType = ColisionDetectionManualy Then
                L1 = .left + LimColLeft
                T1 = .top + LimColTop
                W1 = LimColWidth
                H1 = LimColHeight
            Else
                L1 = .left
                T1 = .top
                W1 = .Width
                H1 = .Height
            End If
        End With
        For i = 0 To UserControl.Parent.Controls.Count - 1
            QueryPerformanceCounter 1
            If UserControl.Parent.Controls(i).Name = Extender.Name Then
                'do nothing
            Else
                If TypeName(UserControl.Parent.Controls(i)) = "Sprite2D" Then
                    If UserControl.Parent.Controls(i).ColisionDetectType = ColisionDetectionManualy Then
                        L2 = UserControl.Parent.Controls(i).left + UserControl.Parent.Controls(i).LimColLeft
                        T2 = UserControl.Parent.Controls(i).top + UserControl.Parent.Controls(i).LimColTop
                        W2 = UserControl.Parent.Controls(i).LimColWidth
                        H2 = UserControl.Parent.Controls(i).LimColHeight
                    Else
                        L2 = UserControl.Parent.Controls(i).left
                        T2 = UserControl.Parent.Controls(i).top
                        W2 = UserControl.Parent.Controls(i).Width
                        H2 = UserControl.Parent.Controls(i).Height
                    End If
                    API_DoEvents
                Else
                    L2 = UserControl.Parent.Controls(i).left
                    T2 = UserControl.Parent.Controls(i).top
                    W2 = UserControl.Parent.Controls(i).Width
                    H2 = UserControl.Parent.Controls(i).Height
                    API_DoEvents
                End If
                strName2 = CStr(UserControl.Parent.Controls(i).Name)
                If IsControlArray(UserControl.Parent.Controls(i)) = True Then
                    Index2 = UserControl.Parent.Controls(i).Index
                Else
                    Index2 = -1
                End If
                If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
                    RaiseEvent Collision(strName2, CStr(Index2), DirDirection)
                    API_DoEvents
                End If
            End If
            QueryPerformanceCounter 1
        Next i
..............

i need speed up these code:(
can anyone advice me?


Top
 Profile  
 
PostPosted: Mon Apr 25, 2011 6:17 am 
Gamer Geek

Joined: Sat Apr 29, 2006 4:22 am
Posts: 33
For/Next loops always slow things down you might want to reformulate the code so it works without using that kind of loop.


Top
 Profile  
 
PostPosted: Mon Apr 25, 2011 7:59 am 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6717
Location: Oxford, Englandshire
Hello and Welcome 8)

I don't know if VBs For/Next loops are slow, but you do need to make sure that there's no unnecessary code going on inside the loop.

There are quite a few calls to API_DoEvents in there. I would imagine that would slow things up quite a bit. Couldn't you call it after the loop has finished?

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Mon Apr 25, 2011 12:08 pm 
Prolific Poster

Joined: Sat Apr 23, 2011 4:39 pm
Posts: 15
Codehead wrote:
Hello and Welcome 8)

I don't know if VBs For/Next loops are slow, but you do need to make sure that there's no unnecessary code going on inside the loop.

There are quite a few calls to API_DoEvents in there. I would imagine that would slow things up quite a bit. Couldn't you call it after the loop has finished?

i tested more, my control, and i have seeing anotherthing. the loop is the best i can do. but my control have 1 api timer control that i found it and i edited. think i these way: you have 50(or more) controls(or index of an array) with animated image, then you have 50 timers, in animation, activated. i'm trying using the api multithread for resolve the problem, but without sucess:(
i know these code is very instable, in vb6, but i'm trying put it to work;)


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 3:07 am 
Octogenarian

Joined: Thu Aug 04, 2011 12:00 am
Posts: 87
Location: Arizona
WOW, I can't believe people are still using VB6! Not a diss, just saying, it's a surprise! Is it possible to run this in compatibility mode on a newer OS like Windows 7? Ah, the good old days... ;) I loved VB6. It was a fantastic version. IMO, it took Microsoft many years to get .NET to work properly. I was really pissed that VB.NET 7.0 did not compile 6.0 code at the time, before realizing it was no longer "Visual Basic" in the traditional sense, but a whole new product with no backwards compatibility other than with the visualbasic6 namespace. Ah, lots of good memories... and lots of money earned for many years doing VB6 dev work full time! ;)

_________________
Amazon Author Page
Game Dev Forum
Facebook Page


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 11:49 am 
Prolific Poster

Joined: Sat Apr 23, 2011 4:39 pm
Posts: 15
twobitcoder wrote:
WOW, I can't believe people are still using VB6! Not a diss, just saying, it's a surprise! Is it possible to run this in compatibility mode on a newer OS like Windows 7? Ah, the good old days... ;) I loved VB6. It was a fantastic version. IMO, it took Microsoft many years to get .NET to work properly. I was really pissed that VB.NET 7.0 did not compile 6.0 code at the time, before realizing it was no longer "Visual Basic" in the traditional sense, but a whole new product with no backwards compatibility other than with the visualbasic6 namespace. Ah, lots of good memories... and lots of money earned for many years doing VB6 dev work full time! ;)

you can do allmost you want with VB6.. well the multithread and multimedia are instable... but maybe the directx can give you more stable(i blive). the .net it's great, but, for me, stells be complicated in some aspects. the controls array aren't used. and more diferent things. and the graphic library is more complicated to use. but my sprite control can do very things;)
for share with you\these forum go to: www.cambalinho.blogspot.com.
there you find 1 nice game build with my sprite control(slow, but works fine;)), 1 code for draw menus and the sprite control;) in time i will share my own apitimer and sound class\control;)
thanks for the time.

Codehead?
what api_doevents\doevents can realy do?(i'm still confuse with these sub)
honestly i need use controls collection and the for/next. but tell more advices, if you can;)
thanks


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 2:14 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6717
Location: Oxford, Englandshire
I'm not a VB'er but DoEvents in other APIs allows Windows to process the event queue. You normally only need to call this once per game loop. Taking out the repeated calls to it should speed up your code.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 9:08 pm 
Prolific Poster

Joined: Sat Apr 23, 2011 4:39 pm
Posts: 15
Codehead wrote:
I'm not a VB'er but DoEvents in other APIs allows Windows to process the event queue. You normally only need to call this once per game loop. Taking out the repeated calls to it should speed up your code.

i need that loop.. i don't use the arrays, like normal games, because i don't know how update it to my control.
thanks for the help


Top
 Profile  
 
PostPosted: Sat Aug 20, 2011 3:58 pm 
Octogenarian

Joined: Thu Aug 04, 2011 12:00 am
Posts: 87
Location: Arizona
Cambalinho wrote:
Codehead wrote:
I'm not a VB'er but DoEvents in other APIs allows Windows to process the event queue. You normally only need to call this once per game loop. Taking out the repeated calls to it should speed up your code.

i need that loop.. i don't use the arrays, like normal games, because i don't know how update it to my control.
thanks for the help




I have some fond memories working on a Star Control clone with a friend back around 1998 or so, way before The Ur-Quan Masters (open source game) was developed. We created a VB6 sprite engine so that you could load up individual frames or a sheet and set the properties then watch it animate, and plug it into the game. There were many limitations, though. I would never go back to VB6, but had a great time with it up until around 2004.

_________________
Amazon Author Page
Game Dev Forum
Facebook Page


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group