how do i make a loop or array to choose between different color[]? (csharp)
im new to c# so i dont know a whole lot, but im trying to do something with my version of snake.
So what i want to try to do is, essentially i want to add in a way to choose between different color combinations for the tail, i.e: like the different colors of different irl snakes as a cool little feature
this is my code that i added to the post for the game.
this is the code for the color of the snake tail currently
nothing special lol
this is the draw code for the snake
i have a gamestate that i was starting to work on that i would have the skin selector active, in which you could swap through and choose different color combinations to use.
basically, how would i go about adding support for this, or what code would i do to do so?
I imagine that it would involve either a Color[] array of each combination of colors, maybe an array for the picker? otherwise i dont really know what i would do. Again im still learning, so my code probably isn't the best, or my thinking/logic is post likely wrong, via how i would have to do this. But if youre able to help, then that would be super helpful. let me know 🙂
4 Replies
You would read the
tailColorList
from somewhere, like the gamestate for example, sure
In the initialize, instead of hardcoding the color list, you would pick thathow could it be done though?
Actually, could probably do it as late as
InitGamePlay
Looking at your code... you'd have something like
and use that _tailColors
instead of your tailColorList
Basically, store the skin in a field, then in the skin chooser set the value of that field
And when drawing the snake, pick the colors from that fieldOk I’ll try after work
The thing that I’m worried about or know I’ll have to figure out too is
Which I’m sure I’ll have to do it in the game state or draw?
Is that I’m sure I’ll have to link said skin chopper in a picker scroll system
Which idk how I would do that
I’m sure I can figure it out once I add or get the above code added successfully