Changeset 5412
- Timestamp:
- 2014-07-04 10:54:32 (9 years ago)
- Location:
- 2014/27/AleksanteriV/Protokolla236TrueSurvivor
- Files:
-
- 10 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/MikonPhysicsObject.cs
r5224 r5412 7 7 using Jypeli.Widgets; 8 8 9 class MikonParticle : GameObject 10 { 11 private Proto236b parent; 12 private Vector velocity; 13 public Vector Velocity { get { return velocity; } set { velocity = value; } } 14 private Angle angularVelocity; 15 public Angle AngularVelocity { get { return angularVelocity; } set { angularVelocity = value; } } 16 private double mass; 17 public double Mass { get { return mass; } set { mass = value; } } 18 private bool ignoresGravity; 19 public bool IgnoresGravity { get { return ignoresGravity; } set { ignoresGravity = value; } } 20 private bool broken = false; 21 public override void Update(Time time) 22 { 23 this.Position += this.velocity / this.mass / 20; 24 if (!this.ignoresGravity) 25 { 26 this.Velocity += this.parent.Gravity / 120; 27 } 28 this.Angle += this.angularVelocity; 29 if (this.parent.Level.Left > this.Position.X || this.parent.Level.Right < this.Position.X) 30 { 31 this.Destroy(); 32 } 33 if (this.parent.Level.Bottom > this.Position.Y || this.parent.Level.Top < this.Position.Y) 34 { 35 this.Destroy(); 36 } 37 base.Update(time); 38 } 39 public void Break(int method, int pieceCountX = 2, int pieceCountY = 2) 40 { 41 if (this.broken) { return; } 42 this.Destroy(); 43 this.broken = true; 44 switch (method) 45 { 46 case 0://uniform break 47 var pieceWidth = this.Width / pieceCountX; 48 var pieceHeight = this.Height / pieceCountY; 49 if (pieceWidth < 1 || pieceHeight < 1) { return; } 50 //loop x and y through 51 //calc left corner 52 var startCorner = Vector.FromLengthAndAngle(this.Width / 2 - pieceWidth / 2, this.AbsoluteAngle + Angle.StraightAngle) + Vector.FromLengthAndAngle(this.Height / 2 - pieceHeight / 2, this.AbsoluteAngle - Angle.RightAngle); //vasen alakulma 53 54 for (int y = 0; y < pieceCountY; y++) 55 { 56 for (int x = 0; x < pieceCountX; x++) 57 { 58 int w = this.Image.Width / pieceCountX, h = this.Image.Height / pieceCountY; 59 var imageArea = this.Image.Area( 60 w * x, 61 h * (pieceCountY - y - 1), 62 w * (x + 1), 63 h * ((pieceCountY - y - 1) + 1) 64 ); 65 MikonParticle childBox = new MikonParticle(this.parent, pieceWidth, pieceHeight); 66 childBox.Tag = this.Tag; 67 childBox.IgnoresGravity = this.IgnoresGravity; 68 childBox.Image = imageArea; 69 childBox.Mass = this.Mass; 70 71 childBox.AbsoluteAngle = this.AbsoluteAngle; 72 childBox.AngularVelocity = this.AngularVelocity; 73 74 childBox.Position = this.Position + startCorner 75 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x 76 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y 77 78 childBox.Velocity = this.Velocity + RandomGen.NextVector(10, 30); 79 80 if (RandomGen.NextDouble(0, 1) < 0.2) 81 { 82 childBox.Break(method, 2, 1); 83 } 84 85 Game.Add(childBox); 86 } 87 } 88 break; 89 } 90 } 91 public MikonParticle(Proto236b parent, double w, double h) 92 : base(w, h) 93 { 94 this.parent = parent; 95 this.IsUpdated = true; 96 } 97 } 9 98 public class MikonPhysicsObject : PhysicsObject 10 99 { … … 21 110 var pieceWidth = this.Width / pieceCountX; 22 111 var pieceHeight = this.Height / pieceCountY; 23 if (pieceWidth < 3 || pieceHeight < 3) { return; }24 var useCollisions = true;25 if (pieceWidth < 10 || pieceHeight < 10) { useCollisions = false; }112 if (pieceWidth < 4 || pieceHeight < 4) { return; } 113 var cheap = false; 114 if (pieceWidth < 10 || pieceHeight < 10) { cheap = true; } 26 115 //loop x and y through 27 116 //calc left corner … … 32 121 for (int x = 0; x < pieceCountX; x++) 33 122 { 34 MikonPhysicsObject childBox = new MikonPhysicsObject(this.game, pieceWidth, pieceHeight); 35 if (!useCollisions) 123 int w = this.Image.Width / pieceCountX, h = this.Image.Height / pieceCountY; 124 var imageArea = this.Image.Area( 125 w * x, 126 h * (pieceCountY - y - 1), 127 w * (x + 1), 128 h * ((pieceCountY - y - 1) + 1) 129 ); 130 if (!cheap) 36 131 { 37 childBox.CollisionIgnoreGroup = 2; 132 MikonPhysicsObject childBox = new MikonPhysicsObject(this.game, pieceWidth, pieceHeight); 133 childBox.Tag = this.Tag; 134 childBox.IgnoresGravity = false; 135 childBox.Image = imageArea; 136 137 childBox.AbsoluteAngle = this.AbsoluteAngle; 138 childBox.AngularVelocity = this.AngularVelocity; 139 140 childBox.Position = this.Position + startCorner 141 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x 142 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y 143 144 childBox.Velocity = this.Velocity + RandomGen.NextVector(10, 30); 145 146 Game.Add(childBox); 38 147 } 39 childBox.Color = this.Color; 40 childBox.Tag = this.Tag; 41 childBox.AbsoluteAngle = this.AbsoluteAngle; 42 childBox.AngularVelocity = this.AngularVelocity; 148 else 149 { 150 MikonParticle childBox = new MikonParticle(this.game, pieceWidth, pieceHeight); 151 childBox.Tag = this.Tag; 152 childBox.IgnoresGravity = this.IgnoresGravity; 153 childBox.Image = imageArea; 154 childBox.Mass = this.Mass; 43 155 44 childBox.Position = this.Position + startCorner 45 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x 46 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y 156 childBox.AbsoluteAngle = this.AbsoluteAngle; 157 childBox.AngularVelocity = Angle.FromDegrees(this.AngularVelocity * 7); 47 158 48 childBox.Velocity = this.Velocity; 159 childBox.Position = this.Position + startCorner 160 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x 161 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y 49 162 50 //childBox.Position += offset;163 childBox.Velocity = this.Velocity + RandomGen.NextVector(10, 30); 51 164 52 if (RandomGen.NextDouble(0, 1) < 0.2) 53 { 54 childBox.Break(method, pieceCountX, pieceCountY); 165 //if (RandomGen.NextDouble(0, 1) < 0.2) 166 //{ 167 // childBox.Break(method, pieceCountX, pieceCountY); 168 //} 169 170 Game.Add(childBox); 55 171 } 56 57 Game.Add(childBox);58 172 } 59 173 } -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Music.cs
r5408 r5412 11 11 private Dictionary<string,string> planetMusic = new Dictionary<string,string>(); 12 12 public Dictionary<string, string> PlanetMusic { get { return planetMusic; } set { planetMusic = value; } } 13 private List<string> spaceMusic = new List<string>(); 14 public List<string> SpaceMusic { get { return spaceMusic; } set { spaceMusic = value; } } 13 15 public Music() { 14 16 planetMusic.Add("planet2", "music/nitrome - Canopy"); 17 planetMusic.Add("planet1", "music/nitrome - temple glider"); 18 spaceMusic.Add("music/SmoothSpaceJazz"); 15 19 } 16 20 } -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Planet.cs
r5398 r5412 19 19 this.levelId = levelId; 20 20 this.Shape = Shape.Circle; 21 this.Image = parent.Images[levelId]; 21 22 this.Position = position; 22 23 this.music = parent.Music.PlanetMusic[levelId]; -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Player.cs
r5396 r5412 63 63 { 64 64 bullet.Velocity += this.Velocity; 65 65 bullet.Tag = "bullet"; 66 66 } 67 67 } 68 } 69 public void BulletHit(PhysicsObject bullet, PhysicsObject target) 70 { 71 bullet.Destroy(); 72 ((MikonPhysicsObject)target).Break(0,2,2); 68 73 } 69 74 public void attachWeapon() … … 73 78 weapon.IsVisible = false; 74 79 weapon.InfiniteAmmo = true; 80 weapon.ProjectileCollision = BulletHit; 75 81 Add(weapon); 76 82 weapons.Add(weapon); -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor.cs
r5408 r5412 46 46 images["planet2_background"] = LoadImage("graphics/backgrounds/planet2"); 47 47 images["planet2_valetta"] = LoadImage("graphics/backgrounds/planet2_valetta"); 48 images["planet2"] = LoadImage("graphics/Planets/MapPlanet1"); 49 images["planet1"] = LoadImage("graphics/Planets/MapPlanet3"); 48 50 images["player"] = LoadImage("graphics/ships/player"); 49 51 images["galaxy_map"] = LoadImage("graphics/HUD/galaxy_map"); … … 83 85 galaxy.CurrentPlanet = galaxy.Planets[level.Id];//aseta galaksiin tiedot nykyisestä planeetasta 84 86 player.Y = Level.Top - Screen.Height; 87 MediaPlayer.Stop(); 85 88 MediaPlayer.Play(galaxy.Planets[level.Id].Music); 86 89 //player.x on jotain … … 88 91 else 89 92 { 93 MediaPlayer.Stop(); 94 MediaPlayer.Play(music.SpaceMusic[RandomGen.NextInt(0,music.SpaceMusic.Count)]); 90 95 Gravity = new Vector(0, 0); 91 96 player.LinearDamping = 1;//avaruudessa ei ilmanvastusta … … 148 153 //kaikki spacessa olevat jutut voisi alkaa CC 149 154 tileMap.SetTileMethod(Color.FromHexCode("ccffff"), createPlanet, "planet2");//planeetta 2 155 tileMap.SetTileMethod(Color.FromHexCode("ccffcc"), createPlanet, "planet1");//planeetta 1 150 156 151 157 double w = 0, h = 0; … … 246 252 { 247 253 // TODO: Kirjoita peli tähän 254 LoadAllMusic(); 248 255 LoadAllImages(); 249 LoadAllMusic();250 256 LoadAllLevels(); 251 257 -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor.csproj.Debug.cachefile
r5408 r5412 36 36 Content\music\nitrome - worm food.xnb 37 37 Content\music\Explosion3.xnb 38 Content\graphics\Planets\MapPlanet1.xnb 39 Content\graphics\Planets\MapPlanet2.xnb 40 Content\graphics\Planets\MapPlanet3.xnb 41 Content\graphics\Planets\MapPlanet4.xnb 42 Content\graphics\Planets\MapPlanet5.xnb 43 Content\graphics\Planets\MapPlanet6.xnb 44 Content\music\SmoothSpaceJazz.xnb 38 45 Content\music\cold_heart_of_the_klondike-j7JwprGVSjA_fmt43.wma 39 46 Content\music\nitrome - Canopy.wma … … 45 52 Content\music\nitrome - thin ice.wma 46 53 Content\music\nitrome - worm food.wma 54 Content\music\SmoothSpaceJazz.wma -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/obj/x86/Debug/ContentPipeline-{5156C658-EF8C-4216-BA6D-9928D133FE72}.xml
r5408 r5412 180 180 <Options>None</Options> 181 181 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\levels\!space.xnb</Output> 182 <Time>2014-07-04T 09:10:13.9184777+03:00</Time>182 <Time>2014-07-04T10:51:24.789244+03:00</Time> 183 183 </Item> 184 184 <Item> … … 343 343 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\Explosion3.xnb</Output> 344 344 <Time>2014-07-04T10:26:40.9532675+03:00</Time> 345 </Item> 346 <Item> 347 <Source>graphics\Planets\MapPlanet1.png</Source> 348 <Name>graphics\Planets\MapPlanet1</Name> 349 <Importer>TextureImporter</Importer> 350 <Processor>TextureProcessor</Processor> 351 <Options>None</Options> 352 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet1.xnb</Output> 353 <Time>2014-07-04T10:33:09.6505335+03:00</Time> 354 </Item> 355 <Item> 356 <Source>graphics\Planets\MapPlanet2.png</Source> 357 <Name>graphics\Planets\MapPlanet2</Name> 358 <Importer>TextureImporter</Importer> 359 <Processor>TextureProcessor</Processor> 360 <Options>None</Options> 361 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet2.xnb</Output> 362 <Time>2014-07-04T10:33:09.6661336+03:00</Time> 363 </Item> 364 <Item> 365 <Source>graphics\Planets\MapPlanet3.png</Source> 366 <Name>graphics\Planets\MapPlanet3</Name> 367 <Importer>TextureImporter</Importer> 368 <Processor>TextureProcessor</Processor> 369 <Options>None</Options> 370 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet3.xnb</Output> 371 <Time>2014-07-04T10:33:09.6661336+03:00</Time> 372 </Item> 373 <Item> 374 <Source>graphics\Planets\MapPlanet4.png</Source> 375 <Name>graphics\Planets\MapPlanet4</Name> 376 <Importer>TextureImporter</Importer> 377 <Processor>TextureProcessor</Processor> 378 <Options>None</Options> 379 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet4.xnb</Output> 380 <Time>2014-07-04T10:33:09.6661336+03:00</Time> 381 </Item> 382 <Item> 383 <Source>graphics\Planets\MapPlanet5.png</Source> 384 <Name>graphics\Planets\MapPlanet5</Name> 385 <Importer>TextureImporter</Importer> 386 <Processor>TextureProcessor</Processor> 387 <Options>None</Options> 388 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet5.xnb</Output> 389 <Time>2014-07-04T10:33:09.6817337+03:00</Time> 390 </Item> 391 <Item> 392 <Source>graphics\Planets\MapPlanet6.png</Source> 393 <Name>graphics\Planets\MapPlanet6</Name> 394 <Importer>TextureImporter</Importer> 395 <Processor>TextureProcessor</Processor> 396 <Options>None</Options> 397 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet6.xnb</Output> 398 <Time>2014-07-04T10:33:09.6817337+03:00</Time> 399 </Item> 400 <Item> 401 <Source>music\SmoothSpaceJazz.mp3</Source> 402 <Name>music\SmoothSpaceJazz</Name> 403 <Importer>Mp3Importer</Importer> 404 <Processor>SongProcessor</Processor> 405 <Options>None</Options> 406 <Output>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\SmoothSpaceJazz.xnb</Output> 407 <Extra>C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\SmoothSpaceJazz.wma</Extra> 408 <Time>2014-07-03T09:33:58.9783652+03:00</Time> 345 409 </Item> 346 410 <BuildSuccessful>true</BuildSuccessful> -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/obj/x86/Debug/Protokolla236TrueSurvivor.csproj.FileListAbsolute.txt
r5408 r5412 97 97 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\nitrome - thin ice.wma 98 98 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\nitrome - worm food.wma 99 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet1.xnb 100 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet2.xnb 101 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet3.xnb 102 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet4.xnb 103 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet5.xnb 104 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\graphics\Planets\MapPlanet6.xnb 105 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\SmoothSpaceJazz.xnb 106 C:\MyTemp\AleksanteriV\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\Protokolla236TrueSurvivor\bin\x86\Debug\Content\music\SmoothSpaceJazz.wma -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/obj/x86/Debug/cachefile-{5156C658-EF8C-4216-BA6D-9928D133FE72}-targetpath.txt
r5408 r5412 45 45 Content\music\nitrome - worm food.wma 46 46 Content\music\Explosion3.xnb 47 Content\graphics\Planets\MapPlanet1.xnb 48 Content\graphics\Planets\MapPlanet2.xnb 49 Content\graphics\Planets\MapPlanet3.xnb 50 Content\graphics\Planets\MapPlanet4.xnb 51 Content\graphics\Planets\MapPlanet5.xnb 52 Content\graphics\Planets\MapPlanet6.xnb 53 Content\music\SmoothSpaceJazz.xnb 54 Content\music\SmoothSpaceJazz.wma -
2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivorContent/Protokolla236TrueSurvivorContent.contentproj
r5408 r5412 269 269 </Compile> 270 270 </ItemGroup> 271 <ItemGroup> 272 <Compile Include="graphics\Planets\MapPlanet1.png"> 273 <Name>MapPlanet1</Name> 274 <Importer>TextureImporter</Importer> 275 <Processor>TextureProcessor</Processor> 276 </Compile> 277 <Compile Include="graphics\Planets\MapPlanet2.png"> 278 <Name>MapPlanet2</Name> 279 <Importer>TextureImporter</Importer> 280 <Processor>TextureProcessor</Processor> 281 </Compile> 282 <Compile Include="graphics\Planets\MapPlanet3.png"> 283 <Name>MapPlanet3</Name> 284 <Importer>TextureImporter</Importer> 285 <Processor>TextureProcessor</Processor> 286 </Compile> 287 <Compile Include="graphics\Planets\MapPlanet4.png"> 288 <Name>MapPlanet4</Name> 289 <Importer>TextureImporter</Importer> 290 <Processor>TextureProcessor</Processor> 291 </Compile> 292 <Compile Include="graphics\Planets\MapPlanet5.png"> 293 <Name>MapPlanet5</Name> 294 <Importer>TextureImporter</Importer> 295 <Processor>TextureProcessor</Processor> 296 </Compile> 297 <Compile Include="graphics\Planets\MapPlanet6.png"> 298 <Name>MapPlanet6</Name> 299 <Importer>TextureImporter</Importer> 300 <Processor>TextureProcessor</Processor> 301 </Compile> 302 </ItemGroup> 303 <ItemGroup> 304 <Compile Include="music\SmoothSpaceJazz.mp3"> 305 <Name>SmoothSpaceJazz</Name> 306 <Importer>Mp3Importer</Importer> 307 <Processor>SongProcessor</Processor> 308 </Compile> 309 </ItemGroup> 271 310 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 272 311 <!-- 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.