- Timestamp:
- 2010-07-22 11:51:03 (13 years ago)
- Location:
- 2010/27/anlakane/Nopeuspeli
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/anlakane/Nopeuspeli/Content/Content.contentproj
r1212 r1261 90 90 </Compile> 91 91 </ItemGroup> 92 <ItemGroup> 93 <Compile Include="00.png"> 94 <Name>00</Name> 95 <Importer>TextureImporter</Importer> 96 <Processor>TextureProcessor</Processor> 97 </Compile> 98 </ItemGroup> 99 <ItemGroup> 100 <Compile Include="11.png"> 101 <Name>11</Name> 102 <Importer>TextureImporter</Importer> 103 <Processor>TextureProcessor</Processor> 104 </Compile> 105 <Compile Include="22.png"> 106 <Name>22</Name> 107 <Importer>TextureImporter</Importer> 108 <Processor>TextureProcessor</Processor> 109 </Compile> 110 <Compile Include="33.png"> 111 <Name>33</Name> 112 <Importer>TextureImporter</Importer> 113 <Processor>TextureProcessor</Processor> 114 </Compile> 115 </ItemGroup> 92 116 </Project> -
2010/27/anlakane/Nopeuspeli/Ohjelma.cs
r1207 r1261 7 7 using (Peli game = new Peli()) 8 8 { 9 #if !DEBUG10 game.IsFullScreen = true;11 #endif12 9 game.Run(); 13 10 } -
2010/27/anlakane/Nopeuspeli/Peli.cs
r1212 r1261 9 9 List<GameObject> painikkeet; 10 10 List<GameObject> painamattomat; 11 const double painikkeenLeveys = 100; 11 12 Animation painike0animaatio; 13 Animation painike1animaatio; 14 Animation painike2animaatio; 15 Animation painike3animaatio; 16 17 const double painikkeenLeveys = 200; 12 18 const double painikkeenKorkeus = painikkeenLeveys; 13 19 Timer painikkeidenSytytin; … … 20 26 int montakoPainikettaPainettu; 21 27 28 bool peliPaattynyt; 29 22 30 Sound piip; 23 31 … … 28 36 painikkeidenMaara = 4; 29 37 38 SetWindowSize(600, 400, false); 30 39 Level.Background.Image = LoadImage("tausta"); 31 40 Level.Background.Size = new Vector(Screen.Width, Screen.Height); … … 77 86 void LisaaPainikkeet() 78 87 { 88 Image[] painike0kuvat = LoadImages("0", "00"); 89 Image[] painike1kuvat = LoadImages("1", "11"); 90 Image[] painike2kuvat = LoadImages("2", "22"); 91 Image[] painike3kuvat = LoadImages("3", "33"); 92 painike0animaatio = new Animation(painike0kuvat); 93 painike1animaatio = new Animation(painike1kuvat); 94 painike2animaatio = new Animation(painike2kuvat); 95 painike3animaatio = new Animation(painike3kuvat); 96 painike0animaatio.FPS = 15; 97 painike1animaatio.FPS = 15; 98 painike2animaatio.FPS = 15; 99 painike3animaatio.FPS = 15; 100 79 101 for (int i = 0; i < painikkeidenMaara; i++) 80 102 { … … 99 121 painike.Tag = painikkeet.Count.ToString(); 100 122 painike.Image = LoadImage((painikkeet.Count - 1).ToString() + "_"); 123 101 124 return painike; 102 125 } … … 131 154 void PeliPaattyy(Timer t) 132 155 { 156 peliPaattynyt = true; 133 157 painikkeidenSytytin.Stop(); 134 158 nopeutusAjastin.Stop(); … … 142 166 void AloitaPeli() 143 167 { 168 peliPaattynyt = false; 144 169 for (int i = 0; i < painikkeet.Count; i++) 145 170 { … … 161 186 void SytytaJokinPainike(Timer t) 162 187 { 163 int sytytettavanIndeksi = RandomGen.NextInt(0, painikkeet.Count - 1); 188 int sytytettavanIndeksi = RandomGen.NextInt(0, painikkeet.Count - 1); // Arvotaan sytytettävä nappula 164 189 Sytyta(sytytettavanIndeksi); 165 190 painamattomat.Add(painikkeet[sytytettavanIndeksi]); … … 168 193 switch (sytytettavanIndeksi) 169 194 { 170 case 0 195 case 0: 171 196 piip.Pitch = -1; 172 197 break; … … 180 205 piip.Pitch = -0.15; 181 206 break; 182 183 } 184 207 } 208 185 209 piip.Play(); 186 210 } … … 188 212 void Sytyta(int i) 189 213 { 190 painikkeet[i].Image = LoadImage(i.ToString()); 214 switch (i) 215 { 216 case 0: 217 painikkeet[i].Animation = painike0animaatio; 218 break; 219 case 1: 220 painikkeet[i].Animation = painike1animaatio; 221 break; 222 case 2: 223 painikkeet[i].Animation = painike2animaatio; 224 break; 225 case 3: 226 painikkeet[i].Animation = painike3animaatio; 227 break; 228 } 229 painikkeet[i].Animation.Start(); 191 230 } 192 231 … … 198 237 void Sammuta(int i) 199 238 { 200 painikkeet[i].Image = LoadImage(i.ToString() + "_"); 201 } 202 203 239 if (!peliPaattynyt) // Ei sammuteta nappulaa jos peli on päättynyt. 240 { 241 painikkeet[i].Animation.Stop(); 242 painikkeet[i].Image = LoadImage(i.ToString() + "_"); 243 } 244 } 204 245 }
Note: See TracChangeset
for help on using the changeset viewer.