Changeset 3273
- Timestamp:
- 2012-06-27 14:53:41 (10 years ago)
- Location:
- 2012/26/ElmoR/Hurja Arska/Hurja Arska
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/26/ElmoR/Hurja Arska/Hurja Arska/Hurja Arska/Hurja Arska.csproj
r3219 r3273 62 62 </PropertyGroup> 63 63 <ItemGroup> 64 <Reference Include="Jypeli"> 64 <Reference Include="Jypeli, Version=5.0.0.0, Culture=neutral, processorArchitecture=x86"> 65 <SpecificVersion>False</SpecificVersion> 66 <HintPath>..\..\..\..\lib\Jypeli.dll</HintPath> 65 67 </Reference> 66 68 <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> -
2012/26/ElmoR/Hurja Arska/Hurja Arska/Hurja Arska/Hurja_Arska.cs
r3219 r3273 7 7 using Jypeli.Widgets; 8 8 9 class Pelaaja : PhysicsObject 10 { 11 public int Elamat = 10; 12 13 public Pelaaja(double leveys, double korkeus) 14 : base(leveys, korkeus) 15 { 16 } 17 } 18 19 class TyhmaVihu : PhysicsObject 20 { 21 public int Elamat = 2; 22 23 public TyhmaVihu(double leveys, double korkeus) 24 : base(leveys, korkeus) 25 { 26 } 27 } 28 29 9 30 public class Hurja_Arska : PhysicsGame 10 31 { 11 PhysicsObject arska; 12 32 const int RUUDUN_KOKO = 32; 33 Pelaaja arska; 34 AssaultRifle ase; 13 35 14 36 public override void Begin() 15 37 { 16 38 LuoMaailma(); 39 tyhmaVihollinenAjastin(); 40 LataaKentta(); 41 LuoValo(); 42 17 43 IsMouseVisible = true; 18 44 Mouse.ListenMovement(0.1, Ohjaus, ""); 19 45 20 Keyboard.Listen(Key.W, ButtonState.Down, LiikuEteen(300), ""); 21 Keyboard.Listen(Key.W, ButtonState.Up, arska.Stop, ""); 22 Keyboard.Listen(Key.S, ButtonState.Down, , ""); 23 Keyboard.Listen(Key.S, ButtonState.Up, arska.Stop, ""); 46 Camera.Follow(arska); 47 Camera.ZoomFactor = 1.4; 48 Camera.StayInLevel = true; 24 49 50 Keyboard.Listen(Key.W, ButtonState.Down, LiikuEteen, ""); 51 Keyboard.Listen(Key.W, ButtonState.Released, arska.Stop, ""); 52 Keyboard.Listen(Key.S, ButtonState.Down, LiikuTaakse, ""); 53 Keyboard.Listen(Key.S, ButtonState.Released, arska.Stop, ""); 54 Keyboard.Listen(Key.D, ButtonState.Down, LiikuOikealle, ""); 55 Keyboard.Listen(Key.D, ButtonState.Released, arska.Stop, ""); 56 Keyboard.Listen(Key.A, ButtonState.Down, LiikuVasemmalle, ""); 57 Keyboard.Listen(Key.A, ButtonState.Released, arska.Stop, ""); 58 59 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, AmmuAseella, ""); 25 60 } 26 61 27 62 void LuoMaailma() 28 63 { 29 arska = new P hysicsObject(42.0, 42.0);64 arska = new Pelaaja(42.0, 42.0); 30 65 arska.Shape = Shape.Circle; 31 66 arska.Image = LoadImage("pallo1"); 67 arska.AngularDamping = 0.9; 32 68 Add(arska); 33 69 70 ase = new AssaultRifle(0, 0); 71 arska.Add(ase); 72 ase.Angle = (Mouse.PositionOnWorld - ase.Position).Angle; 73 ase.Ammo.Value = 300; 74 } 75 76 void AmmuAseella() 77 { 78 PhysicsObject ammus = ase.Shoot(); 79 80 if (ammus != null) 81 { 82 ammus.Size *= 0.6; 83 } 84 } 85 86 void LataaKentta() 87 { 88 TileMap ruudut = TileMap.FromLevelAsset("taustatext"); 89 ruudut.SetTileMethod('A', LuoLaatikko); 90 ruudut.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 91 } 92 93 void LuoLaatikko(Vector paikka, double leveys, double korkeus) 94 { 95 PhysicsObject laatikko = PhysicsObject.CreateStaticObject(leveys, korkeus); 96 laatikko.Position = paikka; 97 laatikko.Color = Color.Brown; 98 Add(laatikko); 34 99 } 35 100 … … 39 104 } 40 105 41 void LiikuEteen( double vauhti)106 void LiikuEteen() 42 107 { 43 arska.Move(Vector.FromLengthAndAngle(vauhti, arska.Angle)); 108 arska.Move(Vector.FromLengthAndAngle(140, arska.Angle)); 109 } 110 111 void LiikuTaakse() 112 { 113 arska.Move(Vector.FromLengthAndAngle(60, arska.Angle - Angle.FromDegrees(180))); 114 } 115 116 void LiikuOikealle() 117 { 118 arska.Move(Vector.FromLengthAndAngle(90, arska.Angle - Angle.FromDegrees(90))); 119 } 120 121 void LiikuVasemmalle() 122 { 123 arska.Move(Vector.FromLengthAndAngle(90, arska.Angle - Angle.FromDegrees(270))); 124 } 125 126 void tyhmaVihollinenAjastin() 127 { 128 Timer tVajastin = new Timer(); 129 tVajastin.Interval = RandomGen.NextDouble(1.4, 6.0); 130 tVajastin.Timeout += LuoVihollinen; 131 tVajastin.Start(); 132 } 133 134 void LuoVihollinen() 135 { 136 TyhmaVihu tyhmaVihollinen = new TyhmaVihu(42.0, 42.0); 137 tyhmaVihollinen.Shape = Shape.Circle; 138 tyhmaVihollinen.Image = LoadImage("pallo2"); 139 tyhmaVihollinen.X = RandomGen.NextInt(20, 500); 140 tyhmaVihollinen.Y = Level.Top-20; 141 Add(tyhmaVihollinen); 142 143 144 FollowerBrain seuraajanAivot = new FollowerBrain(arska); 145 seuraajanAivot.Speed = RandomGen.NextInt(90, 100); 146 seuraajanAivot.DistanceToTarget.Changed += delegate 147 { 148 tyhmaVihollinen.Angle = (arska.Position - tyhmaVihollinen.Position).Angle; 149 }; 150 seuraajanAivot.DistanceFar = 1200; 151 seuraajanAivot.DistanceClose = 0; 152 seuraajanAivot.StopWhenTargetClose = false; 153 tyhmaVihollinen.Brain = seuraajanAivot; 154 155 } 156 157 void LuoValo() 158 { 159 Level.AmbientLight = 1.2; 160 161 Light lanppu = new Light(); 162 lanppu.Intensity = 1.2; 163 lanppu.Distance = 10; 164 lanppu.X += 200; 165 Add(lanppu); 166 167 GameObject tausta = new GameObject(Level.Width, Level.Height); 168 tausta.Image = LoadImage("tausta2"); 169 Add(tausta, -2); 44 170 } 45 171 } -
2012/26/ElmoR/Hurja Arska/Hurja Arska/Hurja ArskaContent/Hurja ArskaContent.contentproj
r3219 r3273 51 51 </Compile> 52 52 </ItemGroup> 53 <ItemGroup> 54 <Compile Include="pallo2.png"> 55 <Name>pallo2</Name> 56 <Importer>TextureImporter</Importer> 57 <Processor>TextureProcessor</Processor> 58 </Compile> 59 </ItemGroup> 60 <ItemGroup> 61 <Compile Include="tahtain.png"> 62 <Name>tahtain</Name> 63 <Importer>TextureImporter</Importer> 64 <Processor>TextureProcessor</Processor> 65 </Compile> 66 </ItemGroup> 67 <ItemGroup> 68 <Compile Include="Untitled.png"> 69 <Name>Untitled</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 </ItemGroup> 74 <ItemGroup> 75 <Compile Include="tausta2.png"> 76 <Name>tausta2</Name> 77 <Importer>TextureImporter</Importer> 78 <Processor>TextureProcessor</Processor> 79 </Compile> 80 </ItemGroup> 81 <ItemGroup> 82 <Compile Include="tausta3.png"> 83 <Name>tausta3</Name> 84 <Importer>TextureImporter</Importer> 85 <Processor>TextureProcessor</Processor> 86 </Compile> 87 </ItemGroup> 88 <ItemGroup> 89 <Compile Include="taustatext.txt"> 90 <Name>taustatext</Name> 91 <Importer>TextFileImporter</Importer> 92 <Processor>TextFileContentProcessor</Processor> 93 </Compile> 94 </ItemGroup> 53 95 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 54 96 <!-- 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.