Changeset 2551
- Timestamp:
- 2011-08-04 14:58:12 (12 years ago)
- Location:
- 2011/31/SanteriP
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/SanteriP/Acon/Acon/Peli.cs
r2526 r2551 12 12 Image olionKuva = LoadImage("Alus"); 13 13 Image AsteroidinKuva = LoadImage("Asteroid"); 14 Image AlotusKuva = LoadImage("Acon Start"); 14 15 PhysicsObject Acon; 16 PhysicsObject Asteroid; 17 LaserGun pyssy; 18 List<Label> valikonKohdat; 19 15 20 public override void Begin() 16 21 { 17 LuoKentta(); 22 Alkuvalikko(); 23 18 24 } 19 25 … … 22 28 { 23 29 24 Acon = new PhysicsObject( 75, 75);30 Acon = new PhysicsObject(30, 80); 25 31 Acon.Shape = Shape.Triangle; 26 32 Acon.Color = Color.White; 27 33 Acon.Image = olionKuva; 28 Acon.Shape = Shape.FromImage(olionKuva); 29 AssaultRifle pyssy = new AssaultRifle(20, 5); 34 Acon.Tag = "Acon"; 35 Add(Acon); 36 37 pyssy = new LaserGun(20, 5); 38 pyssy.LaserCollision = LaserSadeOsuu; 39 pyssy.Angle += Angle.FromDegrees(90); 40 pyssy.Ammo.Value = 500; 41 pyssy.Tag = "pyssy"; 30 42 Acon.Add(pyssy); 31 Add(Acon);32 43 33 44 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); … … 37 48 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-1000, 0)); 38 49 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(1000, 0)); 39 Keyboard.Listen(Key.Space, ButtonState.Down, LiikutaPelaajaa, "Ammu"); 40 50 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu",pyssy); 41 51 42 52 Level.CreateBorders(1.0, false); 43 Level.Background.CreateStars( 100);53 Level.Background.CreateStars(100); 44 54 Level.BackgroundColor = Color.Black; 45 55 Camera.ZoomToLevel(); 46 56 47 57 Timer ajastin = new Timer(); 48 ajastin.Interval = 1. 5;58 ajastin.Interval = 1.7; 49 59 ajastin.Timeout += delegate { LuoVihollinen(); }; 50 60 ajastin.Start(); 61 62 63 AddCollisionHandler(Acon, KasitteleAconinTormays); 51 64 52 65 } … … 56 69 57 70 Acon.Push(vektori); 58 59 71 } 60 72 61 73 void LuoVihollinen() 62 74 { 63 PhysicsObjectAsteroid = new PhysicsObject(150, 150);75 Asteroid = new PhysicsObject(150, 150); 64 76 Asteroid.Shape = Shape.FromImage( AsteroidinKuva ); 65 77 RandomMoverBrain satunnaisAivot = new RandomMoverBrain(); … … 71 83 Asteroid.Image = AsteroidinKuva; 72 84 Asteroid.Shape = Shape.Circle; 85 Asteroid.Tag = "Asteroid"; 73 86 Add(Asteroid); 87 88 74 89 } 75 90 void LiikutaPelaajaa() … … 77 92 78 93 } 79 94 void KasitteleAconinTormays(PhysicsObject Acon, PhysicsObject kohde) 95 { 96 97 if(kohde.Tag.ToString() == "Asteroid") 98 { 99 100 Explosion rajahdys = new Explosion(100); 101 rajahdys.Position = Acon.Position; 102 Add(rajahdys); 103 Acon.Destroy(); 104 } 105 } 106 void LaserSadeOsuu(PhysicsObject pyssy, PhysicsObject kohde) 107 { 108 109 if (kohde.Tag.ToString() == "Asteroid") 110 { 111 Explosion rajahdys = new Explosion(60); 112 rajahdys.Position = kohde.Position; 113 Add(rajahdys); 114 Asteroid.Destroy(); 115 } 116 } 117 void AmmuAseella(LaserGun pyssy) 118 { 119 PhysicsObject ammus = pyssy.Shoot(); 120 121 if (ammus != null) 122 { 123 ammus.Size *= 3; 124 } 125 } 126 127 protected override void Update(Jypeli.Time time) 128 { 129 if (Acon != null) 130 Acon.Angle = Acon.Velocity.Angle - Angle.FromDegrees(90); 131 132 base.Update(time); 133 } 134 void Alkuvalikko() 135 { 136 ClearAll(); 137 valikonKohdat = new List<Label>(); 138 139 Label kohta1 = new Label("Aloita Peli"); 140 kohta1.Position = new Vector(0, 40); 141 valikonKohdat.Add(kohta1); 142 143 Label kohta2 = new Label("Lopeta Peli"); 144 kohta2.Position = new Vector(0, -40); 145 valikonKohdat.Add(kohta2); 146 147 Label kohta3 = new Label("Ohjeet"); 148 kohta3.Position = new Vector(0, 0); 149 valikonKohdat.Add(kohta3); 150 151 Level.Background.Image = AlotusKuva; 152 Level.Background.FitToLevel(); 153 Camera.ZoomToLevel(); 154 155 156 foreach (Label valikonKohta in valikonKohdat) 157 { 158 Add(valikonKohta); 159 } 160 161 162 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 163 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 164 Mouse.ListenOn(kohta3, MouseButton.Left, ButtonState.Pressed, Ohjeet, null); 165 166 Mouse.IsCursorVisible = true; 167 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 168 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 169 } 170 171 void ValikossaLiikkuminen(AnalogState hiirenTila) 172 { 173 foreach (Label kohta in valikonKohdat) 174 { 175 176 if (Mouse.IsCursorOn(kohta)) 177 { 178 kohta.TextColor = Color.Red; 179 } 180 else 181 { 182 kohta.TextColor = Color.Cyan; 183 } 184 185 } 186 187 188 } 189 void AloitaPeli() 190 { 191 ClearAll(); 192 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Alkuvalikko, "Palaa valikkoon"); 193 LuoKentta(); 194 } 195 void Ohjeet() 196 { 197 198 } 199 80 200 } 81 201 -
2011/31/SanteriP/Acon/AconContent/AconContent.contentproj
r2526 r2551 45 45 </ItemGroup> 46 46 <ItemGroup> 47 <Compile Include="Untitled.png"> 48 <Name>Untitled</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 52 </ItemGroup> 53 <ItemGroup> 47 54 <Compile Include="Alus.png"> 48 55 <Name>Alus</Name> … … 58 65 </Compile> 59 66 </ItemGroup> 67 <ItemGroup> 68 <Compile Include="Acon start.png"> 69 <Name>Acon start</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 </ItemGroup> 60 74 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 61 75 <!-- 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.