Advertisement

VB vs C++

Started by January 05, 2001 02:50 PM
25 comments, last by DirectX 24 years, 1 month ago
quote:
Original post by Lamtd
also, anon poster, Java doesn''t have any of these features either (except multiplatform), and still a lot of people are using it (and making great things with it). But then again, that was only your opinion, so...



You are right, and that''s a reason I don''t use it. As for people making great things with it, that is true to. But that doesn''t mean that it wouldn''t be easier to make great things with a different language. IE, I personally would rather not have to rewrite a linked list class for every data type I want to use it with. And yes, this is my opinion.

quote:
Original post by Lamtd
btw, did you ever port any of your C++ programs to a different platform ? I mean, a portable language is cool, but how many of you really uses this feature ? Do you separate the platform-dependent and platform-independ code in your programs ? That means of course, not using any API call in any of the main loops.



Absolutely. I make sure all of my normal C++ code runs on both Windows and Linux. I don''t use any unnecessary Windows API calls (ie, I wrote my own image file loader rather than use the Windows functions), and all platform specific code is compiled in their own static library and mapped to a generic class that can be used for any platform.
Hehehe no program loop eh? So it only updates the screen once and then bails?

Ah yes, a Timer proc, polling is much better than event driven software &ltsarcasm&gt. Oh wait you said Timer event? that means windows is sending your messgage pump (a program loop) a message to tell it that the timer expired.

Oh a lighter note, try not to be so arrogant, and I won''t be so sarcastic.

Also, DirectX was not written in VB, sooo if you use directx you''re kinda cheating.

And last time I checking, VB didn''t have an __asm keyword, so I can''t understand what you could possibly mean by code optimization... unless you mean your VB code doesn''t completly suck like most peoples (mine own inclusive).

On an Athlon 600 with one of those 32Meg 3D cards, you *should* be able to repaint the entire screen at about 1000Hz (or as fast as the monitor can go anyway). So if you''re having problems with ~200x200 pixels, you got problems

quote:

Does anybody have comments about my idea(noon-loop program)?


Yes, it''s a dumb idea & you presented it very poorly. You should have asked "Is it possible to write a game without a loop?" And people would have just said no.

You could create a true timer proc in C, but that''s not a viable option to run the game by. (or any program for that matter).

...
VB does support polymorphism, it does have objects and you can derive from them (single no multi).
Even VBA supports polymorphism
The one thing VB is, is polymorphic, that variant type is funny thing and the Object type really is a reference which is like a pointer...

- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
quote:
Original post by Magmai Kai Holmlor
try not to be so arrogant


I''m sorry if anyone considered me arogant.

I practically realise that I do have a program loop. Anyway, it''s a bit different from a normal program loop :D . What I mean is that my engine blits the screen and then it
quote:
bails out
. I mean that it waits for a key to be pressed, creating a 0 FPS when waiting. In a normal program loop, the screen is blitted as fast as possible, when in here it just gets blitted every time a key is pressed. I repeat, a demo will be launched soon and you will see that it is actually pretty fast.

And another question: is the Timer Event slow to use?

A wise man said: " VB rules!!! ".


quote:
Original post by Magmai Kai Holmlor
try not to be so arrogant


I'm sorry if anyone considered me arogant.

I practically realise that I do have a program loop. Anyway, it's a bit different from a normal program loop :D . What I mean is that my engine blits the screen and then it
quote:
bails out
. I mean that it waits for a key to be pressed, having 0 FPS when waiting. In a normal program loop, the screen is blitted as fast as possible, when in here it just gets blitted every time a key is pressed. I repeat, a demo will be launched soon and you will see that it is actually pretty fast.

And another question: is the Timer Event slow to use?

A wise man said: " VB rules!!! ".




Edited by - DirectX on January 6, 2001 9:25:27 AM
The timer event isn't "slow", but it isn't fast either. It's inaccurate and has a very low resolution compared to the multimedia timer that the API gives you access to. Instead of using a timer control and it's 'Timer' event, you should use an API timer:
in a BAS module:Declare Function GetTickCount Lib "kernel32" () As LongDim EndTime as LongDim StartTime as LongDim DeltaT as LongSub Loop()Do While DoEvents    GameMainLoopSub GameMain()EndTime = GetTickCount()If bInWindowedMode Then ' if the app isn't fullscreen     If (EndTime - StartTime) < 40 Then          Exit Sub     End IfEnd ifDeltaT = EndTime - StartTimeStartTime = EndTime.. ' do drawing here.End Sub  

That'll result in much more efficient looping then a timer can provide. Also, before it checks the time, it looks to see if we're in windowed or fullscreen mode (well, replace my little boolean variable with whatever you use to tell you that). If you're not in windowed mode, you don't need to give the GDI a slice of the draw time, so you don't need to wait, you can just draw at every iteration. Otherwise, you'll slow the system down to a crawl.

edit:
Also, if you don't draw the screen at every iteration, it'll become corrupted.. and how would the player see ambient movement (like NPCs wandering around or animating tiles)?

Edited by - Marc SRS on January 6, 2001 9:43:01 AM
-Marc-SiliconReality Software-http://www.blackenfall.org
That''s a good example, but can you make it to run somewhat slower? I mean, can you set the interval(the Timer event has this property). I have decided to launch a version over the next few days, after I have solved the problem.
Advertisement
A-yup.. hehe.. just change the line:
If (EndTime - StartTime) < 40 Then 

to read:
If (EndTime - StartTime) < REFRESH_RATE Then 


and declare this at the top of your BAS module somewhere:
Public Const REFRESH_RATE = 40 '' Refresh rate in milliseconds. 


You can change REFRESH_RATE to however many milliseconds you want between each iteration while in windowed mode.

If you need any other help feel free to ask.

-Marc
-SiliconReality Software
-http://www.blackenfall.org
-Marc-SiliconReality Software-http://www.blackenfall.org
Er, one more thing.. here are some functions that most people apparently don''t know about in VB:

ObjPtr() - Returns a pointer to any object.
StrPtr() - Returns a pointer to a string.
VarPtr() - Returns a pointer to a variable.

Using them is a walk on the unsupported side as they are totally undocumented (and are on their way out--they have been removed from VB.Net).

-Marc
-SiliconReality Software
-http://www.blackenfall.org
-Marc-SiliconReality Software-http://www.blackenfall.org
Thanks Marc SRS, you are by far the one who has supported me the most. I am now working on my isometric engine(as I said), but I have problems. I blit the character onto the map, as I said, but I have a problem, refreshing the map. So far, my program reblits the map, but I don''t want that to happen, I''m working on something to reblit only the tiles that have been affected.
Well, here''s a "theory", I''m not sure quite how this would work (considering it''s 7am and I''ve been up for 5 minutes). You could try marking all tiles in whatever you use to store their information in memory as "clean" when they are first blit, and then when the player moves, calculate what has been affected by the move and mark those tiles as "dirty". Then, in your render loop, only redraw the tiles marked dirty. I''m not sure if that would work.. like I said it''s early.. hehe..

-Marc
-SiliconReality Software
-http://www.blackenfall.org
-Marc-SiliconReality Software-http://www.blackenfall.org

This topic is closed to new replies.

Advertisement