Visual Basic For Game Development?

Started by
69 comments, last by ErikLong 23 years, 11 months ago
I think that''s kind of a poor example though. I''m guessing, not 100% sure, here but guessing, that each call to Pset. Grabs the HDC, locks it, changes the pixel, and then releases it.

Noone writing C/C++ code would ever right their code to perform like that, and neither would any good VB developer. I can''t remember the last time I used PSet to tell you the truth.


Of course, I write games in C/C++ so I never use that.

Using the Window''s API I''m sure you could come up with a far faster routine using bitBlt''s , and there is probably other ways to do it as well. Never actually tried to just invert colors myself though, but if I have free time, I''ll see what I can come up with.

Most of the reason behind VB being slow is people not knowing how or when to make use of the API, or just do things inefficiently.

For example to move a control to 100,50 don''t go
control.left = 100
control.top = 50

go

Control.move 100,50

And if you are moving lots of controls, call the winapi deferwindowpos,(something like that) make the calls to whatever the movewindow api command is, and then exiting deferwindowpos command. I''m not going to look up in MSDN right now what the exact calls are, because well, noone cares. But the point is, there are a lot of ways to make VB run faster. And it will run pretty damn quickly if written well. No lie.
Advertisement
Private Sub Invert()    Dim x As Integer, y As Integer    Dim color As Long    ''Show Hourglass    Screen.MousePointer = vbHourglass    ''Make sure that we aren''t using twips    ScaleMode = 3    ''Loop through each pixel    For y = 0 To Picture1.ScaleHeight        For x = 0 To Picture1.ScaleWidth            Picture1.PSet (x, y), (Picture1.Point(x, y) Xor &HFFFFFF)        Next    Next    ''Show the Arrow again    Screen.MousePointer = vbArrowEnd Sub  




------------------------
Captured Reality.
Why don''t you use the API?
Getpixel,Setpixel,GetBitmapBits,you know...
Here these words vilifiers and pretenders, please let me die in solitude...
Don''t use PSET! It''s slow, even MS engineers acknowledge they''ve screwed up with the function.... though have they fixed it in 6?.... Think not... think the problem appeared in 6.

Use DD instead!

-------------------------
-Now Working on Pokemon like Engine!
-------------------------
-Now Working on Pokemon like Engine!
No, they didn''t fix it in 6. That''s what I''m using and it takes 8 seconds to do a small picture.

I thought that since the image isn''t updated until the routine finishes that it didn''t copy it to the hdc until the end.

I just did a speed test between VB and VC++. Here''s the results:

VB code:
Option ExplicitPrivate Declare Function GetTickCount Lib "kernel32" () As LongSub main()    Dim oldTicks As Long, newTicks As Long    Dim cnt As Long, x As Single    x = 100    oldTicks = GetTickCount()    For cnt = 1 To 10000000        x = x / 10        x = x * 10    Next cnt    newTicks = GetTickCount()    MsgBox Str(newTicks - oldTicks)End Sub 

Optimization was set to favor fast code. All error checks where turned off.

Number of ticks: 5238

C++ code:
#include #include int main(int argc, char* argv[]){	clock_t oldTicks,newTicks;	long cnt;	float x;		oldTicks=clock();	x=100;	for(cnt=0;cnt<=10000000;cnt++){		x /= 100;		x *= 100;	}	newTicks=clock();	cout << newTicks-oldTicks << "\n";		return 0;} 

compiled as a Win32 console program. Release version.

Number of ticks:310

Hmmm, I wonder which compiler is faster?


E:cb woof!
E:cb woof!
Oops, I just noticed that the C++ code divides/multiplies by 100 where as the VB code uses 10. I don''t think that''ll affect the results though.

E:cb woof!
E:cb woof!
Whoa, did I kill the topic? Has anyone else tried my code on their computers? How did it work out?

E:cb woof!
E:cb woof!
quote:Original post by The Alchemist

a friend of mine said that carmagedon was made using VB, and i said to him: of curse... and quake 3 was made with FORTRAN...


Of course Carmaggeddon wasn''t made with VB, it''s in DOS!


quote: Original post by Josh
2. VB is a sloppy language. There is no structure and anything goes. It''s *hard* to develop good code in VB... the fact that VB imposes Microsoft''s idea of code formatting on you doesn''t help any either.

Original post by nes8bit

Um, VB is VERY structured. I don''t know what you are talking


Actually, he is correct. I have used VB before it was called VB, and it has the same structure of, imagine this, basic. Giving modules a global space instead of local ones is the biggest problem with sloppiness. You know how much crap that piles on the HEAP (yes, the thing inside the computer called a memory heap). This is not good for business.

I use VB mainly for business applications, and it is far superior in that respect, except when a client wants something run on Apache Server, or a Linux box. It is limited, know its limitations, live with them.

I have tried using VB and DX7 in the past to make a 3d engine, and it worked, imported nice models, displayed BSP''s, but in the end, what did it lack?

Speed. Yes. Its native compiler is great, but it still does not optimize like a C compiler. Dunno why, esp since VC++ has one of the best ones around, you''d think the programmers would talk to each other....strange that.

Size. Waaaay yes. Why should I have a 3.0 meg installer for a 24k program? This makes no sense.

Other reasons. Scripting languages? And, I am sorry, VBScript doesn''t cut it. Can I embed LUA? how bout Python? Not even Java.... well, that is not good.

Honestly, even with outside DLL support, there is a 20% drop in speed between applications made in VB and C++. Yes, I have tested many. 20% sound like a lot to you? it does to me. That is an average, some are 5% some are 35%. Depends on how math intensive.

I suggest leaving VB where it belongs. But, of course, I''ll get the VB fanatics yelling at me about that. Go ahead, I put my time in on vbgaming message board, I talk with the guys over at jaggedsoftware, hell I was one of those guys.

Simply, I know what its problems and gems are. Awesome awesome awesome COM and DB support. $h!77y graphics support (yes that includes DX7 --- and if you have made it work on automatically detecting Voodoo 1 and 2 cards, give me a mail: Amorano otherwise, my point is made.



"Five passengers set sail that day, for a three hour tour, a three hour tour...."
35%? Did you look at the times in my example? It''s over 10 times slower! (1000%)

E:cb woof!
E:cb woof!

This topic is closed to new replies.

Advertisement