Changeset 5822
- Timestamp:
- 2015-03-14 15:06:37 (8 years ago)
- Location:
- 2014/koodauskerho/38/AakeR
- Files:
-
- 11 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/koodauskerho/38/AakeR/Turborace/Turborace/Turborace.cs
r5812 r5822 13 13 new Vector( -700.0, 200.0 ), 14 14 new Vector( -500.0, 300.0 ), 15 new Vector( 100.0, 320.0 ), 15 16 new Vector( 500.0, 220.0 ), 16 // ... 17 new Vector( 600.0, 170.0 ), 18 new Vector( 700.0, -100.0 ), 19 new Vector( 600.0, -300.0 ), 20 new Vector( 400.0, -430.0 ), 21 new Vector( 100.0, -400.0 ), 22 new Vector( -300.0, -300.0 ), 23 new Vector( -700.0, -250.0 ), 24 new Vector( -900.0, 0.0 ), 25 new Vector( -670.0, 210.0 ), 17 26 }; 18 27 … … 20 29 21 30 Image aluskuva1 = LoadImage("Alus1"); 22 PhysicsObject alus; 31 Image aluskuva2 = LoadImage("Alus2"); 32 Image aluskuva3 = LoadImage("Alus3"); 33 Image aluskuva4 = LoadImage("Alus4"); 34 Image boostikuva = LoadImage("Boosti"); 35 Image pommikuplakuva = LoadImage("PommiKupla"); 36 Image pommikuva = LoadImage("Pommi"); 37 38 Alus alus1, alus2, alus3, alus4; 39 23 40 public override void Begin() 24 41 { 42 25 43 Level.Height = 1000; 26 44 Level.Width = 2000; … … 47 65 LuoRata(); 48 66 67 Timer ajastin = new Timer(); 68 ajastin.Interval = 2; 69 ajastin.Timeout += delegate { 70 int i = 1 + RandomGen.NextInt(reittiPisteet.Length - 1); 71 luoBoosti(reittiPisteet[i], reittiPisteet[i - 1]); 72 }; 73 ajastin.Start(); 74 75 Timer ajastin2 = new Timer(); 76 ajastin2.Interval = 3; 77 ajastin2.Timeout += delegate 78 { 79 int i = 1 + RandomGen.NextInt(reittiPisteet.Length - 1); 80 luoPommiKupla(reittiPisteet[i], reittiPisteet[i - 1]); 81 }; 82 ajastin2.Start(); 83 49 84 // TODO: Kirjoita ohjelmakoodisi tähän 50 luoAlus(); 85 alus1 = luoAlus(aluskuva1, -150); 86 alus2 = luoAlus(aluskuva2, -100); 87 alus3 = luoAlus(aluskuva3, -50); 88 alus4 = luoAlus(aluskuva4, 0); 89 90 51 91 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 52 92 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 53 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaAlusta, null, alus, 1000.0); 54 Keyboard.Listen(Key.Left, ButtonState.Down, KaannaAlusta, null, alus, 5.0); 55 Keyboard.Listen(Key.Right, ButtonState.Down, KaannaAlusta, null, alus, -5.0); 56 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaAlusta, null, alus, -400.0); 57 Keyboard.Listen(Key.J, ButtonState.Down, LiikutaAlusta2, null, alus, 90.0); 58 Keyboard.Listen(Key.L, ButtonState.Down, LiikutaAlusta2, null, alus, -90.0); 59 93 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaAlusta, null, alus1, 1000.0); 94 Keyboard.Listen(Key.Left, ButtonState.Down, KaannaAlusta, null, alus1, 5.0); 95 Keyboard.Listen(Key.Right, ButtonState.Down, KaannaAlusta, null, alus1, -5.0); 96 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaAlusta, null, alus1, -400.0); 97 Keyboard.Listen(Key.K, ButtonState.Pressed, TiputaPommi, null, alus1); 98 Keyboard.Listen(Key.J, ButtonState.Down, LiikutaAlusta2, null, alus1, 90.0); 99 Keyboard.Listen(Key.L, ButtonState.Down, LiikutaAlusta2, null, alus1, -90.0); 100 101 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaAlusta, null, alus2, 1000.0); 102 Keyboard.Listen(Key.A, ButtonState.Down, KaannaAlusta, null, alus2, 5.0); 103 Keyboard.Listen(Key.D, ButtonState.Down, KaannaAlusta, null, alus2, -5.0); 104 Keyboard.Listen(Key.S, ButtonState.Down, LiikutaAlusta, null, alus2, -400.0); 105 Keyboard.Listen(Key.G, ButtonState.Pressed, TiputaPommi, null, alus2); 106 Keyboard.Listen(Key.F, ButtonState.Down, LiikutaAlusta2, null, alus2, 90.0); 107 Keyboard.Listen(Key.H, ButtonState.Down, LiikutaAlusta2, null, alus2, -90.0); 108 109 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, LiikutaAlusta, null, alus3, 1000.0); 110 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, KaannaAlusta, null, alus3, 5.0); 111 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, KaannaAlusta, null, alus3, -5.0); 112 ControllerOne.Listen(Button.DPadDown, ButtonState.Down, LiikutaAlusta, null, alus3, -400.0); 113 ControllerOne.Listen(Button.LeftTrigger, ButtonState.Down, LiikutaAlusta2, null, alus3, 90.0); 114 ControllerOne.Listen(Button.RightTrigger, ButtonState.Down, LiikutaAlusta2, null, alus3, -90.0); 115 ControllerOne.Listen(Button.B, ButtonState.Down, TiputaPommi, null, alus3); 116 } 117 118 public void TiputaPommi(PhysicsObject alus) 119 { 120 Alus pelaaja = (Alus)alus; 121 if (pelaaja.PommiLaskuri.Value > 0) 122 { 123 PhysicsObject pommi = new PhysicsObject(25, 25); 124 pommi.Image = pommikuva; 125 pommi.Position = alus.Position + alus.AbsoluteAngle.GetVector().Normalize() * -70; 126 pommi.AbsoluteAngle = alus.AbsoluteAngle + Angle.FromDegrees(90); 127 AddCollisionHandler(pommi, "alus", pommiRajahtaa); 128 Add(pommi); 129 pelaaja.PommiLaskuri.Value--; 130 } 131 } 132 133 public void pommiRajahtaa(PhysicsObject pommi, PhysicsObject alus) 134 { 135 Explosion rajahdys = new Explosion(100); 136 rajahdys.Position = pommi.Position; 137 pommi.Destroy(); 138 Add(rajahdys); 139 60 140 } 61 141 … … 73 153 } 74 154 75 public void luoAlus()76 { 77 alus = new PhysicsObject(60, 40);155 Alus luoAlus(Image kuva, double poikkeama) 156 { 157 Alus alus = new Alus(60, 40); 78 158 alus.Shape = Shape.Rectangle; 79 alus.Image = aluskuva1;159 alus.Image = kuva; 80 160 Add(alus); 81 alus.Restitution = 0. 5;161 alus.Restitution = 0.0; 82 162 alus.AngularDamping = 0.5; 83 alus.LinearDamping = 0.95; 163 alus.LinearDamping = 0.97; 164 alus.Tag = "alus"; 165 166 alus.AbsoluteAngle = (reittiPisteet[1] - reittiPisteet[0]).Angle; 167 alus.Position = reittiPisteet[0] + (alus.AbsoluteAngle + Angle.FromDegrees(90)).GetVector() * poikkeama; 168 169 AddCollisionHandler(alus, "boosti", Boosti); 170 AddCollisionHandler(alus, "PommiKupla", KeraaPommi); 84 171 85 172 /*Vector pelaajanSuunta = Vector.FromLengthAndAngle(10000.0, alus.Angle); … … 87 174 alus.AngularVelocity = 5.0;*/ 88 175 89 176 return alus; 177 } 178 179 public void KeraaPommi(PhysicsObject alus, PhysicsObject pommikupla) 180 { 181 ((Alus)alus).PommiLaskuri.Value++; 182 pommikupla.Destroy(); 183 } 184 185 public void Boosti(PhysicsObject alus, PhysicsObject boosti) 186 { 187 //alus.Velocity *= 2; 188 alus.Hit(alus.AbsoluteAngle.GetVector() * 500); 189 boosti.Destroy(); 90 190 } 91 191 … … 99 199 void LuoRata() 100 200 { 101 RoadMap tie = new RoadMap(reittiPisteet); 102 tie.DefaultWidth = 100.0; 103 tie.Insert(); 201 //RoadMap tie = new RoadMap(reittiPisteet); 202 //tie.DefaultWidth = 210.0; 203 //tie.CreateSegmentFunction = LuoKaiteenPatka; 204 //tie.Insert(); 205 206 Vector[] ulkoKaidePisteet = new Vector[reittiPisteet.Length]; 207 for (int i = 0; i < reittiPisteet.Length; i++) 208 { 209 ulkoKaidePisteet[i] = reittiPisteet[i] + reittiPisteet[i].Normalize() * 100; 210 } 211 212 RoadMap ulkoKaide = new RoadMap(ulkoKaidePisteet); 213 ulkoKaide.DefaultWidth = 20.0; 214 ulkoKaide.CreateSegmentFunction = LuoKaiteenPatka; 215 ulkoKaide.Insert(); 216 217 Vector[] sisäKaidePisteet = new Vector[reittiPisteet.Length]; 218 for (int i = 0; i < reittiPisteet.Length; i++) 219 { 220 sisäKaidePisteet[i] = reittiPisteet[i] - reittiPisteet[i].Normalize() * 250; 221 } 222 223 RoadMap sisaKaide = new RoadMap(sisäKaidePisteet); 224 sisaKaide.DefaultWidth = 20.0; 225 sisaKaide.CreateSegmentFunction = LuoKaiteenPatka; 226 Level.Background.Color = Color.Gray; 227 sisaKaide.Insert(); 228 } 229 230 PhysicsObject LuoKaiteenPatka(double width, double height, Shape shape) 231 { 232 PhysicsObject patka = PhysicsObject.CreateStaticObject(width, height, shape); 233 patka.Color = Color.Black; 234 Add(patka); 235 return patka; 236 } 237 238 void luoBoosti(Vector paikka, Vector edellinenPiste) 239 { 240 PhysicsObject boosti = new PhysicsObject(50, 50); 241 boosti.Image = boostikuva; 242 boosti.Position = paikka - paikka.Normalize() * 100; 243 boosti.IgnoresCollisionResponse = true; 244 boosti.Tag = "boosti"; 245 Add(boosti); 246 247 Vector suunta = paikka - edellinenPiste; 248 boosti.AbsoluteAngle = suunta.Angle - Angle.FromDegrees(90); 249 250 boosti.LifetimeLeft = TimeSpan.FromSeconds(6); 251 } 252 253 void luoPommiKupla(Vector paikka, Vector edellinenPiste) 254 { 255 PhysicsObject pommiKupla = new PhysicsObject(50, 50); 256 pommiKupla.Image = pommikuplakuva; 257 pommiKupla.Position = paikka - paikka.Normalize() * 100; 258 pommiKupla.IgnoresCollisionResponse = true; 259 pommiKupla.Tag = "PommiKupla"; 260 Add(pommiKupla); 261 262 //Vector suunta = paikka - edellinenPiste; 263 //pommiKupla.AbsoluteAngle = suunta.Angle - Angle.FromDegrees(90); 264 265 pommiKupla.LifetimeLeft = TimeSpan.FromSeconds(6); 266 } 267 268 class Alus : PhysicsObject 269 { 270 private IntMeter pommiLaskuri = new IntMeter(0, 0, 100); 271 public IntMeter PommiLaskuri { get { return pommiLaskuri; } } 272 273 274 public Alus(double leveys, double korkeus) 275 : base(leveys, korkeus) { } 276 104 277 } 105 278 -
2014/koodauskerho/38/AakeR/Turborace/Turborace/Turborace.csproj.Debug.cachefile
r5812 r5822 1 1 Content\Alus1.xnb 2 Content\Boosti.xnb 3 Content\Pommi.xnb 4 Content\PommiKupla.xnb 5 Content\Alus2.xnb 6 Content\Alus3.xnb 7 Content\Alus4.xnb -
2014/koodauskerho/38/AakeR/Turborace/Turborace/obj/x86/Debug/ContentPipeline-{F25903C4-EB60-483B-922D-0B23274E0822}.xml
r5812 r5822 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus1.xnb</Output> 11 <Time>2015-02-14T12:28:30.5938706+02:00</Time> 11 <Time>2015-03-14T14:34:56.702807+02:00</Time> 12 </Item> 13 <Item> 14 <Source>Boosti.png</Source> 15 <Name>Boosti</Name> 16 <Importer>TextureImporter</Importer> 17 <Processor>TextureProcessor</Processor> 18 <Options>None</Options> 19 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Boosti.xnb</Output> 20 <Time>2015-02-14T14:57:32.6455162+02:00</Time> 21 </Item> 22 <Item> 23 <Source>Pommi.png</Source> 24 <Name>Pommi</Name> 25 <Importer>TextureImporter</Importer> 26 <Processor>TextureProcessor</Processor> 27 <Options>None</Options> 28 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Pommi.xnb</Output> 29 <Time>2015-03-14T10:50:13.293207+02:00</Time> 30 </Item> 31 <Item> 32 <Source>PommiKupla.png</Source> 33 <Name>PommiKupla</Name> 34 <Importer>TextureImporter</Importer> 35 <Processor>TextureProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\PommiKupla.xnb</Output> 38 <Time>2015-03-14T12:44:46.738407+02:00</Time> 39 </Item> 40 <Item> 41 <Source>Alus2.png</Source> 42 <Name>Alus2</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus2.xnb</Output> 47 <Time>2015-03-14T14:37:46.061607+02:00</Time> 48 </Item> 49 <Item> 50 <Source>Alus3.png</Source> 51 <Name>Alus3</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus3.xnb</Output> 56 <Time>2015-03-14T14:38:28.834607+02:00</Time> 57 </Item> 58 <Item> 59 <Source>Alus4.png</Source> 60 <Name>Alus4</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus4.xnb</Output> 65 <Time>2015-03-14T14:40:03.803807+02:00</Time> 12 66 </Item> 13 67 <BuildSuccessful>true</BuildSuccessful> -
2014/koodauskerho/38/AakeR/Turborace/Turborace/obj/x86/Debug/Turborace.csproj.FileListAbsolute.txt
r5812 r5822 8 8 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\obj\x86\Debug\Turborace.pdb 9 9 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus1.xnb 10 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Boosti.xnb 11 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Pommi.xnb 12 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\PommiKupla.xnb 13 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus2.xnb 14 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus3.xnb 15 C:\MyTemp\AakeR\Turborace\Turborace\Turborace\bin\x86\Debug\Content\Alus4.xnb -
2014/koodauskerho/38/AakeR/Turborace/Turborace/obj/x86/Debug/cachefile-{F25903C4-EB60-483B-922D-0B23274E0822}-targetpath.txt
r5812 r5822 1 1 Content\Alus1.xnb 2 Content\Boosti.xnb 3 Content\Pommi.xnb 4 Content\PommiKupla.xnb 5 Content\Alus2.xnb 6 Content\Alus3.xnb 7 Content\Alus4.xnb -
2014/koodauskerho/38/AakeR/Turborace/TurboraceContent/TurboraceContent.contentproj
r5812 r5822 52 52 </Compile> 53 53 </ItemGroup> 54 <ItemGroup> 55 <Compile Include="Boosti.png"> 56 <Name>Boosti</Name> 57 <Importer>TextureImporter</Importer> 58 <Processor>TextureProcessor</Processor> 59 </Compile> 60 </ItemGroup> 61 <ItemGroup> 62 <Compile Include="Pommi.png"> 63 <Name>Pommi</Name> 64 <Importer>TextureImporter</Importer> 65 <Processor>TextureProcessor</Processor> 66 </Compile> 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="PommiKupla.png"> 70 <Name>PommiKupla</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="Alus2.png"> 77 <Name>Alus2</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 <Compile Include="Alus3.png"> 82 <Name>Alus3</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 <Compile Include="Alus4.png"> 87 <Name>Alus4</Name> 88 <Importer>TextureImporter</Importer> 89 <Processor>TextureProcessor</Processor> 90 </Compile> 91 </ItemGroup> 54 92 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 55 93 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.