Changeset 9136
- Timestamp:
- 2017-07-26 14:49:34 (6 years ago)
- Location:
- 2017/30/SamuliR
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/30/SamuliR/Pong/Pong/Pong/Pong.cs
r9067 r9136 12 12 public class Pong : PhysicsGame 13 13 { 14 Vector nopeusYlos = new Vector(0, 200);15 Vector nopeusAlas = new Vector(0, - 200);14 Vector nopeusYlos = new Vector(0, 1200); 15 Vector nopeusAlas = new Vector(0, -1200); 16 16 17 17 PhysicsObject pallo; … … 36 36 { 37 37 pallo = new PhysicsObject(40.0, 40.0); 38 pallo.Shape = Shape. Triangle;39 pallo.X = - 200.0;38 pallo.Shape = Shape.Circle; 39 pallo.X = -400.0; 40 40 pallo.Y = 0.0; 41 41 pallo.Restitution = 1.0; … … 68 68 alaReuna.KineticFriction = 0.0; 69 69 70 Level.BackgroundColor = Color. Beige;70 Level.BackgroundColor = Color.Red; 71 71 72 72 Camera.ZoomToLevel(); … … 139 139 140 140 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 141 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");141 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); 142 142 143 143 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos); -
2017/30/SamuliR/SpeedFloat/SpeedFloat/SpeedFloat/SpeedFloat.cs
r9097 r9136 7 7 using Jypeli.Widgets; 8 8 9 public class SpeedFloat : PhysicsGame 9 public class SpeedFloat : PhysicsGame // Ennätys 126 10 10 { 11 11 PhysicsObject timantti; 12 12 13 13 public override void Begin() 14 { 15 LuoPistelaskuri(); 14 16 17 Level.Height = Window.Height; 15 18 16 17 { 18 Camera.ZoomToLevel(); 19 Level.Width = 1000000; 19 20 20 21 Level.Background.Color = Color.Black; … … 22 23 Level.Background.CreateStars(); 23 24 24 timantti = new PhysicsObject(50.0, 50.0); 25 timantti = new PhysicsObject(50.0, 50.0); 26 timantti.IgnoresCollisionResponse = true; 25 27 timantti.Color = Color.Aqua; 26 28 timantti.Shape = Shape.Diamond; 27 29 Add(timantti); 28 29 // AddCollisionHandler(salama, CollisionHandler.ExplodeBoth(200, true); 30 30 Camera.StayInLevel = true; 31 PhysicsObject alareuna = Level.CreateBottomBorder(); 32 PhysicsObject ylareuna = Level.CreateTopBorder(); 33 alareuna.Tag = ylareuna.Tag = "reuna"; 34 Camera.Follow(timantti); 35 AddCollisionHandler(timantti, CollisionHandler.ExplodeBoth(1200, true)); 36 AddCollisionHandler(timantti, delegate (PhysicsObject p1, PhysicsObject p2) 37 { 38 Timer.SingleShot(3.0, delegate 39 { ClearAll(); Begin(); }); 40 }); 41 //AddCollisionHandler(timantti, "reuna", delegate (PhysicsObject p1, PhysicsObject p2) { ClearAll(); Begin(); }); 31 42 // Camera.Follow(timantti); 32 43 … … 35 46 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); 36 47 37 LiikutaPelaajaa(new Vector(10000, 0)); 48 LiikutaPelaajaa(new Vector(49999, 0)); 49 50 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 1000)); 51 Keyboard.Listen(Key.D, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -1000)); 52 53 Timer ajastin = new Timer(); 54 ajastin.Interval = 0.7; 55 ajastin.Timeout += LisaaAsteroideja; 56 ajastin.Start(); 57 58 //Timer ajastin2 = new Timer(); 59 //ajastin2.Interval = 1.0; 60 //ajastin2.Timeout += reuna; 61 //ajastin2.Start(); 62 63 64 } 65 66 void LisaaAsteroideja() 67 { 38 68 39 Keyboard.Listen(Key.A, ButtonState.Down, 40 LiikutaPelaajaa, null, new Vector(0, 1000)); 41 Keyboard.Listen(Key.D, ButtonState.Down, 42 LiikutaPelaajaa, null, new Vector(0, -1000)); 69 PhysicsObject este = new PhysicsObject(80.0, 90.0); 70 este.MakeStatic(); 71 este.X = timantti.X + 1000.0; 72 double randomiluku = RandomGen.NextDouble(-250.0, 250.0); 73 este.Y = timantti.Y + randomiluku; 74 este.LifetimeLeft = TimeSpan.FromSeconds(60); 75 este.Color = Color.DarkRed; 76 Add(este); 43 77 } 78 79 44 80 45 81 void LiikutaPelaajaa(Vector vektori) 46 82 { 83 47 84 timantti.Push(vektori); 48 85 … … 51 88 void LuoKentta() 52 89 { 53 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Kuvataso") 90 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Kuvataso"); 91 92 // ruudut.SetTileMethod(Color.Black, LuoKentta); 93 94 ruudut.Execute(20, 20); 95 96 97 } 98 99 void LuoTaso(Vector paikka, double leveys, double korkeus) 100 { 101 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 102 taso.Position = paikka; 103 // taso.Image = groundImage; 104 taso.CollisionIgnoreGroup = 1; 105 Add(taso); 106 107 } 108 109 //void reuna() 110 111 //{ 112 // PhysicsObject reuna = new PhysicsObject(80.0, 90.0); 113 // reuna.MakeStatic(); 114 // reuna.X = timantti.X + 1000.0; 115 116 // reuna.Y = timantti.Y + sijainti; 117 // reuna.LifetimeLeft = TimeSpan.FromSeconds(60); 118 // reuna.Color = Color.DarkRed; 119 // Add(reuna); 120 //} 121 122 IntMeter pisteLaskuri; 123 124 void LuoPistelaskuri() 125 { 126 pisteLaskuri = new IntMeter(0); 127 128 Label pisteNaytto = new Label(); 129 pisteNaytto.X = Screen.Left + 100; 130 pisteNaytto.Y = Screen.Top - 100; 131 pisteNaytto.TextColor = Color.Black; 132 pisteNaytto.Color = Color.White; 133 134 pisteNaytto.BindTo(pisteLaskuri); 135 Add(pisteNaytto); 136 137 Timer.SingleShot(1.3, delegate { 138 Timer lisaysajastin = new Timer(); 139 lisaysajastin.Interval = 0.7; 140 lisaysajastin.Timeout += delegate { pisteLaskuri.AddValue(1); }; 141 lisaysajastin.Start(); 142 143 }); 144 145 146 pisteLaskuri.MaxValue = 999; 54 147 } 55 148 56 149 } 57 58
Note: See TracChangeset
for help on using the changeset viewer.