1# 2# Copyright 2011,2014 by Mark Weyer 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 2 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write to the Free Software 16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17# 18 19Secret = { 20 name = " " 21 author = "Mark Weyer" 22 description = "Congratulations, you found the secret level" 23 pics = Two,Three,Four,Five 24 greypic = Grey 25 startpic = Start 26 emptypic = Empty 27 startdist = "**********","**********","**********","**********","..%&" 28 neighbours = <neighbours_eight> 29 randomfallpos = 1 30 31 << 32 var kind_channel,start_channel,kind_perm,connect_perm; 33 var start_val = 0 : reapply; 34 var channel,perm; 35 var pos_; 36 var val0,val1,val2,val3; 37 38 random_perm = { 39 val0 = rnd(4); 40 val1 = rnd(3); 41 val2 = rnd(2); 42 if val1>=val0 -> val1+=1; 43 if val2>=val0 -> val2+=1; 44 if val2>=val1 -> {val2+=1; if val2==val0 -> val2+=1;}; 45 val3 = 6-val0-val1-val2; 46 perm = val0+4*val1+16*val2+64*val3; 47 }; 48 49 random_channel = { 50 channel = 1; 51 if 1:2 -> channel*=4; 52 if 1:2 -> channel*=16; 53 }; 54 55 do_perm = { # applies perm to val0 56 channel = 1; 57 if val0%2 -> channel*=4; 58 if val0>1 -> channel*=16; 59 val0 = perm/channel%4; 60 }; 61 62 global.init = { 63 random_channel; kind_channel = channel; 64 random_perm; kind_perm = perm; 65 random_perm; connect_perm = perm; 66 random_channel; start_channel = channel; 67 start_val = rnd(4); 68 }; 69 70 draw = {pos=pos_; *;}; 71 72 Kind_init = { 73 val0 = kind-Two; perm=kind_perm@; do_perm; 74 pos_ = (rnd(256).-(3*kind_channel@))+val0*kind_channel@; 75 }; 76 77 Kind = draw; 78 79 Kind_connect = { 80 val0 = kind-Two; perm=connect_perm@; do_perm; 81 switch { 82 val0==0 -> inhibit=DIR_U+DIR_D+DIR_UL+DIR_DL+DIR_UR+DIR_DR; 83 val0==1 -> inhibit=DIR_L+DIR_R+DIR_U+DIR_D; 84 val0==2 -> inhibit=DIR_UL+DIR_DL+DIR_UR+DIR_DR; 85 val0==3 -> inhibit=DIR_L+DIR_R+DIR_UL+DIR_DL+DIR_UR+DIR_DR; 86 }; 87 }; 88 89 Start.init = { 90 random_perm; 91 behaviour .+= floats; 92 }; 93 94 Start = { 95 if !time -> { 96 val0 = 19-loc_y; perm = perm@@(loc_x,19); do_perm; 97 pos_ = val0; 98 val0 = 19-loc_y; perm = perm@@(loc_x,18); do_perm; 99 pos_ += 4*val0; 100 val0 = 19-loc_y; perm = perm@@(loc_x,17); do_perm; 101 pos_ += 16*val0; 102 val0 = 19-loc_y; perm = perm@@(loc_x,16); do_perm; 103 pos_ += 64*val0; 104 if pos_/start_channel@%4 != start_val@ -> {kind=Empty; start_val=1;}; 105 }; 106 draw; 107 }; 108 109 Grey.init = { 110 pos_ = rnd(256).-(3*start_channel@); 111 val0 = rnd(3); 112 if val0>=start_val@ -> val0+=1; 113 pos_ += val0*start_channel@; 114 }; 115 116 Grey = draw; 117 118 Empty = { if start_val -> draw; }; 119 120 Two.init = Kind_init; 121 Three.init = Kind_init; 122 Four.init = Kind_init; 123 Five.init = Kind_init; 124 125 Two = Kind; 126 Three = Kind; 127 Four = Kind; 128 Five = Kind; 129 130 Two.connect = Kind_connect; 131 Three.connect = Kind_connect; 132 Four.connect = Kind_connect; 133 Five.connect = Kind_connect; 134 135 info = { 136 if version==0 -> A* 137 else { 138 E,E,E,E,E,E,E,E,E, 139 F,F,F,F,F,F,F,F,F, 140 M,M,M,M,M,M,M,M,M, 141 N,N,N,N,N,N,N,N,N 142 }; 143 * 144 }; 145 >> 146 147 Start = { pics = mseGG.xpm } 148 149 Grey = { pics = mseGG.xpm } 150 151 Empty = { pics = mseGG.xpm } 152 153 Two = { 154 pics = mseKind.xpm 155 numexplode = 2 156 } 157 158 Three = { 159 pics = mseKind.xpm 160 numexplode = 3 161 } 162 163 Four = { 164 pics = mseKind.xpm 165 numexplode = 4 166 } 167 168 Five = { 169 pics = mseKind.xpm 170 numexplode = 5 171 } 172 173 info = { 174 pics = infoicons.xpm 175 } 176 177} 178 179