Test to see if it works, and build on top of it in this order:
- Basic Drawing Function
- Basic File Loading Function
- Basic File Saving Function
- Advanced Drawing Function
- Advanced File Loading Function
- Advanced File Saving Function
The best way to improve your program is to rewrite it. I know it's a lot of work, but that's the best way. You probably learned how to make your program while you were writing it, so you'll probably write code faster and cleaner than you did before. Look at your program in a new perspective. How else can you build it?
For example:
Code: Select all
int x = 0;
while(1)
{
ClearScreen();
TextOut(0, 0, "ABCDE", 0);
TextOut(0, 8, "FGHIJ", 0);
TextOut(0, 16, "KLMNO", 0);
NumOut(0, 24, x, 0);
Wait(100);
x++;
if(x >= 100)
break;
}
Code: Select all
ClearScreen();
string szTemp = "";
for(int line = 0; line < 3; line++)
{
szTemp = "";
for(char charidx = (5 * line) + 'A'; charidx < (5 * (line + 1) + 'A'); charidx++)
{
szTemp += FlattenVar(charidx);
}
TextOut(0, line * 8, szTemp, 0);
}
for(int x = 0; x < 100; x++)
{
NumOut(0, 24, x, 0);
Wait(100);
}
Try to strike a balance between all of them.
The first piece of code scores the following [IMHO]:
- File size: Unknown (smaller, in this case)
- Speed: 5/10
- Readability: 8/10
- Maintainability: 2/10
With a few tweaks, the speed could actually score better than the second piece of code.
The second piece of code scores the following [IMHO]:
- File size: Unknown (smaller, in the long run)
- Speed: 6/10
- Readability: 4/10
- Maintainability: 9/10
For example, by just changing a few constants, you can make it display virtually endless variations:
Code: Select all
AB
CD
EF
GH
IJ
KL
MN
OP
Code: Select all
ABCDEFGH
IJKLMNOP
QRSTUVWX
Code: Select all
GHI
JKL
MNO
I recommend you read Code Complete [be sure to get the 2nd Edition, the first is "outdated"], if you want to learn more, and have a better explanation than what I gave you. In fact, I'm still reading it [I've been on Chapter 2 for over an year... -_-' ].