- Timestamp:
- 2016-07-05 14:58:32 (7 years ago)
- Location:
- 2014/koodauskerho/38/PietuR
- Files:
-
- 31 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/koodauskerho/38/PietuR/MagicalFlowerParty/MagicalFlowerParty/MagicalFlowerParty/MagicalFlowerParty.cs
r7727 r7801 7 7 using Jypeli.Widgets; 8 8 9 class Pelaaja: PhysicsObject 10 { 11 public bool stamina = true; 12 13 public bool osunut = false; 14 15 public DoubleMeter kerroin { get;} 16 17 public Pelaaja(double width, double height) 18 : base(width, height){ 19 kerroin = new DoubleMeter(100, 0, 300); 20 } 21 } 9 22 public class MagicalFlowerParty : PhysicsGame 10 23 { 24 25 26 Pelaaja pelaaja1; 27 Pelaaja pelaaja2; 28 Pelaaja pelaaja3; 29 Pelaaja pelaaja4; 11 30 public override void Begin() 12 31 { 13 // TODO: Kirjoita ohjelmakoodisi tähän 32 33 Image finnypic = LoadImage("Finny"); 34 Image wibblypic = LoadImage("Wibbly"); 35 Image puffypic = LoadImage("Puffy"); 36 Image kookypic = LoadImage("Kooky"); 37 Image arenapic = LoadImage("Arena"); 38 39 PhysicsObject arena = new PhysicsObject(1100, 1100); 40 arena.Shape = Shape.FromImage(arenapic); 41 arena.Image = arenapic; 42 arena.IgnoresCollisionResponse = true; 43 Add(arena, -1); 44 45 46 47 pelaaja1 = new Pelaaja(60, 60); 48 pelaaja1.Position = new Vector(-100, 100); 49 pelaaja1.CanRotate = false; 50 pelaaja1.LinearDamping = 0.95; 51 pelaaja1.Image = finnypic; 52 pelaaja1.Shape = Shape.Circle; 53 pelaaja1.Tag = "pallero"; 54 AddCollisionHandler(pelaaja1, "pallero", PelaajaOsuu); 55 Add(pelaaja1); 56 57 LuoKerroin(pelaaja1); 58 59 pelaaja2 = new Pelaaja(60, 60); 60 pelaaja2.Position = new Vector(100, 100); 61 pelaaja2.CanRotate = false; 62 pelaaja2.LinearDamping = 0.95; 63 pelaaja2.Image = wibblypic; 64 pelaaja2.Shape = Shape.Circle; 65 pelaaja2.Tag = "pallero"; 66 AddCollisionHandler(pelaaja2, "pallero", PelaajaOsuu); 67 Add(pelaaja2); 68 69 LuoKerroin(pelaaja2); 70 71 pelaaja3 = new Pelaaja(60, 60); 72 pelaaja3.Position = new Vector(-100, -100); 73 pelaaja3.CanRotate = false; 74 pelaaja3.LinearDamping = 0.95; 75 pelaaja3.Image = puffypic; 76 pelaaja3.Shape = Shape.Circle; 77 pelaaja3.Tag = "pallero"; 78 AddCollisionHandler(pelaaja3, "pallero", PelaajaOsuu); 79 Add(pelaaja3); 80 81 LuoKerroin(pelaaja3); 82 83 pelaaja4 = new Pelaaja(60, 60); 84 pelaaja4.Position = new Vector(100, -100); 85 pelaaja4.CanRotate = false; 86 pelaaja4.LinearDamping = 0.95; 87 pelaaja4.Image = kookypic; 88 pelaaja4.Shape = Shape.Circle; 89 pelaaja4.Tag = "pallero"; 90 AddCollisionHandler(pelaaja4, "pallero", PelaajaOsuu); 91 Add(pelaaja4); 92 93 LuoKerroin(pelaaja4); 94 95 96 Keyboard.Listen(Key.Left, ButtonState.Down, 97 MovePlayer, null, new Vector(-1000, 0), pelaaja1); 98 Keyboard.Listen(Key.Right, ButtonState.Down, 99 MovePlayer, null, new Vector(1000, 0), pelaaja1); 100 Keyboard.Listen(Key.Up, ButtonState.Down, 101 MovePlayer, null, new Vector(0, 1000), pelaaja1); 102 Keyboard.Listen(Key.Down, ButtonState.Down, 103 MovePlayer, null, new Vector(0, -1000), pelaaja1); 104 Keyboard.Listen(Key.RightControl, ButtonState.Pressed, 105 Dash, null, new Vector(0, -10000), pelaaja1); 106 107 Keyboard.Listen(Key.A, ButtonState.Down, 108 MovePlayer, null, new Vector(-1000, 0), pelaaja2); 109 Keyboard.Listen(Key.D, ButtonState.Down, 110 MovePlayer, null, new Vector(1000, 0), pelaaja2); 111 Keyboard.Listen(Key.W, ButtonState.Down, 112 MovePlayer, null, new Vector(0, 1000), pelaaja2); 113 Keyboard.Listen(Key.S, ButtonState.Down, 114 MovePlayer, null, new Vector(0, -1000), pelaaja2); 115 Keyboard.Listen(Key.LeftControl, ButtonState.Pressed, 116 Dash, null, new Vector(0, -10000), pelaaja2); 117 118 Keyboard.Listen(Key.NumPad4, ButtonState.Down, 119 MovePlayer, null, new Vector(-1000, 0), pelaaja3); 120 Keyboard.Listen(Key.NumPad6, ButtonState.Down, 121 MovePlayer, null, new Vector(1000, 0), pelaaja3); 122 Keyboard.Listen(Key.NumPad8, ButtonState.Down, 123 MovePlayer, null, new Vector(0, 1000), pelaaja3); 124 Keyboard.Listen(Key.NumPad5, ButtonState.Down, 125 MovePlayer, null, new Vector(0, -1000), pelaaja3); 126 Keyboard.Listen(Key.NumPad9, ButtonState.Pressed, 127 Dash, null, new Vector(0, -10000), pelaaja3); 128 129 Keyboard.Listen(Key.H, ButtonState.Down, 130 MovePlayer, null, new Vector(-1000, 0), pelaaja4); 131 Keyboard.Listen(Key.K, ButtonState.Down, 132 MovePlayer, null, new Vector(1000, 0), pelaaja4); 133 Keyboard.Listen(Key.U, ButtonState.Down, 134 MovePlayer, null, new Vector(0, 1000), pelaaja4); 135 Keyboard.Listen(Key.J, ButtonState.Down, 136 MovePlayer, null, new Vector(0, -1000), pelaaja4); 137 Keyboard.Listen(Key.Y, ButtonState.Pressed, 138 Dash, null, new Vector(0, -10000), pelaaja4); 139 140 141 14 142 15 143 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 16 144 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 17 145 } 146 void MovePlayer(Vector vector, PhysicsObject pelaaja) 147 { 148 pelaaja.Push(vector); 149 } 150 151 void Dash(Vector vector, Pelaaja pelaaja) 152 { 153 if (pelaaja.stamina == true && pelaaja.Velocity.Magnitude != 0) 154 { 155 pelaaja.Hit(pelaaja.Velocity.Normalize() * 500); 156 157 pelaaja.stamina = false; 158 159 Timer.SingleShot(3.0,delegate { pelaaja.stamina = true; }); 160 } 161 162 } 163 void PelaajaOsuu(PhysicsObject tormaaja, PhysicsObject kohde) 164 { 165 Pelaaja pelaaja = tormaaja as Pelaaja; 166 Pelaaja osuttu = kohde as Pelaaja; 167 if (osuttu == null) 168 return; 169 170 if (pelaaja.Velocity.Magnitude > kohde.Velocity.Magnitude && !osuttu.osunut && !pelaaja.osunut) 171 { 172 double vahinko = (pelaaja.Velocity - kohde.Velocity).Magnitude / 60.0 * 2.0; 173 osuttu.osunut = true; 174 osuttu.kerroin.Value += vahinko; 175 osuttu.Hit(pelaaja.Velocity * osuttu.kerroin.Value / 100.0 * 2.0); 176 pelaaja.Stop(); 177 178 //Color.Lerp(Color.Green, Color.Red) 179 ((Label)osuttu.Objects[0]).TextColor = Color.Lerp(Color.White, Color.Red, (osuttu.kerroin.Value - 100) / 200.0); 180 181 Timer.SingleShot(0.05, () => osuttu.osunut = false); 182 } 183 } 184 void LuoKerroin(Pelaaja pelaaja) 185 { 186 Label kerroinarvo = new Label(pelaaja.kerroin); 187 kerroinarvo.Position = new Vector(0, 50); 188 kerroinarvo.TextColor = Color.White; 189 kerroinarvo.Color = new Color(0, 0, 0, 128); 190 pelaaja.Add(kerroinarvo); 191 192 } 18 193 } -
2014/koodauskerho/38/PietuR/MagicalFlowerParty/MagicalFlowerParty/MagicalFlowerPartyContent/MagicalFlowerPartyContent.contentproj
r7727 r7801 45 45 <Reference Include="AnimationExtension" /> 46 46 </ItemGroup> 47 <ItemGroup> 48 <Compile Include="Arena.png"> 49 <Name>Arena</Name> 50 <Importer>TextureImporter</Importer> 51 <Processor>TextureProcessor</Processor> 52 </Compile> 53 <Compile Include="Finny.png"> 54 <Name>Finny</Name> 55 <Importer>TextureImporter</Importer> 56 <Processor>TextureProcessor</Processor> 57 </Compile> 58 <Compile Include="Kooky.png"> 59 <Name>Kooky</Name> 60 <Importer>TextureImporter</Importer> 61 <Processor>TextureProcessor</Processor> 62 </Compile> 63 <Compile Include="Puffy.png"> 64 <Name>Puffy</Name> 65 <Importer>TextureImporter</Importer> 66 <Processor>TextureProcessor</Processor> 67 </Compile> 68 <Compile Include="Wibbly.png"> 69 <Name>Wibbly</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 </ItemGroup> 47 74 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 48 75 <!-- 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.