Changeset 7582
- Timestamp:
- 2016-06-29 15:02:47 (7 years ago)
- Location:
- 2016/26/JonniN/TankHero
- Files:
-
- 20 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/26/JonniN/TankHero/TankHero/TankHero/TankHero.cs
r7555 r7582 9 9 public class TankHero : PhysicsGame 10 10 { 11 Cannon torni; 12 Image leopard2a4 = LoadImage("leopard2a4"); 13 Image torninKuva = LoadImage("leopard2a4valmistorni"); 14 PhysicsObject pelaaja; 11 15 public override void Begin() 12 16 { 13 17 Mouse.IsCursorVisible = true; 18 Vector kursoriruudulla = Mouse.PositionOnScreen; 19 Vector paikkakentällä = Mouse.PositionOnWorld; 20 LuoPelaaja(); 21 LuoKentta(); 22 LuoOhjaimet(); 23 14 24 15 25 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 16 26 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 17 27 } 28 void LuoPelaaja() 29 { 30 pelaaja = new PhysicsObject(150, 200); 31 pelaaja.Shape = Shape.FromImage(leopard2a4); 32 pelaaja.Image = leopard2a4; 33 pelaaja.LinearDamping = 0.90; 34 Add(pelaaja); 35 36 37 38 torni = new Cannon(150, 120); 39 torni.Shape = Shape.FromImage(torninKuva); 40 torni.Image = torninKuva; 41 torni.Position = new Vector(22, -35); 42 torni.Ammo.Value = 10000; 43 pelaaja.Add(torni); 44 45 } 46 void LuoKentta() 47 { 48 //Camera.Follow(pelaaja); 49 50 51 52 } 53 54 void LuoOhjaimet() 55 { 56 Keyboard.Listen(Key.W, ButtonState.Down, Aja, null, new Vector(0, 1000)); 57 Keyboard.Listen(Key.S, ButtonState.Down, Aja, null, new Vector(0, -700)); 58 Keyboard.Listen(Key.A, ButtonState.Down, Kaanny, null, 1); 59 Keyboard.Listen(Key.D, ButtonState.Down, Kaanny, null, -1); 60 61 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, AmmuTykilla, "Ammu", torni); 62 Mouse.ListenMovement(0.1, TorninLiike, "Käännä tornia"); 63 64 65 66 } 67 void AmmuTykilla(Cannon tykki) 68 { 69 PhysicsObject ammus = tykki.Shoot(); 70 71 if(ammus !=null) 72 { 73 ammus.Size *= 1; 74 tykki.FireRate = 10; 75 } 76 } 77 void TorninLiike(AnalogState hiirenLiike) 78 { 79 Vector suunta = (Mouse.PositionOnWorld - torni.AbsolutePosition).Normalize(); 80 torni.Angle = suunta.Angle; 81 } 82 void Aja(Vector suunta) 83 { 84 Vector menosuunta = Vector.FromLengthAndAngle(suunta.Y, pelaaja.Angle); 85 pelaaja.Push(menosuunta); 86 87 } 88 void Kaanny(int kaannos) 89 { 90 pelaaja.Angle += Angle.FromDegrees(kaannos); 91 } 18 92 } -
2016/26/JonniN/TankHero/TankHero/TankHeroContent/TankHeroContent.contentproj
r7555 r7582 45 45 <Reference Include="AnimationExtension" /> 46 46 </ItemGroup> 47 <ItemGroup> 48 <Compile Include="leopard2a4.png"> 49 <Name>leopard2a4</Name> 50 <Importer>TextureImporter</Importer> 51 <Processor>TextureProcessor</Processor> 52 </Compile> 53 </ItemGroup> 54 <ItemGroup> 55 <Compile Include="leopard2a4valmistorni.png"> 56 <Name>leopard2a4valmistorni</Name> 57 <Importer>TextureImporter</Importer> 58 <Processor>TextureProcessor</Processor> 59 </Compile> 60 </ItemGroup> 47 61 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 48 62 <!-- 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.