I have little experience in writing a simple games on XNA, but now i dont have knowns to solve my problem.
So, i want to write simple racing 2d-arcade, and i dont know how i can do maps for this game.
I decided do this so:
I draw a picture-map in mspaint. Black - its grass, white color - its road, red color - road markings, blue - water, green - forest, etc.;
After the image is loaded, I override textures in XNA - on white color i place texture of road, on black color i place texture of grass and etc.
So i have 2 questions.
Sorry for really bad english. And thanks for answers advance.
In MSDN forums, man with the nickname Mad Martin adviced do so:
Draw the final picture in paint with the mixture of textures like you want it on the screen. Draw this texture directly. Now you'r game logic needs to know where the road is in that texture. There are two ways i can think of:
- Make the road a spline and calculate the exact layout of the game. Probably a bit steep for beginners, but the most powerful.
- Make a separate texture like yours with just two colors(black no road, white road). You can then check via the coordinates of the cars whether you are on the road or not. You can do this either on the CPU, by readign the texture into an array with Texture2D.GetData, or you can do this on the GPU. Either way needs a little fiddling around, so your cars dont hang on the edges of the road.
i think that it's quite useful answer, so i close question.