kroyee / SpeedBlocks

Fast paced tetris game cloned from Cultris II
GNU Lesser General Public License v3.0
11 stars 7 forks source link

[Discussion] Piece Colors #66

Closed v0ltumna closed 7 years ago

v0ltumna commented 7 years ago

At the moment colors of the pieces are not saved and are (as far as I saw) implemented in a way that make it hard to give every opponent their own colors. I suppose to change the implemantation by adding an array colormap[7] like piecerotation[7] in class optionSet in which a connection between every piece number from 1 to 7 with a color (in rgb values) is made. Such an array should also be added to the class obsField so that it can be different for every opponent. This would lead to some changes in gui.cpp for the options menu and so on, before I dig into this any further I wanted to discuss it.

kroyee commented 7 years ago

The colors should definitely be saved. The colors are actually being stored in the textures class, as an array of different pre-defined sprites with 7 different piececolors + an 8th color for garbage.

If you change your colors this will already be visible to your opponents as they use the same sprite array for colors and the number of the color is transferred to the server and passed on to other players.

This number is also used in the playField class in square[22][10] to represent the color of the current square (0=nothing, 1 = color[0], 2 = color[1] ect.) and in the piece arrays[4][4] to represent the color of the block the piece is made up of.

To save the colors easiest approach I can see with how it currently works is to save it in an array in optionSet as you suggest like: short colormap[7]; and use the same mapping that's already in place through textures.h

This would in addition require that the initBasePieces function in optionSet sets the color values for the pieces accoarding to colormap[7] instead of what's in the predefined array. Also here there is a 1 adjustment, a value of 1 gives color[0] ect.

jefgenowitsch commented 7 years ago

The colour of my pieces isn't saved. When I restart the game, I have to change it again. (as guest)