Well, me and Lilith are pretty good at tag teaming here =P
Quote: "
2. What is dbCLS()?
3. Why do you multiply the title by 32?"
2. dbCLS( ) clears the screen to black. The reason for putting it in is because without it there would be a blur added the the levels. Pasted images do not go away, so with that system you need to clear the images before you paste new ones or there could be problems.
3. My drawScene( ... ) function was kinda hacked up because I was doing it quickly. It's certainly not the most elegant, which is the reason the second and third scenes are drawn with basic value like +640/1280. A little more work could be done to make it better, but I just wanted to convey the basic idea.
The reason for multiplying by 32 is because way the data is read is exactly the way the level is laid out. If you look at the data sections;
int area1[15][20] =
{
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 11, 2, 2, 2, 12, 13, 14, 2, 2, 2, 12, 13, 14, 2, 2, 2, 2, 2, 2, 2 }
};
So, if going across the first data section is the top of the screen, the first 20 values Y are multiplied by 32, but since the loop is still y == 0, it gets a 0 returned for position. The X loop, however, is still getting incremented, so each loop iteration is spitting out 0, then 1, then 2, etc. When these values are multiplied by 32, it generates the proper coordinates for the images.
Thus, the first data value coordinates are 0,0, the seconds are 32,0, the third are 64,0 etc based on the loop iteration.
The next 20 values will have had their Y loop iteration increased, so while the X values will follow the same pattern( 0, 32, 64, etc ), the Y loop, now at value 1, will generate 32.
Hope i explained it well enough, let me know =P
Quote: "4. Now this is to do with coding games in general, i've been making classes like how you do in a business app and its own methods like void Level1::setUp(); with its constructor ect but don't think thats correct now after looking over your code (bishop) and also the tutorails where they don't make classes and use extern varibles. Which is better or which is the standard?
"
I am a huge proponent of classes, the reason I didn't use them in my code was because classes require extensive testing to make sure they're being coded properly. The example I made up only took 15 minutes, so I didn't take the time to make a player or level class.
I would certainly suggest you do, however, or use structs. They would both work.
Cheers!
Tux is my guildmaster.