Changeset 274
- Timestamp:
- 2009-08-05 11:27:47 (11 years ago)
- Location:
- arho_m
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
arho_m/Avaruuspeli2/Content/Content.contentproj
r268 r274 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>7a1efcbb-b39d-4767-bcac-732d721d9524</ProjectGuid> … … 33 33 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 34 34 </ItemGroup> 35 <ItemGroup> 36 <Compile Include="bgtex.png"> 37 <Name>bgtex</Name> 38 <Importer>TextureImporter</Importer> 39 <Processor>TextureProcessor</Processor> 40 </Compile> 41 </ItemGroup> 35 42 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 36 43 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
arho_m/Avaruuspeli2/Peli.cs
r268 r274 24 24 BattleObject pelaaja1; 25 25 PlasmaCannon ase; 26 27 26 BarGauge hitpointNaytto; 28 Timer ajastin; 27 double vihu_interv = 0.5; 28 bool nopeuta_vihuja = true; 29 29 #endregion 30 30 … … 62 62 lisaaNappaimet(); 63 63 Camera.Follow(pelaaja1); 64 65 MessageDisplay.Add("(Paina F1, niin saat näppäinohjeet.)");66 64 } 67 65 68 66 Level luoKentta() 69 67 { 70 Level kentta = new Level(this, 640, 480);68 Level kentta = new Level(this, 800, 600); 71 69 kentta.CreateBorder(); 72 kentta.Background.CreateStars(); 70 kentta.BackgroundColor = Color.Black; 71 72 Texture2D bgtex = Content.Load<Texture2D>("bgtex"); 73 73 74 74 lisaaPelaajat(kentta); … … 79 79 private void lisaaPelaajat(Level kentta) 80 80 { 81 // Pelaaja 182 81 Texture2D alus = Content.Load<Texture2D>("alus"); 83 pelaaja1 = new BattleObject(Shapes.CreateFromTexture(alus, new Vector2D(50, 40), 10), 10, 5); 82 IShape pelaaja_shape = Shapes.CreateFromTexture(alus, new Vector2D(50, 40), 8.0); 83 84 pelaaja1 = new BattleObject(pelaaja_shape, 15, 5); 84 85 pelaaja1.Texture = alus; 86 85 87 hitpointNaytto.BindTo(pelaaja1.HitPoints); 86 88 pelaaja1.HitpointsReachedZero += new EventHandler(rajahdys); … … 96 98 ase.SetOwner(pelaaja1, kentta); 97 99 ase.Visible = true; 100 ase.Size = new Vector2D(0, 0); 98 101 ase.Color = Color.SteelBlue; 99 ase.FireRate = 1000;102 ase.FireRate = 8; 100 103 ase.Power = new Meter<double>(5000, 5000, 5000); 101 104 kentta.Objects.Add(ase); 105 106 Timer tm = new Timer(); 107 tm.Interval = vihu_interv; 108 tm.Trigger += new Timer.TriggerHandler(spawnVihu); 109 tm.Start(); 110 AddTimer(tm); 102 111 } 103 112 #endregion … … 110 119 111 120 //Yleiset näppäimet 112 Controls.Listen(Keys.Enter, ButtonPosition.Pressed, UusiPeli , "Aloittaa uuden pelin");121 Controls.Listen(Keys.Enter, ButtonPosition.Pressed, UusiPeli); 113 122 114 123 // Pelaajan 1 näppäimet 115 Controls.Listen(Keys.Left, ButtonPosition.Down, LiikuX, null, 5.0); 116 Controls.Listen(Keys.Right, ButtonPosition.Down, LiikuX, null, -5.0); 117 Controls.Listen(Keys.Up, ButtonPosition.Down, LiikuY, null, 5.0); 118 Controls.Listen(Keys.Down, ButtonPosition.Down, LiikuY, null, -5.0); 124 const double nopeus = 850.0; 125 Controls.Listen(Keys.Left, ButtonPosition.Down, LiikuX, null, pelaaja1, -nopeus); 126 Controls.Listen(Keys.Right, ButtonPosition.Down, LiikuX, null, pelaaja1, nopeus); 127 Controls.Listen(Keys.Up, ButtonPosition.Down, LiikuY, null, pelaaja1, nopeus); 128 Controls.Listen(Keys.Down, ButtonPosition.Down, LiikuY, null, pelaaja1, -nopeus); 119 129 Controls.Listen(Keys.Space, ButtonPosition.Down, Ammu); 120 }121 122 // Näppäimiin liitetyt toiminnot alkavat tästä -->123 private Boolean NaytaOhjeet(ControlEvent e)124 {125 ShowControlHelp(MessageDisplay);126 return false;127 130 } 128 131 … … 137 140 // luodaan ammus 138 141 Projectile ammus = ase.Use(); 142 if (ammus == null) 143 return false; 144 139 145 ammus.Position = ammus.Position + (Vector2D.FromLengthAndAngle(40, ase.Angle.Radian)); 140 146 ammus.Push(ammus.Velocity); //? … … 150 156 PhysicsObject pelaaja = e.Parameter0.ToPhysicsObject(); 151 157 double nopeus = e.Parameter1.ToDouble(); 152 pelaaja.Y += nopeus; 158 159 Vector2D v = new Vector2D(0, nopeus); 160 pelaaja.Hit(v); 161 153 162 return false; 154 163 } … … 158 167 PhysicsObject pelaaja = e.Parameter0.ToPhysicsObject(); 159 168 double nopeus = e.Parameter1.ToDouble(); 160 pelaaja.X += nopeus; 169 170 Vector2D v = new Vector2D(nopeus,0); 171 pelaaja.Hit(v); 172 161 173 return false; 162 174 } … … 170 182 { 171 183 PhysicsObject po = sender.ToPhysicsObject(); 172 Explosion ex = new Explosion(po.Width * 2);184 Explosion ex = new Explosion(po.Width * 1.25); 173 185 ex.Position = po.Position; 174 ex.Force = 4000;186 ex.Force = 2000; 175 187 Level.Objects.Add(ex); 176 188 po.Destroy(); 189 190 if (po == pelaaja1) 191 ase.Destroy(); 177 192 } 178 193 … … 186 201 bo2.TakeDamage(new Damage(1)); 187 202 } 203 204 void spawnVihu(Timer t) 205 { 206 IShape shape; 207 208 int numero = RandomGen.NextInt(0, 1); 209 switch (numero) 210 { 211 case 0: 212 shape = Shapes.CreateRectangle(40, 40); 213 break; 214 215 case 1: 216 shape = Shapes.CreateCircle(20.0); 217 break; 218 219 default: 220 return; 221 } 222 223 BattleObject bo = new BattleObject(shape, 25.0, 25); 224 225 bo.X = Level.Right - (bo.Width/2.0); 226 bo.Y = RandomGen.NextDouble(Level.Bottom, Level.Top); 227 bo.HitpointsReachedZero += new EventHandler(rajahdys); 228 AddCollisionHandler(bo, VihuTormHandler); 229 230 Vector2D v = new Vector2D(RandomGen.NextDouble(-12000,-6000), RandomGen.NextDouble(-4000,4000)); 231 bo.Hit(v); 232 233 Level.Objects.Add(bo); 234 235 double kerroin = 1.4; 236 237 if (nopeuta_vihuja) 238 vihu_interv /= kerroin; 239 else 240 vihu_interv *= kerroin; 241 242 if (vihu_interv < 0.01 || vihu_interv > 0.5) 243 nopeuta_vihuja = !nopeuta_vihuja; 244 245 t.Interval = vihu_interv; 246 } 247 248 void VihuTormHandler(Collision c) 249 { 250 if (c.Other == Level.LeftBorder) 251 c.Obj.Destroy(); 252 } 253 188 254 #endregion 189 255 } -
arho_m/Pong/Peli.cs
r255 r274 46 46 pallo.KineticFriction = 0.0; 47 47 pallo.Restitution = 1.0; 48 pallo.LinearDamping = 1.0; 48 49 49 50 Timer tm = new Timer();
Note: See TracChangeset
for help on using the changeset viewer.