(7.10.2018 / 15:15) молодец аннимон 
    Magatino  (Adm) [Off]  
(7.10.2018 / 14:28) Alexandr, 
Показывать то нечего, я же делаю движок для игр, а не саму игру, вот мой упоротый код получения палитры, может кто - нибудь что - нибудь посоветует 
  Открыть спойлер
Закрыть спойлер
public  class  Palette
 
{ 
 
    private  int[ ]  colors; 
 
 
 
    private  int columns; 
 
    private  int rows; 
 
    private  int maxCells; 
 
 
 
    public  Palette( int columns,  int rows)  { 
 
        this. columns =  columns; 
 
        this. rows =  rows; 
 
 
 
        maxCells =  columns *  rows; 
 
 
 
        colors =  new  int[ maxCells] ; 
 
    } 
 
 
 
// rows = 8 по причине того, что всего цветов будет 8, ну типа, чтобы не париться, в будущем напишу, а может прямо сейчас более гибкий метод 
 
    public  Palette( int columns,  int color,  int index0,  int index1)  { 
 
        this. columns =  columns; 
 
        rows =  8 ; 
 
 
 
        maxCells =  columns *  rows; 
 
 
 
        colors =  new  int[ maxCells] ; 
 
 
 
        setPalette( 0 ,  color,  0 ,  index0,  0 ,  0 ) ; 
 
        setPalette( columns,  color,  0 ,  index0,  index1,  0 ) ; 
 
        setPalette( columns *  2 ,  color,  0 ,  index0,  index0,  0 ) ; 
 
        setPalette( columns *  3 ,  color,  0 ,  0 ,  index0,  0 ) ; 
 
        setPalette( columns *  4 ,  color,  0 ,  0 ,  index0,  index0) ; 
 
        setPalette( columns *  5 ,  color,  0 ,  0 ,  0 ,  index0) ; 
 
        setPalette( columns *  6 ,  color,  0 ,  index0,  0 ,  index0) ; 
 
        setPalette( columns *  7 ,  color,  0 ,  index0,  index0,  index0) ; 
 
    } 
 
 
 
    public  void setPalette( int index,  int color,  int alfaIndex,  int redIndex,  int greenIndex,  int blueIndex) 
 
    { 
 
        for  ( int i =  0 ;  i <  columns;  i++ )  { 
 
             colors[ index +  i]  =  getColor( color,  alfaIndex,  redIndex,  greenIndex,  blueIndex) ; 
 
             color =  colors[ index +  i] ; 
 
        } 
 
    } 
 
 
 
    public  int getColor( int color,  int alfaIndex,  int redIndex,  int greenIndex,  int blueIndex) 
 
    { 
 
        int alfa =  ( color >>  24 )  &  0xff ; 
 
        int red =  ( color >>  16 )  &  0xff ; 
 
        int green =  ( color >>  8 )  &  0xff ; 
 
        int blue =  color &  0xff ; 
 
 
 
        alfa +=  alfaIndex; 
 
        red +=  redIndex; 
 
        green +=  greenIndex; 
 
        blue +=  blueIndex; 
 
 
 
        alfa =  ( alfa >  255 )  ? 255  :  alfa; 
 
        red =  ( red >  255 )  ? 255  :  red; 
 
        green =  ( green >  255 )  ? 255  :  green; 
 
        blue =  ( blue >  255 )  ? 255  :  blue; 
 
 
 
        return  color =  ( alfa <<  24 )  |  ( red <<  16 )  |  ( green <<  8 )  |  blue; 
 
    } 
 
 
 
    public  int getCell( int dx,  int dy)  { 
 
        return  colors[ dy *  columns +  dx] ; 
 
    } 
 
 
 
    public  int getCell( int index)  { 
 
        return  colors[ index] ; 
 
    } 
 
 
 
    public  int getColumns( )  { 
 
        return  columns; 
 
    } 
 
 
 
    public  int getRows( )  { 
 
        return  rows; 
 
    } 
 
 
 
    public  int getMaxCells( )  { 
 
        return  maxCells; 
 
    } 
 
} 
 
Изм. Magatino  (7.10 / 14:29) (1)      Alexandr   [Off]  
(7.10.2018 / 14:07) Magatino, покаж скрины.
К записи GameDev Категории 
                 
                                    
                        
    Разделы 
    
 
    
Мы в соцсетях