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 / 3D Starfield, need evaluations... :)

Author
Message
enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 14th Feb 2011 01:39 Edited at: 14th Feb 2011 02:37
I made this program as an excercise as I'm a bit rusty at C++, and I'm not sure if my implementation is "good"...

Basically I'm not sure if I need to delete anything in a Destructor, as I believe VECTOR handles this automatically and I'm not using any dynamic memory...

stars.h


stars.cpp


Am I doing anything wrong here? Are there any bad coding practices here? Any optimizations? Other suggestions?

I have also attached the full project to this message incase you wanna have a closer look...

EDIT: Btw... Is there any "lang=dbp" type tags i can add to the codeblock to highlight C++ code and/or DarkGDK code?

Attachments

Login to view attachments
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Feb 2011 03:05
I downloaded the code to check it out but it won't compile for me. I'm still on vc++ 2008 express.

Warning! May contain Nuts!
enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 14th Feb 2011 03:33
Hmm... So am I...

What kind of error messages do you get?

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Feb 2011 03:57
These... Tried changing the debug libraries... Must be the time of night...



Warning! May contain Nuts!
enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 14th Feb 2011 05:11
Did you ignore the libs: atls and msvcrt?

enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 14th Feb 2011 05:17
Hmm... I can't get it working if running debug mode... try setting it to Release... That works for me...

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 14th Feb 2011 06:04
Quote: "Basically I'm not sure if I need to delete anything in a Destructor, as I believe VECTOR handles this automatically and I'm not using any dynamic memory..."


Yeah that's fine, you only need to manually 'delete' stuff when you use 'new'.


Quote: "Am I doing anything wrong here? Are there any bad coding practices here? Any optimizations? Other suggestions?"


Instead of prefixing all your classes with 'DEMO_' you should just use a namespace called DEMO or something.

Your header guard name doesn't match the header name, you have stars and STAR, so you should really change the guard to STARS, or just use '#pragma once' so you don't have to name them.

You should avoid doing things like 'int hsw = sw >> 1;' it's far clearer to just write '/ 2', and in the case of unsigned types, the compiler may just do this optimization anyway.

Also, your local variable names are pretty poor, it seems almost every one is an initialism, in fact, at a quick glance I'm not even sure what your draw() method's for loop is doing without running it.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 14th Feb 2011 09:06 Edited at: 14th Feb 2011 09:08

you will call draw() in a loop, and in each draw, you will loop through starts and change the ink for each, don't do that! your game will be slow as hell, either find a way to avoid using dbInk in loops, or use an alternative (cloggy's DLL maybe)

enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 14th Feb 2011 14:17
Quote: "you will call draw() in a loop, and in each draw, you will loop through starts and change the ink for each, don't do that! your game will be slow as hell, either find a way to avoid using dbInk in loops, or use an alternative"

Actually knew this...
Just haven't gotten to fix it yet. Was thinking of getting a pointer to the pixels and just do it manually.

Thanks for the tips everyone though... Not as bad as I thought... BTW the code is a bit messy as I was mostly experimenting and changing things around all the time... But still, good suggestions.

Login to post a reply

Server time is: 2024-06-23 03:02:07
Your offset time is: 2024-06-23 03:02:07