Static class member variables

Started by
5 comments, last by Alimonster 22 years, 5 months ago
Hi there! I''m wondering if there''s anything to compare with "class function" for member variables, like with "static" in C++ or Java. The closest I''ve managed is variables after the implementation part, like this: unit something; interface type TSomething = class protected class function GetMyVar: Integer; public end; implementation var FMyVar: Integer = 0; // the static variable class function TSomething.GetMyVar: Integer; begin Result := FMyVar; end; end. The class function is for descended classes. Of course, because the variable is declared after the implementation section, it can''t be seen outside the unit without such a function. You can make a public property to access the variable if that''s what you want. This method works fine, and I haven''t run into any problems with it, but I just wondered if there was a specific keyword for this. Alistair Keys My web site (due for an update sometime soon, including more demo effects and cleaned up code, plus better tutorials) "There are two kinds of people, those who finish what they start and so on." -- Robert Byrne
Advertisement
I think your solution is the best way to implement static members of a class since Object Pascal has no support for them.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Nice website and demos, Alistair. I''m impressed.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Thanks very much! I''m currently trying to convert a company near me (Visual Sciences Ltd.) to using Delphi for games. Looks like I''ve convinced at least one of their programmers. Here''s a recent email to me. It''s probably a breach of copyright, but what the heck!

----- EMAIL CONVERSTION NOW-----

Hi Alistair,

Sorry for the delay, but I''m catching up on holidays just
now, since it''s been a hectic summer here :-)

> Sorry to keep hassling you, but this was a real find! I''ve
> spotted a 3D
> engine thingy using Delphi, and it looks fantastic. The link is
> http://www.fistofbenztown.de/. Check out the screenshots.

That''s really impressive! I''ll maybe have to install Delphi and have a play with it to see what it can do. I suppose in reality it''s not much different from using MS Visual C++ as we do here, just that you''re writing Pascal instead.

There''s no reason why a successful game can''t be written with Delphi, and having seen the examples I''d bet there are a few pretty good ones already out there. It''s probably a better option for the "back bedroom programmer" than paying huge amounts to Microsoft :-)

> P.S. This is the last email I''ll bother you with, honest!
> Just slap me
> until I go away

LOL - it''s no bother really. It''s always good to have people interested in games development, and most games companies are looking for people who are keen on gaming as much as they''re looking for talent and ability.

If you find any more good Delphi links or examples, please
send them along - it looks like an area we should definitely
be paying more attention to.

Cheers,

David


"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne
Have you directed him to Age Of Wonders and Seige Of Avalon yet?

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Of course! I wouldn't be much of a Delphi evangelist if I didn't . This is a list of all the sites I've recommended:

Turbo, DelphiGamer, Siege of Avalon, Age of Wonders (they're working on a sequel just now, I think), Delphi3D, Delphi-JEDI project, Jan Horn's Sulaco, Jake's Efficiency Code Challenge thing, OptimalCode.com, that Fist of Be...etc , and last but *not least by any means at all, and I'll kill anyone who disagrees*... my site .

*Wheeze*, almost out of breath. I also sent him my second demo effects release, but that probably scared him off!

In fact, I think the only lot I haven't mentioned to him yet is... Krome Studios. Whoopsie!

Alistair Keys

P.S. I've updated my site a bit since the mention on Turbo

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

Edited by - Alimonster on November 15, 2001 6:26:22 PM
Krome Studios has done one game in Delphi, but they weren't Krome Studios than. That was a few years back when they were Gee Whiz Software. The game was Zombie Wars, a Halloween Harry sequel.

Krome's current games are done in Visual C++ with tools done in C++ Builder.

"There are three kinds of people in this world: those who can count, and those who can't." - Anonymous

Steve 'Sly' Williams   Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

Edited by - sly on November 18, 2001 5:48:01 PM
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement