Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / My first Dark SDK, C++ app.

Author
Message
Jimmy 9 Toes
19
Years of Service
User Offline
Joined: 15th Sep 2004
Location: 2nd Star to the Right
Posted: 22nd Aug 2005 17:11 Edited at: 22nd Aug 2005 17:12
Ok.
I don't know why, but whenever I get a new languge I have write a program that bounces a bunch of balls all over the screen. Maybe it's a sickness. I've written my very fist C++ application using Dark SDK to bounce a bunch of colored spheres around in 3D space.

http://www.pishlo.net/File-Store/DarkBalls.zip

Could someone take a look at my source code and tell me how I might possibly improve it?

-Jim
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 22nd Aug 2005 17:34 Edited at: 22nd Aug 2005 17:39
With me its bouncing lines
Dont see how the code can be optimised any further - all seems pretty efficient at the moment.

Come to the third DarkBasic Pro Sci Fi Con - Be there and be square
Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Jimmy 9 Toes
19
Years of Service
User Offline
Joined: 15th Sep 2004
Location: 2nd Star to the Right
Posted: 22nd Aug 2005 17:51
Thanks.

I've been a C# developer for a long time, and I'm pretty decent at C. This was my first attempt at an object oriented C++ program.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Aug 2005 19:38
Here are some changes that I'd suggest ...

Throughout your Ball class, you access your member variables with Ball::variable - this is only necessary if you have an argument variable of the same name. If you don't then 'Ball::handle' can be shortened to 'handle' for example. I usually add a trailing underscore to the argument names to avoid this ... others will add 'm_' to the member variables.

Also, different code paths initialise the object in slightly different ways - you can get all of your constructors to call a common subroutine to complete initialisation.



In addition, although it makes no difference to the speed of the code, you probably want to make all of your member variables non-public - it's considered bad style to leave them available for people to bypass your object interface and tread all over them.

Very good for your first try at a C++ class

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Jimmy 9 Toes
19
Years of Service
User Offline
Joined: 15th Sep 2004
Location: 2nd Star to the Right
Posted: 23rd Aug 2005 04:06
Hey wow! Thanks for the valuable pointers. I'll definitely take your advice.

Login to post a reply

Server time is: 2024-04-26 13:05:21
Your offset time is: 2024-04-26 13:05:21