- Timestamp:
- 2012-06-13 15:12:56 (11 years ago)
- Location:
- 2012/24/JaakkoL/Crisis Fire
- Files:
-
- 5 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Crisis Fire.csproj
r2981 r3010 62 62 </PropertyGroup> 63 63 <ItemGroup> 64 <Reference Include="Jypeli4"> 64 <Reference Include="Jypeli4, Version=4.2.1.0, Culture=neutral, processorArchitecture=x86"> 65 <SpecificVersion>False</SpecificVersion> 66 <HintPath>..\..\..\..\..\Program Files (x86)\Jypeli\lib\x86\Jypeli4.dll</HintPath> 65 67 </Reference> 66 68 <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> … … 116 118 </ItemGroup> 117 119 <ItemGroup> 118 <Compile Include="FieldFromTilemap.txt">119 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>120 </Compile>121 120 <Content Include="Game.ico" /> 122 121 <Content Include="GameThumbnail.png" /> -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Peli.cs
r2982 r3010 7 7 using Jypeli.Widgets; 8 8 9 class Player : PhysicsObject10 {11 public int HPP = 1;12 13 public Player(double height, double width)14 : base(height, width)15 {16 }17 }18 19 9 class Enemy : PhysicsObject 20 10 { … … 28 18 } 29 19 20 class Bullet : PhysicsObject 21 { 22 public int Damage; 23 24 public Bullet(double height, double width) 25 : base(height, width) 26 { 27 } 28 } 29 30 30 class CrisisFire : PhysicsGame 31 31 { 32 Vector VelocityUp = new Vector(0.0, 250.0);33 Vector FocusedVelocityUp = new Vector(0.0, 125.0);34 Vector VelocityDown = new Vector(0.0, - 250.0);35 Vector FocusedVelocityDown = new Vector(0.0, - 125.0);36 Vector VelocityLeft = new Vector(- 250.0, 0.0);37 Vector FocusedVelocityLeft = new Vector(- 125.0, 0.0);38 Vector VelocityRight = new Vector( 250.0, 0.0);39 Vector FocusedVelocityRight = new Vector( 125.0, 0.0);40 P layerPlayer;32 Vector VelocityUp = new Vector(0.0, 500.0); 33 Vector FocusedVelocityUp = new Vector(0.0, 250.0); 34 Vector VelocityDown = new Vector(0.0, -500.0); 35 Vector FocusedVelocityDown = new Vector(0.0, -250.0); 36 Vector VelocityLeft = new Vector(-500.0, 0.0); 37 Vector FocusedVelocityLeft = new Vector(-250.0, 0.0); 38 Vector VelocityRight = new Vector(500.0, 0.0); 39 Vector FocusedVelocityRight = new Vector(250.0, 0.0); 40 PhysicsObject Player; 41 41 Enemy SmallEnemy; 42 42 Enemy Enemy; 43 43 Enemy LargeEnemy; 44 44 Enemy Boss; 45 PhysicsObject Border;46 45 PhysicsObject KillBorder; 47 46 PhysicsObject Threshold; … … 60 59 { 61 60 TileMap LevelSpawns = TileMap.FromLevelAsset("FieldFromTilemap"); 62 Level.BackgroundColor = Color.Gray; 63 64 LevelSpawns.SetTileMethod('-', CreateBorder); 61 Level.BackgroundColor = Color.DarkGray; 62 65 63 LevelSpawns.SetTileMethod('/', CreateThreshold); 66 64 LevelSpawns.SetTileMethod('|', CreateKillBorder); … … 71 69 LevelSpawns.SetTileMethod('B', SpawnBoss); 72 70 73 Camera.ZoomTo(-512, -384, 512, 384); 74 75 Gravity = new Vector(-200.0, 0.0); 71 LevelSpawns.Execute(90, 90); 72 Level.CreateBorders(); 73 Camera.StayInLevel = true; 74 Camera.FollowedObject = Player; 75 76 Gravity = new Vector(-400.0, 0.0); 76 77 // Assigns the spawn methods to the game's tilemap and adds constant gravity (which only affects enemies) 77 78 } … … 81 82 height = 10.0; 82 83 width = 10.0; 83 Player = new P layer(height, width);84 Player = new PhysicsObject(height, width); 84 85 double massP1 = 10.0; 85 86 Player.Mass = massP1; 87 Player.Restitution = 0.0; 88 Player.LinearDamping = 0.85; 89 Player.IgnoresGravity = true; 86 90 Player.Position = PPosition; 87 91 Player.Shape = Shape.Circle; 88 92 Player.Color = Color.Red; 89 Player.IgnoresGravity = true;90 93 Player.Tag = "P1"; 94 AddCollisionHandler(Player, "KB", KillBorderCollision); 91 95 Add(Player); 92 // Creates the player's ship 93 } 94 95 void CreateBorder(Vector BorPosition, double height, double width) 96 { 97 PhysicsObject Border = PhysicsObject.CreateStaticObject(height, width); 98 Border.Position = BorPosition; 99 Border.Shape = Shape.Rectangle; 100 Border.Color = Color.Black; 101 Border.Restitution = 0.0; 102 Border.Mass = 999999999999999.0; 103 Add(Border); 104 // Creates the level's borders 96 // Creates the player's ship and the collision handler for the Kill Border 105 97 } 106 98 107 99 void CreateKillBorder(Vector KBPosition, double height, double width) 108 100 { 109 PhysicsObjectKillBorder = PhysicsObject.CreateStaticObject(height, width);101 KillBorder = PhysicsObject.CreateStaticObject(height, width); 110 102 KillBorder.Position = KBPosition; 111 103 KillBorder.Shape = Shape.Rectangle; 112 104 KillBorder.Color = Color.Red; 105 KillBorder.Tag = "KB"; 113 106 KillBorder.IgnoresCollisionResponse = true; 114 AddCollisionHandler(Player, KillBorderCollision);115 107 Add(KillBorder); 116 108 // Adds a border that the player cannot cross without dying; this is to prevent moving out of the camera bounds 117 109 } 118 110 119 void KillBorderCollision(PhysicsObject Player, PhysicsObject KillBorder) 120 { 121 Remove(Player); 111 void KillBorderCollision(IPhysicsObject Player, IPhysicsObject KillBorder) 112 { 113 PowerGauge.Value = RandomGen.NextInt(0, 127); 114 Player.Destroy(); 122 115 MessageDisplay.Add("The force field vaporized you."); 123 Timer.SingleShot(2.0, GameOverFF); 124 Timer.SingleShot(5.0, Exit); 125 } 126 127 void GameOverFF() 116 Timer.SingleShot(2.0, GameOver); 117 Timer.SingleShot(6.0, Exit); 118 // What happens if the player hits the Kill Border 119 } 120 121 void GameOver() 128 122 { 129 123 Label GameOver = new Label(300.0, 100.0, "Game Over"); … … 136 130 void CreateThreshold(Vector THPosition, double height, double width) 137 131 { 138 PhysicsObjectThreshold = PhysicsObject.CreateStaticObject(height, width);132 Threshold = PhysicsObject.CreateStaticObject(height, width); 139 133 Threshold.Position = THPosition; 140 134 Threshold.Shape = Shape.Rectangle; 141 135 Threshold.Color = Color.DarkOrange; 142 136 Threshold.IgnoresCollisionResponse = true; 143 AddCollisionHandler <PhysicsObject,Enemy>(Threshold, EnemyReachesThreshold);137 AddCollisionHandler(Threshold, EnemyReachesThreshold); 144 138 Add(Threshold); 145 } 146 147 void EnemyReachesThreshold(PhysicsObject Threshold, Enemy Target) 148 { 149 if (Target.Tag == "Enemy") 150 { 151 ScoreGauge.Value = ScoreGauge.Value - Target.ScoreValue / 2; 152 Remove(Target); 153 } 154 } 155 139 // The score-lowering threshold 140 } 141 142 void EnemyReachesThreshold(IPhysicsObject Threshold, IPhysicsObject Target) 143 { 144 Enemy targetEnemy = Target as Enemy; 145 146 if (Target.Tag.ToString() == "Enemy") 147 { 148 ScoreGauge.Value = ScoreGauge.Value -= targetEnemy.ScoreValue / 2; 149 Target.Destroy(); 150 } 151 } 156 152 157 153 void SpawnSmallEnemy(Vector SEPosition, double height, double width) 158 154 { 159 155 height = 25.0; 156 width = 25.0; 157 SmallEnemy = new Enemy(height, width); 158 SmallEnemy.Position = SEPosition; 159 SmallEnemy.Shape = Shape.Ellipse; 160 SmallEnemy.Color = Color.Green; 161 SmallEnemy.Restitution = 0.8; 162 SmallEnemy.ScoreValue = 40; 163 SmallEnemy.HP = 100; 164 SmallEnemy.LinearDamping = 0.95; 165 SmallEnemy.Tag = "Enemy"; 166 AddCollisionHandler(SmallEnemy, "P1", PlayerDestruction); 167 Add(SmallEnemy); 168 // The smallest enemy type 160 169 } 161 170 162 171 void SpawnEnemy(Vector EPosition, double height, double width) 163 172 { 164 173 height = 70.0; 174 width = 70.0; 175 Enemy = new Enemy(height, width); 176 Enemy.Position = EPosition; 177 Enemy.Shape = Shape.Ellipse; 178 Enemy.Color = Color.Green; 179 Enemy.Restitution = 0.5; 180 Enemy.LinearDamping = 0.95; 181 Enemy.ScoreValue = 200; 182 Enemy.HP = 250; 183 Enemy.Tag = "Enemy"; 184 AddCollisionHandler(Enemy, "P1", PlayerDestruction); 185 Add(Enemy); 186 // The medium enemy type 165 187 } 166 188 167 189 void SpawnLargeEnemy(Vector LEPosition, double height, double width) 168 190 { 169 170 } 171 172 void SpawnBoss(Vector BPosition, double height, double width) 173 { 174 191 height = 150.0; 192 width = 150.0; 193 LargeEnemy = new Enemy(height, width); 194 LargeEnemy.Position = LEPosition; 195 LargeEnemy.Shape = Shape.Ellipse; 196 LargeEnemy.Color = Color.Green; 197 LargeEnemy.Restitution = 0.35; 198 LargeEnemy.LinearDamping = 0.95; 199 LargeEnemy.ScoreValue = 500; 200 LargeEnemy.HP = 800; 201 LargeEnemy.Tag = "Enemy"; 202 AddCollisionHandler(LargeEnemy, "P1", PlayerDestruction); 203 Add(LargeEnemy); 204 // The large enemy type 205 } 206 207 void SpawnBoss(Vector BPosition, double width, double height) 208 { 209 height = 800.0; 210 width = 500.0; 211 Boss = new Enemy(width, height); 212 Boss.Position = BPosition; 213 Boss.Shape = Shape.Ellipse; 214 Boss.Color = Color.DarkGreen; 215 Boss.Restitution = 0.1; 216 Boss.LinearDamping = 0.95; 217 Boss.ScoreValue = 3000; 218 Boss.HP = 5000; 219 Boss.Tag = "Enemy"; 220 AddCollisionHandler(Boss, "P1", PlayerDestruction); 221 Add(Boss); 222 // The boss. Obviously the larget enemy type 223 } 224 225 void PlayerDestruction(IPhysicsObject Collider, IPhysicsObject Player) 226 { 227 Enemy collidingEnemy = Collider as Enemy; 228 229 if (Collider.Tag.ToString() == "Enemy") 230 { 231 PowerGauge.Value = RandomGen.NextInt(0, 127); 232 Player.Destroy(); 233 MessageDisplay.Add("You have died."); 234 Timer.SingleShot(2.0, GameOver); 235 Timer.SingleShot(6.0, Exit); 236 } 175 237 } 176 238 … … 194 256 void FirePrimary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 195 257 { 196 CreatePrimary(Player.X + 20, Player.Y + 10, 12.0, 3.0, new Vector(750.0, 25.0), 10); 197 CreatePrimary(Player.X + 20, Player.Y + 4, 12.0, 3.0, new Vector(750.0, -25.0), 10); 198 CreatePrimary(Player.X + 10, Player.Y + 17, 8.0, 2.0, new Vector(750.0, 100.0), 5); 199 CreatePrimary(Player.X + 10, Player.Y - 3, 8.0, 2.0, new Vector(750.0, -100.0), 5); 200 // Fires a wide, relatively slow shotgun-like 4 bullet spread from the top gun 201 } 202 203 void CreatePrimary(double x, double y, double sizeX, double sizeY, Vector PrimaryImpulse, int DamagePrimary) 204 { 205 PhysicsObject Primary = new PhysicsObject(sizeX, sizeY); 258 if (PowerGauge.Value < 128) 259 { 260 CreatePrimary(Player.X + 20, Player.Y + 10, 12.0, 3.0, new Vector(725.0, 30.0)); 261 CreatePrimary(Player.X + 20, Player.Y + 4, 12.0, 3.0, new Vector(725.0, -30.0)); 262 CreatePrimary(Player.X + 10, Player.Y + 17, 12.0, 3.0, new Vector(725.0, 120.0)); 263 CreatePrimary(Player.X + 10, Player.Y - 3, 12.0, 3.0, new Vector(725.0, -120.0)); 264 // Fires a wide, relatively slow shotgun-like 4 bullet spread from the top gun 265 } 266 else if (PowerGauge.Value == 128) 267 { 268 CreatePrimary(Player.X + 25, Player.Y, 15.0, 4.0, new Vector(800.0, 0.0)); 269 CreatePrimary(Player.X + 22, Player.Y + 12, 15.0, 4.0, new Vector(800.0, 30.0)); 270 CreatePrimary(Player.X + 22, Player.Y + 5, 15.0, 4.0, new Vector(800.0, -30.0)); 271 CreatePrimary(Player.X + 11, Player.Y + 20, 15.0, 4.0, new Vector(800.0, 120.0)); 272 CreatePrimary(Player.X + 11, Player.Y - 1, 15.0, 4.0, new Vector(800.0, -120.0)); 273 } 274 } 275 276 void CreatePrimary(double x, double y, double sizeX, double sizeY, Vector PrimaryImpulse) 277 { 278 Bullet Primary = new Bullet(sizeX, sizeY); 206 279 Primary.Color = Color.White; 207 280 Primary.X = x; 208 281 Primary.Y = y; 282 283 if (PowerGauge.Value == 128) 284 { 285 Primary.Damage = 15; 286 } 287 else if (PowerGauge.Value < 128) 288 { 289 Primary.Damage = 8; 290 } 291 292 Primary.Mass = 1; 209 293 Primary.IgnoresGravity = true; 210 294 AddCollisionHandler(Primary, PrimaryDamagesEnemy); … … 213 297 } 214 298 215 void PrimaryDamagesEnemy(PhysicsObject Primary, PhysicsObject Target) 216 { 217 if (Target.Tag == "Enemy") 218 { 219 299 void PrimaryDamagesEnemy(IPhysicsObject Primary, IPhysicsObject Target) 300 { 301 Bullet primaryBullet = Primary as Bullet; 302 Enemy targetEnemy = Target as Enemy; 303 304 if (Target.Tag.ToString() == "Enemy") 305 { 306 targetEnemy.HP -= primaryBullet.Damage; 307 primaryBullet.Destroy(); 308 309 if (targetEnemy.HP < 0) 310 { 311 ScoreGauge.Value += targetEnemy.ScoreValue; 312 targetEnemy.Destroy(); 313 } 314 } 315 else if (Target.Tag.ToString() == "KB") 316 { 317 primaryBullet.Destroy(); 318 } 319 else if (Target.Tag.ToString() == "LB") 320 { 321 primaryBullet.Destroy(); 220 322 } 221 323 } … … 223 325 void FireSecondary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 224 326 { 225 CreateSecondary(Player.X + 20, Player.Y - 4, 15.0, 5.0, new Vector(1200.0, 0.0) , 20);226 CreateSecondary(Player.X + 20, Player.Y - 10, 15.0, 5.0, new Vector(1200.0, 0.0) , 20);327 CreateSecondary(Player.X + 20, Player.Y - 4, 15.0, 5.0, new Vector(1200.0, 0.0)); 328 CreateSecondary(Player.X + 20, Player.Y - 10, 15.0, 5.0, new Vector(1200.0, 0.0)); 227 329 // Fires a fast and powerful double-barrel shot from the bottom gun 228 330 } 229 331 230 void CreateSecondary(double X, double Y, double SizeX, double SizeY, Vector SecondaryImpulse , int DamageSecondary)231 { 232 PhysicsObject Secondary = new PhysicsObject(SizeX, SizeY);332 void CreateSecondary(double X, double Y, double SizeX, double SizeY, Vector SecondaryImpulse) 333 { 334 Bullet Secondary = new Bullet(SizeX, SizeY); 233 335 Secondary.Shape = Shape.Diamond; 234 336 Secondary.Color = Color.White; 235 337 Secondary.X = X; 236 338 Secondary.Y = Y; 339 Secondary.Damage = 25; 340 Secondary.Mass = 1; 237 341 Secondary.IgnoresGravity = true; 238 342 AddCollisionHandler(Secondary, SecondaryDamagesEnemy); … … 241 345 } 242 346 243 void SecondaryDamagesEnemy(PhysicsObject Secondary, PhysicsObject Target) 244 { 245 if (Target.Tag == "Enemy") 246 { 247 347 void SecondaryDamagesEnemy(IPhysicsObject Secondary, IPhysicsObject Target) 348 { 349 Bullet secondaryBullet = Secondary as Bullet; 350 Enemy targetEnemy = Target as Enemy; 351 352 if (Target.Tag.ToString() == "Enemy") 353 { 354 targetEnemy.HP -= secondaryBullet.Damage; 355 secondaryBullet.Destroy(); 356 357 if (targetEnemy.HP < 0) 358 { 359 ScoreGauge.Value += targetEnemy.ScoreValue; 360 targetEnemy.Destroy(); 361 } 362 } 363 else if (Target.Tag.ToString() == "KB") 364 { 365 secondaryBullet.Destroy(); 366 } 367 else if (Target.Tag.ToString() == "LB") 368 { 369 secondaryBullet.Destroy(); 248 370 } 249 371 } … … 268 390 269 391 Label PowerText = new Label("Power: "); 270 PowerText.X = Screen.Left + 108;392 PowerText.X = Screen.Left + 50; 271 393 PowerText.Y = Screen.Top - 100; 272 394 PowerText.TextColor = Color.White; … … 289 411 290 412 Label ScoreText = new Label("Score: "); 291 ScoreText.X = Screen.Right - 190;413 ScoreText.X = Screen.Right - 300; 292 414 ScoreText.Y = Screen.Top - 100; 293 415 ScoreText.TextColor = Color.White; -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/ContentPipeline-{7ACFD14C-C6F7-4882-A22A-55EBD417A6D1}.xml
r2982 r3010 5 5 <Source>FieldFromTilemap.txt</Source> 6 6 <Name>FieldFromTilemap</Name> 7 <Importer>Text ureImporter</Importer>8 <Processor> PassThroughProcessor</Processor>7 <Importer>TextFileImporter</Importer> 8 <Processor>TextFileContentProcessor</Processor> 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\JaakkoL\Crisis Fire\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\FieldFromTilemap.xnb</Output> 11 <Time> 0001-01-01T00:00:00</Time>11 <Time>2012-06-13T13:39:14.9145117+03:00</Time> 12 12 </Item> 13 <BuildSuccessful> false</BuildSuccessful>13 <BuildSuccessful>true</BuildSuccessful> 14 14 <Settings> 15 15 <ContentProjectGUID>{7ACFD14C-C6F7-4882-A22A-55EBD417A6D1}</ContentProjectGUID> … … 24 24 </Settings> 25 25 <Assemblies> 26 <Assembly> 27 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 28 <Value>2012-04-23T14:23:36+03:00</Value> 29 </Assembly> 26 30 <Assembly> 27 31 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key> … … 50 54 <Assembly> 51 55 <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 52 <Value>2012-03-16T14:3 3:41.9515583+02:00</Value>56 <Value>2012-03-16T14:34:34.1534733+02:00</Value> 53 57 </Assembly> 54 58 </Assemblies> -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/Crisis Fire.csproj.FileListAbsolute.txt
r2908 r3010 7 7 C:\MyTemp\JaakkoL\Crisis Fire\FysiikkaPeli1\FysiikkaPeli1\obj\x86\Debug\FysiikkaPeli1.exe 8 8 C:\MyTemp\JaakkoL\Crisis Fire\FysiikkaPeli1\FysiikkaPeli1\obj\x86\Debug\FysiikkaPeli1.pdb 9 C:\MyTemp\JaakkoL\Crisis Fire\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\FieldFromTilemap.xnb 10 C:\MyTemp\JaakkoL\Crisis Fire\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\FieldFromTilemap.txt -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1Content/Crisis Fire Content.contentproj
r2981 r3010 41 41 <Private>False</Private> 42 42 </Reference> 43 <Reference Include="TextFileContentExtension"> 44 <HintPath>..\..\..\..\..\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</HintPath> 45 </Reference> 43 46 </ItemGroup> 44 47 <ItemGroup> 45 48 <Compile Include="FieldFromTilemap.txt"> 49 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 46 50 <Name>FieldFromTilemap</Name> 47 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 48 <Processor>PassThroughProcessor</Processor> 49 <Importer>TextureImporter</Importer> 51 <Importer>TextFileImporter</Importer> 52 <Processor>TextFileContentProcessor</Processor> 50 53 </Compile> 51 54 </ItemGroup> -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1Content/FieldFromTilemap.txt
r2979 r3010 1 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3 -/ | S S S S S S - 4 -/ | S M S L S M - 5 -/ | S S M S M M S - 6 -/ | S S S L S S S L - 7 -/ P | S M S L M L M M L S S M B - 8 -/ | S S S L S S S L - 9 -/ | S S S M M S - 10 -/ | S S S L S M - 11 -/ | S S S S S S S - 12 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 -/ | S S S S S S - 2 -/ | S M S L S M - 3 -/ | S S M S M M S - 4 -/ | S S S L S S S L - 5 -/ P | S M S L M L M M L S S M B - 6 -/ | S S S L S S S L - 7 -/ | S S S M M S - 8 -/ | S S S L S M - 9 -/ | S S S S S S S -
Note: See TracChangeset
for help on using the changeset viewer.