Hard Light Productions Forums
Off-Topic Discussion => Programming => Topic started by: CommanderDJ on August 20, 2010, 09:59:23 am
-
Can anyone link me to some good C++ exercises? I've found that I'm learning stuff pretty quick and I want to put my skills to the test. Thanks!
CommanderDJ
-
http://www.cplusplus.com/
^Invaluable resource. Exercises? Learn I/O libraries to make a program spit out a text file - that's a great higher-level exercise to delve into. :)
-
Thanks! I will get into that.
-
There's also this entry-level challenge on the SCP Mantis (http://scp.indiegames.us/mantis/view.php?id=2224).
-
You might find the attached interesting/challenging.
[attachment deleted by ninja]
-
There's also this entry-level challenge on the SCP Mantis (http://scp.indiegames.us/mantis/view.php?id=2224).
What do you mean by entry-level challenge?
EDIT: Like, I get what it is, but does this have possible implications for future involvement for whoever solves it?
-
Only if you want it to be. The point is that the solution for that problem is easy enought to implement for new guys.
-
Coming from an engineering background, and having spent more time around CS students and algorithms competitions than I'd care to admit, I'd suggest that programming is only a small part of the puzzle.
A larger part of the puzzle is thinking about the algorithms that you're trying to implement.
http://uva.onlinejudge.org/ (http://uva.onlinejudge.org/) is a collection (and automated judging system) of problems from the ACM ICPC finals, and they do range in difficult from solve on an envelope to 'ask someone at Google'.
I suggest trying to work your way through them - you will learn more about programming by doing that than by just writing up classes that do very simple operations.
-
There's also this entry-level challenge on the SCP Mantis (http://scp.indiegames.us/mantis/view.php?id=2224).
I decided to give it a go, how does this look? (see attached alphacolors.zip, not sure how to create .diff or .patch in VC). In the UI white should change to black and blue should change to red.
As requested in mantis, it looks up colors.tbl and changes whatever colour specified. But you will need to specify all three colours if you do.
Some notes:
- You can only change the colours specified in *Color_netplayer[]
- Parsing is based off existing parsers such as in ship.cpp and ai_profiles.cpp
- New array for the colour names, *Color_names[], will match what is written in the table, and should correspond exactly with *Color_netplayer[]
- New constant #define NUM_COLORS 20, so the arrays can be used in loops
- gr_init_alphacolor() is done twice on whatever custom colors specified in table, it worked for me but I don't know too much about what it does (if it works on different machines etc.)
- Is the string concatenation adequate? (I learned C++ skipping C)
[attachment deleted by admin]
-
Didn't notice this until now. I'll take a look at it today.
EDIT : To be honest I'd have been tempted to move all the hardcoded colours to Def_Files. Not entirely sure about your string handling either. Might want someone more used to it to double check it too.
-
Ok, well I was aiming to modify only one file (set by taylor in mantis). And I guess NUM_COLORS would also be better off in alphacolors.h anyway. Ill make some changes as to what you suggested (didnt notice def_files before, still new to the fs code) Will edit this post when I'm finished making changes.
EDIT: Done. 3 files now changed: alphacolors.cpp, alphacolors.h, and def_files.cpp
Changes:
- Tweaked parsing a little (use strncpy first then strncat)
- New function void parse_colors_tbl(char* filename) to do the tbl parsing, again with coding and comments
stolen borrowed from ai_profiles.cpp - Default table stored in def_files.cpp as Default_colors_table, still for netplayer colors only
- Black and light pink are still initialized manually, since they don't exist in Color_netplayer[]
- alphacolors.h updated to reflect changes
Unlike the previous solution its a bit less efficient (loops through the color_netplayer array for each entry in the default table). Does this matter too much?
[attachment deleted by admin]