- Timestamp:
- 2010-08-03 14:57:48 (12 years ago)
- Location:
- 2010/31/saolhaka/GuitarZero
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
2010/31/saolhaka/GuitarZero/Content/Content.contentproj
r1535 r1574 1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> 2 2 <PropertyGroup> 3 3 <ProjectGuid>ce2a6936-8e98-47f1-a2dc-cb25670e009b</ProjectGuid> … … 34 34 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 35 35 </ItemGroup> 36 <ItemGroup> 37 <Compile Include="bluefret.png"> 38 <Name>bluefret</Name> 39 <Importer>TextureImporter</Importer> 40 <Processor>TextureProcessor</Processor> 41 </Compile> 42 <Compile Include="greenfret.png"> 43 <Name>greenfret</Name> 44 <Importer>TextureImporter</Importer> 45 <Processor>TextureProcessor</Processor> 46 </Compile> 47 <Compile Include="orangefret.png"> 48 <Name>orangefret</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 52 <Compile Include="redfret.png"> 53 <Name>redfret</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 <Compile Include="yellowfret.png"> 58 <Name>yellowfret</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="Bitmap1.bmp"> 65 <Name>Bitmap1</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="bluebutton.png"> 72 <Name>bluebutton</Name> 73 <Importer>TextureImporter</Importer> 74 <Processor>TextureProcessor</Processor> 75 </Compile> 76 <Compile Include="greenbutton.png"> 77 <Name>greenbutton</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 <Compile Include="orangebutton.png"> 82 <Name>orangebutton</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 <Compile Include="redbutton.png"> 87 <Name>redbutton</Name> 88 <Importer>TextureImporter</Importer> 89 <Processor>TextureProcessor</Processor> 90 </Compile> 91 <Compile Include="yellowbutton.png"> 92 <Name>yellowbutton</Name> 93 <Importer>TextureImporter</Importer> 94 <Processor>TextureProcessor</Processor> 95 </Compile> 96 </ItemGroup> 97 <ItemGroup> 98 <Compile Include="bluefretpressed.png"> 99 <Name>bluefretpressed</Name> 100 <Importer>TextureImporter</Importer> 101 <Processor>TextureProcessor</Processor> 102 </Compile> 103 <Compile Include="greenfretpressed.png"> 104 <Name>greenfretpressed</Name> 105 <Importer>TextureImporter</Importer> 106 <Processor>TextureProcessor</Processor> 107 </Compile> 108 <Compile Include="orangefretpressed.png"> 109 <Name>orangefretpressed</Name> 110 <Importer>TextureImporter</Importer> 111 <Processor>TextureProcessor</Processor> 112 </Compile> 113 <Compile Include="redfretpressed.png"> 114 <Name>redfretpressed</Name> 115 <Importer>TextureImporter</Importer> 116 <Processor>TextureProcessor</Processor> 117 </Compile> 118 <Compile Include="yellowfretpressed.png"> 119 <Name>yellowfretpressed</Name> 120 <Importer>TextureImporter</Importer> 121 <Processor>TextureProcessor</Processor> 122 </Compile> 123 </ItemGroup> 124 <ItemGroup> 125 <Compile Include="bluehopo.png"> 126 <Name>bluehopo</Name> 127 <Importer>TextureImporter</Importer> 128 <Processor>TextureProcessor</Processor> 129 </Compile> 130 <Compile Include="greenhopo.png"> 131 <Name>greenhopo</Name> 132 <Importer>TextureImporter</Importer> 133 <Processor>TextureProcessor</Processor> 134 </Compile> 135 <Compile Include="orangehopo.png"> 136 <Name>orangehopo</Name> 137 <Importer>TextureImporter</Importer> 138 <Processor>TextureProcessor</Processor> 139 </Compile> 140 <Compile Include="redhopo.png"> 141 <Name>redhopo</Name> 142 <Importer>TextureImporter</Importer> 143 <Processor>TextureProcessor</Processor> 144 </Compile> 145 <Compile Include="yellowhopo.png"> 146 <Name>yellowhopo</Name> 147 <Importer>TextureImporter</Importer> 148 <Processor>TextureProcessor</Processor> 149 </Compile> 150 </ItemGroup> 36 151 </Project> -
2010/31/saolhaka/GuitarZero/GuitarHere.csproj
r1535 r1574 7 7 <OutputType>WinExe</OutputType> 8 8 <AppDesignerFolder>Properties</AppDesignerFolder> 9 <RootNamespace>Guitar Zero</RootNamespace>10 <AssemblyName>Guitar Zero</AssemblyName>9 <RootNamespace>GuitarHere</RootNamespace> 10 <AssemblyName>GuitarHere</AssemblyName> 11 11 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 12 12 <XnaFrameworkVersion>v3.1</XnaFrameworkVersion> -
2010/31/saolhaka/GuitarZero/GuitarHere.sln
r1535 r1574 2 2 Microsoft Visual Studio Solution File, Format Version 10.00 3 3 # Visual Studio 2008 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Guitar Zero", "GuitarZero.csproj", "{8D3FD434-B351-4F19-91AA-69CC880D14A9}"4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuitarHere", "GuitarHere.csproj", "{8D3FD434-B351-4F19-91AA-69CC880D14A9}" 5 5 EndProject 6 6 Global -
2010/31/saolhaka/GuitarZero/Peli.cs
r1535 r1574 7 7 public class Peli : Game 8 8 { 9 const double kielenLeveys = 50.0; 10 double nuottienTippumisnopeus = 8.0; 11 9 12 List<Label> valikonKohdat; 13 Label valikonValittu; 10 14 Label pisteNaytto; 15 GameObject[] fretit; 16 Image[] fretitPainettuna; 17 Image[] fretitPainamattomina; 18 GameObject viivaus; 19 20 Timer nuottienPudotusAjastin; 21 List<GameObject> nuotit; 22 bool seuraavaOnHopo = false; 11 23 12 24 protected override void Begin() … … 19 31 valikonKohdat = new List<Label>(); 20 32 21 Label kohta0 = new Label("Guitar Zero");33 Label kohta0 = new Label("Guitar Here"); 22 34 kohta0.Position = new Vector(0, 300); 23 35 Add(kohta0); … … 26 38 Label kohta1 = new Label("Aloita uusi peli"); 27 39 kohta1.Position = new Vector(0, 40); 40 kohta1.TextColor = Color.White; 28 41 valikonKohdat.Add(kohta1); 29 42 30 43 Label kohta2 = new Label("Lopeta"); 31 44 kohta2.Position = new Vector(0, -40); 45 kohta2.TextColor = Color.White; 32 46 valikonKohdat.Add(kohta2); 33 47 Level.BackgroundColor = Color.Red; … … 38 52 } 39 53 40 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 41 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Lopeta, null); 42 43 Mouse.IsCursorVisible = true; 44 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 54 valikonValittu = valikonKohdat[0]; 55 valikonValittu.TextColor = Color.Orange; 56 RaySegment alleviivaus = new RaySegment(new Vector(-75, 30), new Vector(150, 0), 1); 57 viivaus = new GameObject(1, 1, alleviivaus); 58 viivaus.Color = Color.Orange; 59 Add(viivaus); 60 61 //Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 62 //Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Lopeta, null); 63 Keyboard.Listen(Key.Up, ButtonState.Pressed, ValikossaLiikkuminen, null); 64 Keyboard.Listen(Key.Down, ButtonState.Pressed, ValikossaLiikkuminen, null); 65 Keyboard.Listen(Key.Enter, ButtonState.Pressed, ValikonValinta, null); 66 67 68 Mouse.IsCursorVisible = false; 69 //Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 45 70 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Lopeta, ""); 46 71 } 47 72 48 void ValikossaLiikkuminen(AnalogState hiirenTila) 49 { 50 foreach (Label kohta in valikonKohdat) 51 { 52 if (Mouse.IsCursorOn(kohta)) 73 void ValikonValinta() 74 { 75 if (valikonValittu == valikonKohdat[0]) 76 { 77 AloitaPeli(); 78 } 79 if (valikonValittu == valikonKohdat[1]) 80 { 81 Lopeta(); 82 } 83 } 84 85 void ValikossaLiikkuminen() 86 { 87 if (valikonValittu == valikonKohdat[0]) 53 88 { 54 89 // Todo: Voiko tekstin kokoa jotenkin muuttaa? 55 kohta.TextColor = Color.Orange; 56 } 57 else 58 { 59 kohta.TextColor = Color.White; 60 } 61 62 } 63 } 90 valikonKohdat[1].TextColor = Color.Orange; 91 valikonKohdat[0].TextColor = Color.White; 92 valikonValittu = valikonKohdat[1]; 93 viivaus.Destroy(); 94 RaySegment alleviivaus = new RaySegment(new Vector(-35, -50), new Vector(70, 0), 1); 95 viivaus = new GameObject(1, 1, alleviivaus); 96 viivaus.Color = Color.Orange; 97 Add(viivaus); 98 return; 99 } 100 if (valikonValittu == valikonKohdat[1]) 101 { 102 valikonKohdat[0].TextColor = Color.Orange; 103 valikonKohdat[1].TextColor = Color.White; 104 valikonValittu = valikonKohdat[0]; 105 viivaus.Destroy(); 106 RaySegment alleviivaus = new RaySegment(new Vector(-75, 30), new Vector(150, 0), 1); 107 viivaus = new GameObject(1, 1, alleviivaus); 108 viivaus.Color = Color.Orange; 109 Add(viivaus); 110 } 111 } 112 64 113 void AloitaPeli() 65 114 { 66 115 ClearAll(); 67 LuoLaskuri(); 116 AsetaOhjaimet(); 117 Level.BackgroundColor = Color.Brown; 118 LuoPisteLaskuri(); 68 119 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); 69 120 pisteNaytto.BindTo(pisteLaskuri); 70 121 Add(pisteNaytto); 71 PiirraViivasto(); 72 73 } 74 75 void PiirraViivasto() 76 { 77 for (int i = 0; i < 6; i++) 78 { 79 RaySegment r = new RaySegment(new Vector(-125 + (i*50), -750), new Vector(0, 2000), 1); 80 GameObject p = new GameObject(1, 1, r); 81 Add(p); 82 83 } 122 PiirraKieletJaFretit(); 123 nuotit = new List<GameObject>(); 124 LuoNuottienPudotusAjastin(); 125 } 126 127 void LuoNuottienPudotusAjastin() 128 { 129 nuottienPudotusAjastin = new Timer(); 130 nuottienPudotusAjastin.Interval = 0.50; 131 nuottienPudotusAjastin.Trigger += LuoSatunnainenNuotti; 132 nuottienPudotusAjastin.Start(); 133 Timer.SingleShot(0.5, NuottienPudotusNopeudenAsettaminen); 134 } 135 136 void NuottienPudotusNopeudenAsettaminen() 137 { 138 double aika = RandomGen.NextDouble(0.10, 0.50); 139 aika = Math.Round(aika, 1); 140 if (aika <= 0.2) 141 { 142 seuraavaOnHopo = true; 143 } 144 nuottienPudotusAjastin.Interval = aika; 145 MessageDisplay.Add("Nuotit putoaa nyt nopeudella: " + nuottienPudotusAjastin.Interval.ToString() + " s"); 146 Timer.SingleShot(aika, NuottienPudotusNopeudenAsettaminen); 147 } 148 149 void LuoSatunnainenNuotti(Timer ajastin) 150 { 151 int kieli = RandomGen.NextInt(0, 4); 152 GameObject nuotti = new GameObject(40, 40, Shapes.Circle); 153 double x = -75 + (kieli * kielenLeveys); 154 nuotti.Position = new Vector(x, Screen.Top); 155 156 bool edellinenSamallaKielella = false; 157 if (nuotit.Count > 1) 158 { 159 edellinenSamallaKielella = (nuotti.X == nuotit[nuotit.Count - 1].X); 160 } 161 162 if (seuraavaOnHopo && !edellinenSamallaKielella) 163 { 164 switch (kieli) 165 { 166 case 0: 167 nuotti.Image = LoadImage("greenhopo"); 168 break; 169 case 1: 170 nuotti.Image = LoadImage("redhopo"); 171 break; 172 case 2: 173 nuotti.Image = LoadImage("yellowhopo"); 174 break; 175 case 3: 176 nuotti.Image = LoadImage("bluehopo"); 177 break; 178 case 4: 179 nuotti.Image = LoadImage("orangehopo"); 180 break; 181 } 182 183 seuraavaOnHopo = false; 184 } 185 else 186 { 187 switch (kieli) 188 { 189 case 0: 190 nuotti.Image = LoadImage("greenbutton"); 191 break; 192 case 1: 193 nuotti.Image = LoadImage("redbutton"); 194 break; 195 case 2: 196 nuotti.Image = LoadImage("yellowbutton"); 197 break; 198 case 3: 199 nuotti.Image = LoadImage("bluebutton"); 200 break; 201 case 4: 202 nuotti.Image = LoadImage("orangebutton"); 203 break; 204 } 205 206 } 207 208 nuotit.Add(nuotti); 209 Add(nuotti); 210 } 211 212 void LuoReuna(double x) 213 { 214 RaySegment reuna1 = new RaySegment(new Vector(x, -750), new Vector(0, 2000), 1); 215 GameObject reuna = new GameObject(1, 1, reuna1); 216 reuna.Color = Color.White; 217 Add(reuna); 218 219 } 220 void PiirraKieletJaFretit() 221 { 222 LuoReuna(-100); 223 LuoReuna(150); 224 225 fretitPainettuna = new Image[5]; 226 fretitPainettuna[0] = LoadImage("greenfretpressed"); 227 fretitPainettuna[1] = LoadImage("redfretpressed"); 228 fretitPainettuna[2] = LoadImage("yellowfretpressed"); 229 fretitPainettuna[3] = LoadImage("bluefretpressed"); 230 fretitPainettuna[4] = LoadImage("orangefretpressed"); 231 fretitPainamattomina = new Image[5]; 232 fretitPainamattomina[0] = LoadImage("greenfret"); 233 fretitPainamattomina[1] = LoadImage("redfret"); 234 fretitPainamattomina[2] = LoadImage("yellowfret"); 235 fretitPainamattomina[3] = LoadImage("bluefret"); 236 fretitPainamattomina[4] = LoadImage("orangefret"); 237 238 fretit = new GameObject[5]; 239 240 for (int i = 0; i < 5; i++) 241 { 242 double x = -75 + (i * kielenLeveys); 243 double y = -750; 244 RaySegment r = new RaySegment(new Vector(x, y), new Vector(0, 2000), 1); 245 GameObject kieli = new GameObject(1, 1, r); 246 kieli.Color = new Color(100, 100, 100); 247 Add(kieli); 248 249 GameObject fretti = new GameObject(47, 47, Shapes.Circle); 250 switch (i) 251 { 252 case 0: 253 fretti.Image = LoadImage("greenfret"); 254 break; 255 case 1: 256 fretti.Image = LoadImage("redfret"); 257 break; 258 case 2: 259 fretti.Image = LoadImage("yellowfret"); 260 break; 261 case 3: 262 fretti.Image = LoadImage("bluefret"); 263 break; 264 case 4: 265 fretti.Image = LoadImage("orangefret"); 266 break; 267 } 268 269 fretti.Position = new Vector(x, Screen.Bottom + 75); 270 fretit[i] = fretti; 271 Add(fretit[i]); 272 } 273 } 274 275 void AsetaOhjaimet() 276 { 277 Keyboard.Listen(Key.F1, ButtonState.Down, Paina, null, 0); 278 Keyboard.Listen(Key.F1, ButtonState.Released, Vapauta, null, 0); 279 Keyboard.Listen(Key.F2, ButtonState.Down, Paina, null, 1); 280 Keyboard.Listen(Key.F2, ButtonState.Released, Vapauta, null, 1); 281 Keyboard.Listen(Key.F3, ButtonState.Down, Paina, null, 2); 282 Keyboard.Listen(Key.F3, ButtonState.Released, Vapauta, null, 2); 283 Keyboard.Listen(Key.F4, ButtonState.Down, Paina, null, 3); 284 Keyboard.Listen(Key.F4, ButtonState.Released, Vapauta, null, 3); 285 Keyboard.Listen(Key.F5, ButtonState.Down, Paina, null, 4); 286 Keyboard.Listen(Key.F5, ButtonState.Released, Vapauta, null, 4); 287 } 288 289 void Paina(int indeksi) 290 { 291 fretit[indeksi].Image = fretitPainettuna[indeksi]; 292 } 293 294 void Vapauta(int indeksi) 295 { 296 fretit[indeksi].Image = fretitPainamattomina[indeksi]; 84 297 } 85 298 … … 91 304 IntMeter pisteLaskuri; 92 305 93 void Luo Laskuri()306 void LuoPisteLaskuri() 94 307 { 95 308 pisteLaskuri = new IntMeter(0); … … 109 322 Add(pisteTeksti); 110 323 } 324 325 protected override void Update(Time time) 326 { 327 if (nuotit != null && nuotit.Count > 0) 328 { 329 foreach (GameObject nuotti in nuotit) 330 { 331 nuotti.Y -= 1 * nuottienTippumisnopeus; 332 } 333 } 334 base.Update(time); 335 } 336 111 337 } 338
Note: See TracChangeset
for help on using the changeset viewer.