Changeset 8396 for 2016/koodauskerho/OttoK/peli2
- Timestamp:
- 2017-01-28 14:52:25 (4 years ago)
- Location:
- 2016/koodauskerho/OttoK/peli2
- Files:
-
- 16 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/koodauskerho/OttoK/peli2/peli2/peli2/obj/x86/Debug/ContentPipeline-{63C34160-7957-4F91-BEB4-9CD0C03BF303}.xml
r8375 r8396 19 19 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\vihreealus.xnb</Output> 20 20 <Time>2016-12-17T13:17:07.0365774+02:00</Time> 21 </Item> 22 <Item> 23 <Source>mustalus.png</Source> 24 <Name>mustalus</Name> 25 <Importer>TextureImporter</Importer> 26 <Processor>TextureProcessor</Processor> 27 <Options>None</Options> 28 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\mustalus.xnb</Output> 29 <Time>2017-01-28T10:12:06.3665507+02:00</Time> 30 </Item> 31 <Item> 32 <Source>alustuli.png</Source> 33 <Name>alustuli</Name> 34 <Importer>TextureImporter</Importer> 35 <Processor>TextureProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\alustuli.xnb</Output> 38 <Time>2017-01-28T11:18:09.6609507+02:00</Time> 39 </Item> 40 <Item> 41 <Source>vihreepanos.png</Source> 42 <Name>vihreepanos</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\vihreepanos.xnb</Output> 47 <Time>2017-01-28T11:46:09.3009507+02:00</Time> 48 </Item> 49 <Item> 50 <Source>oranssipanos.png</Source> 51 <Name>oranssipanos</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\oranssipanos.xnb</Output> 56 <Time>2017-01-28T11:46:13.7549507+02:00</Time> 57 </Item> 58 <Item> 59 <Source>meteoriitti.png</Source> 60 <Name>meteoriitti</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\meteoriitti.xnb</Output> 65 <Time>2017-01-28T13:43:14.0054507+02:00</Time> 21 66 </Item> 22 67 <BuildSuccessful>true</BuildSuccessful> -
2016/koodauskerho/OttoK/peli2/peli2/peli2/obj/x86/Debug/cachefile-{63C34160-7957-4F91-BEB4-9CD0C03BF303}-targetpath.txt
r8375 r8396 1 1 Content\oranssialus.xnb 2 2 Content\vihreealus.xnb 3 Content\mustalus.xnb 4 Content\alustuli.xnb 5 Content\vihreepanos.xnb 6 Content\oranssipanos.xnb 7 Content\meteoriitti.xnb -
2016/koodauskerho/OttoK/peli2/peli2/peli2/obj/x86/Debug/peli2.csproj.FileListAbsolute.txt
r8375 r8396 9 9 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\oranssialus.xnb 10 10 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\vihreealus.xnb 11 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\mustalus.xnb 12 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\alustuli.xnb 13 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\vihreepanos.xnb 14 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\oranssipanos.xnb 15 C:\MyTemp\OttoK\peli2\peli2\peli2\bin\x86\Debug\Content\meteoriitti.xnb -
2016/koodauskerho/OttoK/peli2/peli2/peli2/peli2.cs
r8375 r8396 7 7 using Jypeli.Widgets; 8 8 9 class Alus : PhysicsObject 10 { 11 private IntMeter elamaLaskuri = new IntMeter(10, 0, 20); 12 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 13 14 private GameObject alustuli; 15 public GameObject Alustuli { get { return alustuli; } } 16 17 18 public Alus(double leveys, double korkeus, Image alustulenkuva) 19 : base(leveys, korkeus) 20 { 21 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 22 23 alustuli = new GameObject(10, 15); 24 alustuli.Image = alustulenkuva; 25 this.Add(alustuli); 26 alustuli.Position = new Vector(0, -35); 27 alustuli.IsVisible = false; 28 } 29 } 9 30 public class peli2 : PhysicsGame 10 31 { 11 32 Image oranssialuskuva = LoadImage("oranssialus"); 12 33 Image vihreealuskuva = LoadImage("vihreealus"); 34 Image mustaluskuva = LoadImage("mustalus"); 35 Image alustulenkuva = LoadImage("alustuli"); 36 Image vihreeammuskuva = LoadImage("vihreepanos"); 37 Image oranssiammuskuva = LoadImage("oranssipanos"); 38 Image meteoriittikuva = LoadImage("meteoriitti"); 13 39 14 40 public override void Begin() 15 41 { 16 42 SmoothTextures = false; 43 Level.Size = new Vector(1900, 1000); 17 44 18 PhysicsObject vihreealus = TeeAlus(100, 100, vihreealuskuva); 45 Alus vihreealus = TeeAlus(400, 0, vihreealuskuva, Screen.Right - 150, Color.LightGreen); 46 vihreealus.Tag = "vihreealus"; 19 47 20 PhysicsObject oranssialus = TeeAlus(200, 200, oranssialuskuva); 48 Alus oranssialus = TeeAlus(-400, 0, oranssialuskuva, Screen.Left + 150, Color.Orange); 49 oranssialus.Tag = "oranssialus"; 21 50 22 51 PhoneBackButton.Listen(ConfirmExit, "Quit"); 23 52 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Quit"); 24 53 Keyboard.Listen(Key.Up, ButtonState.Down, Liiku, "Liiku", vihreealus, 800.0); 54 Keyboard.Listen(Key.Up, ButtonState.Released, Sammutatuli, null, vihreealus); 25 55 Keyboard.Listen(Key.Right, ButtonState.Down, Kaanny, "Käänny", vihreealus, -8000.0); 26 56 Keyboard.Listen(Key.Left, ButtonState.Down, Kaanny, "Käänny", vihreealus, 8000.0); … … 29 59 Keyboard.Listen(Key.W, ButtonState.Down, Liiku, "Liiku", oranssialus, 800.0); 30 60 Keyboard.Listen(Key.D, ButtonState.Down, Kaanny, "Käänny", oranssialus, -8000.0); 61 Keyboard.Listen(Key.W, ButtonState.Released, Sammutatuli, null, oranssialus); 31 62 Keyboard.Listen(Key.A, ButtonState.Down, Kaanny, "Käänny", oranssialus, 8000.0); 63 Keyboard.Listen(Key.LeftControl, ButtonState.Pressed, ammu, "Ammu", oranssialus); 64 65 Timer meteorcreater = new Timer(); 66 meteorcreater.Interval = RandomGen.NextDouble(6, 16); 67 meteorcreater.Timeout += delegate 68 { 69 PhysicsObject meteoriitti = TeeMeteoriitti(100, 100); 70 meteoriitti.Velocity = (RandomGen.NextVector(-75, -75, 75, 75)); 71 meteoriitti.AngularVelocity = RandomGen.NextDouble(-2, 2); 72 meteorcreater.Interval = RandomGen.NextDouble(6, 14); 73 }; 74 meteorcreater.Start(); 32 75 33 76 Level.Background.Color = Color.Black; 34 77 Level.Background.CreateStars(); 78 Timer ajastin = new Timer(); 79 ajastin.Interval = 0.1; 80 ajastin.Timeout += delegate 81 { 82 if (vihreealus.X < Level.Left) 83 vihreealus.X = Level.Right; 84 if (vihreealus.X > Level.Right) 85 vihreealus.X = Level.Left; 86 if (vihreealus.Y > Level.Top) 87 vihreealus.Y = Level.Bottom; 88 if (vihreealus.Y < Level.Bottom) 89 vihreealus.Y = Level.Top; 90 91 if (oranssialus.X < Level.Left) 92 oranssialus.X = Level.Right; 93 if (oranssialus.X > Level.Right) 94 oranssialus.X = Level.Left; 95 if (oranssialus.Y > Level.Top) 96 oranssialus.Y = Level.Bottom; 97 if (oranssialus.Y < Level.Bottom) 98 oranssialus.Y = Level.Top; 99 }; 100 ajastin.Start(); 35 101 } 36 102 37 103 void ammu(PhysicsObject pelaaja) 38 104 { 39 PhysicsObject ammus = new PhysicsObject(15, 15); 105 PhysicsObject ammus = new PhysicsObject(10, 7); 106 if (pelaaja.Tag.Equals("vihreealus")) 107 { 108 ammus.Image = vihreeammuskuva; 109 } 110 else 111 { 112 ammus.Image = oranssiammuskuva; 113 } 40 114 ammus.Angle = pelaaja.Angle + Angle.FromDegrees(90); 41 ammus.Velocity = Vector.FromLengthAndAngle( 100, pelaaja.Angle + Angle.FromDegrees(90));115 ammus.Velocity = Vector.FromLengthAndAngle(700, pelaaja.Angle + Angle.FromDegrees(90)); 42 116 ammus.Position = pelaaja.Position + Vector.FromLengthAndAngle(pelaaja.Width * 0.75, pelaaja.Angle + Angle.FromDegrees(90)); 117 ammus.Tag = "ammus"; 118 ammus.LifetimeLeft = TimeSpan.FromSeconds(10); 43 119 Add(ammus); 44 120 } 45 PhysicsObject TeeAlus(double x, double y, Image aluskuva)121 Alus TeeAlus(double x, double y, Image aluskuva, double xpalkinpaikka, Color palkinvari) 46 122 { 47 PhysicsObject alus = new PhysicsObject(60, 70);123 Alus alus = new Alus(60, 70, alustulenkuva); 48 124 alus.Position = new Vector(x, y); 49 alus.Shape = Shape. Rectangle;125 alus.Shape = Shape.FromImage(mustaluskuva); 50 126 alus.Image = aluskuva; 51 127 alus.LinearDamping = 0.98; 52 128 alus.AngularDamping = 0.98; 53 129 Add(alus); 130 AddCollisionHandler(alus, "ammus", TormaaAmmukseen); 131 ProgressBar elamaPalkki = new ProgressBar(150, 20); 132 elamaPalkki.BarColor = palkinvari; 133 elamaPalkki.X = xpalkinpaikka; 134 elamaPalkki.Y = Screen.Top - 20; 135 elamaPalkki.BindTo(alus.ElamaLaskuri); 136 Add(elamaPalkki); 54 137 return alus; 55 138 } 56 void Liiku( PhysicsObjectalus, double nopeus)139 void Liiku(Alus alus, double nopeus) 57 140 { 58 141 alus.Push((alus.Angle + Angle.FromDegrees(90)).GetVector() * nopeus); 142 alus.Alustuli.IsVisible = true; 143 } 144 void Sammutatuli(Alus alus) 145 { 146 alus.Alustuli.IsVisible = false; 59 147 } 60 148 void Kaanny(PhysicsObject alus, double nopeus) … … 62 150 alus.ApplyTorque(nopeus); 63 151 } 152 PhysicsObject TeeMeteoriitti(double leveys, double korkeus) 153 { 154 PhysicsObject meteoriitti = new PhysicsObject(leveys, korkeus); 155 meteoriitti.Mass = 100; 156 meteoriitti.Image = meteoriittikuva; 157 Add(meteoriitti); 158 return meteoriitti; 159 } 160 void TormaaAmmukseen(PhysicsObject alus, PhysicsObject ammus) 161 { 162 163 ammus.Destroy(); 164 ((Alus)alus).ElamaLaskuri.Value -= 1; 165 if (((Alus)alus).ElamaLaskuri.Value == ((Alus)alus).ElamaLaskuri.MinValue) 166 { 167 if (alus.Tag.Equals("vihreealus")) 168 { 169 Keyboard.Disable(Key.RightControl); 170 } 171 if (alus.Tag.Equals("oranssialus")) 172 { 173 Keyboard.Disable(Key.LeftControl); 174 } 175 } 176 } 64 177 } -
2016/koodauskerho/OttoK/peli2/peli2/peli2/peli2.csproj.Debug.cachefile
r8375 r8396 1 1 Content\oranssialus.xnb 2 2 Content\vihreealus.xnb 3 Content\mustalus.xnb 4 Content\alustuli.xnb 5 Content\vihreepanos.xnb 6 Content\oranssipanos.xnb 7 Content\meteoriitti.xnb -
2016/koodauskerho/OttoK/peli2/peli2/peli2Content/peli2Content.contentproj
r8375 r8396 57 57 </Compile> 58 58 </ItemGroup> 59 <ItemGroup> 60 <Compile Include="mustalus.png"> 61 <Name>mustalus</Name> 62 <Importer>TextureImporter</Importer> 63 <Processor>TextureProcessor</Processor> 64 </Compile> 65 </ItemGroup> 66 <ItemGroup> 67 <Compile Include="alustuli.png"> 68 <Name>alustuli</Name> 69 <Importer>TextureImporter</Importer> 70 <Processor>TextureProcessor</Processor> 71 </Compile> 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="vihreepanos.png"> 75 <Name>vihreepanos</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="oranssipanos.png"> 82 <Name>oranssipanos</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="meteoriitti.png"> 89 <Name>meteoriitti</Name> 90 <Importer>TextureImporter</Importer> 91 <Processor>TextureProcessor</Processor> 92 </Compile> 93 </ItemGroup> 59 94 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 60 95 <!-- 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.