1 /* 2 Bastet - tetris clone with embedded bastard block chooser 3 (c) 2005-2009 Federico Poloni <f.polonithirtyseven@sns.it> minus 37 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #include "Block.hpp" 20 21 #include "curses.h" 22 23 namespace Bastet{ 24 25 BlockArray blocks={{ 26 BlockImpl(COLOR_PAIR(7),(OrientationMatrix){{ //O //should be yellow, but I find no portable way to output a yellow solid block character in ncurses. 27 {{//orientation 0 (initial 28 {1,1},{2,1},{1,0},{2,0} 29 }}, 30 {{//orientation 1 31 {1,1},{2,1},{1,0},{2,0} 32 }}, 33 {{//orientation 2 34 {1,1},{2,1},{1,0},{2,0} 35 }}, 36 {{//orientation 3 37 {1,1},{2,1},{1,0},{2,0} 38 }} 39 }}), 40 BlockImpl(COLOR_PAIR(4),(OrientationMatrix){{ //I 41 {{//orientation 0 (initial) 42 {0,1},{1,1},{2,1},{3,1} 43 }}, 44 {{//orientation 1 45 {2,3},{2,1},{2,2},{2,0} 46 }}, 47 {{//orientation 2 48 {0,2},{1,2},{2,2},{3,2} 49 }}, 50 {{//orientation 3 51 {1,3},{1,1},{1,2},{1,0} 52 }} 53 }}), 54 BlockImpl(COLOR_PAIR(1),(OrientationMatrix){{ //Z 55 {{//orientation 0 (initial 56 {1,1},{2,1},{0,0},{1,0} 57 }}, 58 {{//orientation 1 59 {1,2},{1,1},{2,1},{2,0} 60 }}, 61 {{//orientation 2 62 {1,2},{2,2},{0,1},{1,1} 63 }}, 64 {{//orientation 3 65 {0,2},{0,1},{1,1},{1,0} 66 }} 67 }}), 68 BlockImpl(COLOR_PAIR(5),(OrientationMatrix){{ //T 69 {{//orientation 0 (initial 70 {0,1},{1,1},{2,1},{1,0} 71 }}, 72 {{//orientation 1 73 {1,2},{1,1},{2,1},{1,0} 74 }}, 75 {{//orientation 2 76 {1,2},{0,1},{1,1},{2,1} 77 }}, 78 {{//orientation 3 79 {1,2},{0,1},{1,1},{1,0} 80 }} 81 }}), 82 BlockImpl(COLOR_PAIR(6),(OrientationMatrix){{ //J 83 {{//orientation 0 (initial 84 {0,1},{1,1},{2,1},{0,0} 85 }}, 86 {{//orientation 1 87 {1,2},{1,1},{1,0},{2,0} 88 }}, 89 {{//orientation 2 90 {2,2},{0,1},{1,1},{2,1} 91 }}, 92 {{//orientation 3 93 {0,2},{1,2},{1,1},{1,0} 94 }} 95 }}), 96 BlockImpl(COLOR_PAIR(3),(OrientationMatrix){{ //S 97 {{//orientation 0 (initial 98 {0,1},{1,1},{1,0},{2,0} 99 }}, 100 {{//orientation 1 101 {2,2},{1,1},{2,1},{1,0} 102 }}, 103 {{//orientation 2 104 {0,2},{1,2},{1,1},{2,1} 105 }}, 106 {{//orientation 3 107 {1,2},{0,1},{1,1},{0,0} 108 }} 109 }}), 110 BlockImpl(COLOR_PAIR(2),(OrientationMatrix){{ //L 111 {{//orientation 0 (initial 112 {0,1},{1,1},{2,1},{2,0} 113 }}, 114 {{//orientation 1 115 {1,2},{2,2},{1,1},{1,0} 116 }}, 117 {{//orientation 2 118 {0,2},{0,1},{1,1},{2,1} 119 }}, 120 {{//orientation 3 121 {1,2},{1,1},{0,0},{1,0} 122 }} 123 }}) 124 }}; 125 126 // const DotMatrix GetDots(BlockType b, Dot position, Orientation o){ 127 // return blocks[b].GetDots(position,o); 128 // } GetColor(BlockType b)129 const Color GetColor(BlockType b){ 130 return blocks[b].GetColor(); 131 } GetChar(BlockType b)132 const char GetChar(BlockType b){ 133 return "OIZTJSL"[int(b)]; 134 } 135 hash_value(const Dot & d)136 size_t hash_value(const Dot &d){ 137 return (d.x+5)*32+d.y; 138 } 139 } 140