Changeset 2955
- Timestamp:
- 2012-06-12 14:39:31 (11 years ago)
- Location:
- 2012/24/JaakkoL/Crisis Fire
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Crisis Fire.csproj
r2908 r2955 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="Bullets.cs" />114 113 <Compile Include="Ohjelma.cs" /> 115 114 <Compile Include="Peli.cs" /> -
2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Peli.cs
r2936 r2955 6 6 using Jypeli.Effects; 7 7 using Jypeli.Widgets; 8 9 class Player : PhysicsObject 10 { 11 public int HPP = 1; 12 13 public Player(double height, double width) 14 : base(height, width) 15 { 16 } 17 } 18 19 class Enemy : PhysicsObject 20 { 21 public int HP; 22 public int SaatavatPisteet; 23 24 public Enemy(double height, double width) 25 : base(height, width) 26 { 27 } 28 } 8 29 9 30 class CrisisFire : PhysicsGame … … 17 38 Vector VelocityRight = new Vector(250.0, 0.0); 18 39 Vector FocusedVelocityRight = new Vector(125.0, 0.0); 19 P hysicsObjectPlayer;20 PhysicsObjectSmallEnemy;21 PhysicsObjectEnemy;22 PhysicsObjectLargeEnemy;23 PhysicsObjectBoss;40 Player Player; 41 Enemy SmallEnemy; 42 Enemy Enemy; 43 Enemy LargeEnemy; 44 Enemy Boss; 24 45 PhysicsObject BorderTop; 25 46 PhysicsObject BorderBottom; 47 PhysicsObject BorderLeft; 26 48 IntMeter PowerGauge; 49 IntMeter ScoreGauge; 27 50 28 51 public override void Begin() … … 31 54 SetControls(); 32 55 CreatePowerGauge(); 56 CreateScoreGauge(); 33 57 } 34 58 35 59 void Field() 36 60 { 37 Level.CreateBorders(false);38 61 Level.BackgroundColor = Color.Gray; 39 62 Camera.ZoomToLevel(); 40 63 41 BorderTop = new PhysicsObject( 1000.0, 150.0, Shape.Rectangle);64 BorderTop = new PhysicsObject(20000.0, 150.0, Shape.Rectangle); 42 65 BorderTop.Y = Screen.Top - 150.0; 43 66 BorderTop.X = 0.0; 67 BorderTop.Mass = 99999999999999999999999999999.0; 68 BorderTop.Restitution = 0.0; 44 69 BorderTop.Color = Color.Black; 45 BorderTop.Restitution = 0.0; 46 BorderTop.Mass = 9999999999999.0; 70 BorderTop.IgnoresGravity = true; 47 71 Add(BorderTop); 48 72 49 BorderBottom = new PhysicsObject( 1000.0, 150.0, Shape.Rectangle);73 BorderBottom = new PhysicsObject(20000.0, 150.0, Shape.Rectangle); 50 74 BorderBottom.Y = Screen.Bottom + 150.0; 51 75 BorderBottom.X = 0.0; 76 BorderBottom.Mass = 9999999999999999999999999999999.0; 77 BorderBottom.Restitution = 0.0; 52 78 BorderBottom.Color = Color.Black; 53 BorderBottom.Restitution = 0.0; 54 BorderBottom.Mass = 99999999999999.0; 79 BorderBottom.IgnoresGravity = true; 55 80 Add(BorderBottom); 56 81 57 Player = new PhysicsObject(10.0, 10.0, Shape.Circle); 82 BorderLeft = new PhysicsObject(100.0, 800.0, Shape.Rectangle); 83 BorderLeft.Y = 0; 84 BorderLeft.X = Screen.Left + 90.0; 85 BorderLeft.Mass = 9999999999999999999999999999999.0; 86 BorderLeft.Restitution = 0.0; 87 BorderLeft.Color = Color.Black; 88 BorderLeft.IgnoresGravity = true; 89 Add(BorderLeft); 90 91 Player = new Player(10.0, 10.0); 58 92 double massP1 = 10.0; 59 93 Player.Mass = massP1; 94 Player.Shape = Shape.Circle; 60 95 Player.Color = Color.Red; 61 96 Player.X = -400.0; 62 97 Player.Y = 0.0; 63 98 Player.IgnoresGravity = true; 64 99 Add(Player); 100 101 Gravity = new Vector(-200.0, 0.0); 102 // Creates the level's borders and player. 103 // Note that you have 0 lives, the game is over if you are hit. But that's kind of a score attack SHMUP's idea. 104 } 105 106 void EnemySpawns() 107 { 108 65 109 } 66 110 … … 77 121 ControllerOne.Listen(Button.DPadRight, ButtonState.Released, SetVelocity, null, Player, Vector.Zero); 78 122 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, null); 79 ControllerOne.Listen(Button.RightTrigger, ButtonState.Pressed, FirePrimary, null, Player, 10.0, 5.0, Shape.Rectangle);123 ControllerOne.Listen(Button.RightTrigger, ButtonState.Pressed, FirePrimary, null, Player, 10.0, 2.5, Shape.Rectangle); 80 124 ControllerOne.Listen(Button.LeftTrigger, ButtonState.Pressed, FireSecondary, null, Player, 25.0, 10.0, Shape.Diamond); 125 // Sets controls. Focused movement is currently not implemented 81 126 } 82 127 83 128 void FirePrimary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 84 129 { 85 PhysicsObject Primary1 = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 86 Primary1.X = Player.X + 15; 87 Primary1.Y = Player.Y + 5; 88 PhysicsObject Primary2 = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 89 Primary2.X = Player.X + 15; 90 Primary2.Y = Player.Y - 5; 91 Add(Primary1); 92 Add(Primary2); 93 Primary1.Hit(new Vector(1200.0, 0.0)); 94 Primary2.Hit(new Vector(1200.0, 0.0)); 130 CreatePrimary(Player.X + 20, Player.Y + 10, 12.0, 3.0, new Vector(750.0, 25.0), 10); 131 CreatePrimary(Player.X + 20, Player.Y + 4, 12.0, 3.0, new Vector(750.0, -25.0), 10); 132 CreatePrimary(Player.X + 10, Player.Y + 17, 8.0, 2.0, new Vector(750.0, 100.0), 5); 133 CreatePrimary(Player.X + 10, Player.Y - 3, 8.0, 2.0, new Vector(750.0, -100.0), 5); 134 // Fires a wide, relatively slow shotgun-like 4 bullet spread from the top gun 135 } 136 137 void CreatePrimary(double x, double y, double sizeX, double sizeY, Vector PrimaryImpulse, int DamagePrimary) 138 { 139 PhysicsObject Primary = new PhysicsObject(sizeX, sizeY); 140 Primary.Color = Color.White; 141 Primary.X = x; 142 Primary.Y = y; 143 Primary.IgnoresGravity = true; 144 Add(Primary); 145 Primary.Hit(PrimaryImpulse); 95 146 } 96 147 97 148 void FireSecondary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 98 149 { 99 PhysicsObject Secondary = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 100 Secondary.X = Player.X + 15; 101 Secondary.Y = Player.Y; 150 CreateSecondary(Player.X + 20, Player.Y - 4, 15.0, 5.0, new Vector(1200.0, 0.0), 20); 151 CreateSecondary(Player.X + 20, Player.Y - 10, 15.0, 5.0, new Vector(1200.0, 0.0), 20); 152 // Fires a fast and powerful double-barrel shot from the bottom gun 153 } 154 155 void CreateSecondary(double X, double Y, double SizeX, double SizeY, Vector SecondaryImpulse, int DamageSecondary) 156 { 157 PhysicsObject Secondary = new PhysicsObject(SizeX, SizeY); 158 Secondary.Shape = Shape.Diamond; 159 Secondary.Color = Color.White; 160 Secondary.X = X; 161 Secondary.Y = Y; 162 Secondary.IgnoresGravity = true; 102 163 Add(Secondary); 103 Secondary.Hit( new Vector(500.0, 0.0));164 Secondary.Hit(SecondaryImpulse); 104 165 } 105 166 … … 123 184 124 185 Label PowerText = new Label("Power: "); 125 PowerText.X = Screen.Left + 10 0;186 PowerText.X = Screen.Left + 108; 126 187 PowerText.Y = Screen.Top - 100; 127 188 PowerText.TextColor = Color.White; … … 129 190 Add(PowerText); 130 191 } 192 193 void CreateScoreGauge() 194 { 195 ScoreGauge = new IntMeter(0); 196 197 Label ScoreMeter = new Label(); 198 ScoreMeter.X = Screen.Right - 150; 199 ScoreMeter.Y = Screen.Top - 100; 200 ScoreMeter.TextColor = Color.White; 201 ScoreMeter.Color = Color.DarkGreen; 202 203 ScoreMeter.BindTo(ScoreGauge); 204 Add(ScoreMeter); 205 206 Label ScoreText = new Label("Score: "); 207 ScoreText.X = Screen.Right - 190; 208 ScoreText.Y = Screen.Top - 100; 209 ScoreText.TextColor = Color.White; 210 ScoreText.Color = Color.DarkGreen; 211 Add(ScoreText); 212 } 131 213 } 132
Note: See TracChangeset
for help on using the changeset viewer.