- Timestamp:
- 2010-07-29 14:58:30 (13 years ago)
- Location:
- 2010/30/janiemit/FysiikkaPeli3
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/janiemit/FysiikkaPeli3/Content/Content.contentproj
r1391 r1422 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>bbf0e456-f1a8-4ee6-a9de-9bddcd14d51f</ProjectGuid> … … 34 34 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 35 35 </ItemGroup> 36 <ItemGroup> 37 <Compile Include="avaruus.jpg"> 38 <Name>avaruus</Name> 39 <Importer>TextureImporter</Importer> 40 <Processor>TextureProcessor</Processor> 41 </Compile> 42 </ItemGroup> 36 43 </Project> -
2010/30/janiemit/FysiikkaPeli3/Peli.cs
r1391 r1422 3 3 using Jypeli.Widgets; 4 4 using Jypeli.Assets; 5 using Jypeli.Effects; 6 5 7 6 8 public class Peli : PhysicsGame 7 9 { 10 int elamiaAlussa = 50; 8 11 Vector nopeusoikealle = new Vector(2000, 0); 9 12 Vector nopeusvasemmalle = new Vector(-2000, 0); 10 13 const double pallonNopeus = 500; 14 Image taustaKuva = LoadImage("avaruus"); 15 16 11 17 12 18 Vector pysahdy = new Vector(0, 0); … … 16 22 // PhysicsObject maila2; 17 23 IntMeter pelaajan1Pisteet; 18 IntMeter pelaajanhp; 24 IntMeter pelaajanhp; 25 int rajahdyslaskuri; 26 19 27 20 28 21 29 protected override void Begin() 22 30 { 23 31 ClearAll(); 24 32 LuoKentta(); 25 33 AsetaOhjaimet(); 26 34 AloitaPeli(); 27 35 LisaaLaskurit(); 28 29 30 31 32 } 36 Level.Background.Image = taustaKuva; 37 rajahdyslaskuri = 0; 38 } 39 33 40 34 41 void TiileenTormattiin(PhysicsObject tiili, PhysicsObject tormaaja) … … 40 47 { 41 48 Timer.SingleShot(0.1, tiili.Destroy); 42 43 44 45 pelaajan1Pisteet.Value += 10; 49 Explosion rajahdys = new Explosion(300); 50 rajahdys.Position = tiili.Position; 51 rajahdys.Speed = 90.0; 52 rajahdys.Force = 0; 53 rajahdys.ShockwaveColor = Color.TransparentBlack; 54 //new Color(100,0,0 , 50); 55 Add(rajahdys); 56 pelaajan1Pisteet.Value += 100; 46 57 47 58 … … 57 68 tiili.X = X; 58 69 tiili.Y = Y; 59 Add(tiili );70 Add(tiili,0); 60 71 return tiili; 61 72 … … 69 80 pallo.Y = -340.0; 70 81 pallo.KineticFriction = 0.0; 71 pallo.Restitution = 2.0;72 73 Add(pallo );82 pallo.Restitution = 1.0; 83 84 Add(pallo,1); 74 85 75 86 //Level.CreateBorders(90.0, true); … … 78 89 Camera.ZoomToLevel(); 79 90 80 maila1 = LuoMaila(0.0, -3 90.0);91 maila1 = LuoMaila(0.0, -370.0); 81 92 //Add(maila1); 82 93 //maila2 = LuoMaila(0.0,-365.0); … … 91 102 void AsetaOhjaimet() 92 103 { 93 Keyboard.Listen(Key. A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa vasemmalle", maila1, nopeusvasemmalle);94 Keyboard.Listen(Key. A, ButtonState.Released, AsetaNopeus, null, maila1, pysahdy);95 Keyboard.Listen(Key. D, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa oikealle", maila1, nopeusoikealle);96 Keyboard.Listen(Key. D, ButtonState.Released, AsetaNopeus, null, maila1, pysahdy);104 Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa vasemmalle", maila1, nopeusvasemmalle); 105 Keyboard.Listen(Key.Left, ButtonState.Released, AsetaNopeus, null, maila1, pysahdy); 106 Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa oikealle", maila1, nopeusoikealle); 107 Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, maila1, pysahdy); 97 108 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 98 Keyboard.Listen(Key.F1 , ButtonState.Pressed,uudistatiili ,"uusi tiili kasa" );109 Keyboard.Listen(Key.F12, ButtonState.Pressed,uudistatiili ,"uusi tiili kasa" ); 99 110 } 100 111 void AsetaNopeus(PhysicsObject maila, Vector nopeus) … … 114 125 PhysicsObject LuoMaila(double x, double y) 115 126 { 116 PhysicsObject maila = PhysicsObject.CreateStaticObject(200.0, 10.0,Shapes.Rectangle,CollisionShapeQuality.Best);127 PhysicsObject maila = PhysicsObject.CreateStaticObject(200.0, 20.0,Shapes.Rectangle,CollisionShapeQuality.Best); 117 128 maila.X = x; 118 129 maila.Y = y; … … 120 131 maila.Color = Color.ForestGreen; 121 132 maila.IgnoresCollisionResponse = false; 133 122 134 Add(maila); 123 135 … … 128 140 protected override void Update(Time time) 129 141 { 142 if (rajahdyslaskuri == 100) 143 { 144 pummi(); 145 rajahdyslaskuri = 0; 146 } 147 rajahdyslaskuri++; 130 148 131 149 if (pallo != null && Math.Abs(pallo.Velocity.Y) < pallonNopeus) … … 164 182 pelaajan1Pisteet = LuoPisteLaskuri(350, 350,"pisteet"); 165 183 pelaajanhp = LuoPisteLaskuri(-350, 350,"HP"); 166 pelaajanhp.Value = 10; 184 pelaajanhp.Value = elamiaAlussa; 185 pelaajanhp.MinValue = -1; 186 pelaajanhp.LowerLimit += PeliLoppui; 167 187 168 188 } … … 179 199 Label textit = new Label(texti); 180 200 Add(textit); 181 textit.X = naytto.X - 360; 182 //textit.Color = Color.Red; 201 textit.X = naytto.X -70; 202 textit.Y = naytto.Y = 300; 203 textit.Color = Color.Red; 183 204 return laskuri; 184 205 } … … 218 239 LuoTiili(-100 + p * 101, 247); 219 240 } 220 } 221 222 223 224 225 226 241 for (int i = 0; i < 2; i++) 242 { 243 LuoTiili(-50 + i * 101, 268); 244 } 245 for (int o = 0; o < 1; o++) 246 { 247 LuoTiili(-0 + o * 101, 289); 248 } 249 } 250 void PeliLoppui(int elamia) 251 { 252 Label gameower = new Label(); 253 gameower.Text = "GAMEOWER"; 254 gameower.Color = Color.Red; 255 Add(gameower); 256 Timer.SingleShot(1,Begin); 257 } 258 void pummi() 259 { 260 Explosion rajahdys = new Explosion(10); 261 rajahdys.Position = RandomGen.NextVector(Level.Left, Level.Right, Level.Top, Level.Bottom); 262 rajahdys.Speed = 5.0; 263 rajahdys.Force = 0; 264 rajahdys.ShockwaveColor = Color.TransparentBlack; 265 //new Color(0, 100, 0, 100); 266 Add(rajahdys); 267 268 } 227 269 228 270
Note: See TracChangeset
for help on using the changeset viewer.