- Timestamp:
- 2010-07-29 14:57:31 (13 years ago)
- Location:
- 2010/30/aneesavi/Cyb0rg-City
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/aneesavi/Cyb0rg-City/Content/Content.contentproj
r1399 r1419 61 61 </Compile> 62 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="Ase1.png"> 65 <Name>Ase1</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="rajahdys.png"> 72 <Name>rajahdys</Name> 73 <Importer>TextureImporter</Importer> 74 <Processor>TextureProcessor</Processor> 75 </Compile> 76 </ItemGroup> 63 77 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 64 78 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/30/aneesavi/Cyb0rg-City/Peli.cs
r1399 r1419 1 1 using System; 2 using System.Collections.Generic; 2 3 using Jypeli; 3 4 using Jypeli.Widgets; 4 5 using Jypeli.Assets; 6 using Jypeli.Effects; 7 5 8 6 9 7 10 class Tasohyppely : PhysicsGame 8 11 { 9 const double nopeus = 200;12 const double nopeus = 500; 10 13 const double hyppyVoima = 4000; 14 DoubleMeter energiaMittari; 11 15 12 16 PlatformCharacter pelaaja1; … … 14 18 PlatformCharacter vihollinen; 15 19 Image Evil = LoadImage("Evil"); 20 Image Ase1 = LoadImage("Ase1"); 16 21 const int ruudunLeveys = 50; 17 22 const int ruudunKorkeus = 50; 18 23 24 List<PlatformCharacter> viholliset; 25 ExplosionSystem rajahdys; 19 26 20 27 protected override void Begin() 21 28 { 29 viholliset = new List<PlatformCharacter>(); 30 rajahdys = new ExplosionSystem(LoadImage("rajahdys"), 200); 31 Add(rajahdys); 32 22 33 Gravity = new Vector(0, -1000); 23 34 24 35 luoKentta(); 25 36 lisaaNappaimet(); 37 LisaaVihollisenEnergiapalkki(); 26 38 27 39 Camera.Follow(pelaaja1); 28 40 Camera.ZoomFactor = 1.0; 29 Camera.StayInLevel = true;41 //Camera.StayInLevel = true; 30 42 } 31 43 … … 49 61 { 50 62 // tämä aliohjelma ei ole vielä valmis... 51 PhysicsObject laakepaketti = new PhysicsObject(50, 50);63 PhysicsObject laakepaketti = new PhysicsObject(50, 50); 52 64 return laakepaketti; 53 65 } … … 61 73 pelaaja1.LeftWalkingAnimation = new Animation(Image.Mirror(seppo)); 62 74 pelaaja1.RightWalkingAnimation = new Animation(seppo); 75 pelaaja1.Weapon = new AssaultRifle(150, 50); 76 pelaaja1.Weapon.Size = new Vector(230, 100); 77 pelaaja1.Weapon.Image = Ase1; 63 78 return pelaaja1; 64 79 } … … 72 87 Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, nopeus); 73 88 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); 89 Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Ammu"); 74 90 75 91 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 80 96 } 81 97 98 void Ammu() 99 { 100 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 101 if (ammus != null) 102 { 103 ammus.Size *= 6; 104 ammus.Velocity *= 4; 105 rajahdys.MinLifetime = 0.1; 106 rajahdys.MaxLifetime = 0.2; 107 rajahdys.MinVelocity = 1; 108 rajahdys.MaxVelocity = 100; 109 rajahdys.MinScale = 0.05; 110 rajahdys.MaxScale = 0.1; 111 112 double x = ammus.X; 113 if (pelaaja1.FacingDirection == Direction.Left) 114 { 115 x -= 60; 116 } 117 118 if (pelaaja1.FacingDirection == Direction.Right) 119 { 120 x += 60; 121 } 122 123 rajahdys.AddEffect(x, ammus.Y, 20); 124 125 AddCollisionHandler(ammus, AmmusOsui); 126 } 127 } 128 129 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 130 { 131 if (kohde == vihollinen) 132 { 133 VahennaVihollisenVoimia(); 134 } 135 } 136 82 137 void liikuta(PlatformCharacter hahmo, double nopeus) 83 138 { 84 139 hahmo.Walk(nopeus); 140 if (nopeus < 0) 141 { 142 hahmo.Weapon.Image = Image.Flip(Ase1); 143 } 144 else 145 hahmo.Weapon.Image = Ase1; 146 85 147 } 86 148 … … 92 154 PhysicsObject Luovihollinen() 93 155 { 94 vihollinen = new PlatformCharacter(200, 200 );156 vihollinen = new PlatformCharacter(200, 200, Shapes.Circle); 95 157 vihollinen.Mass = 2.0; 96 158 vihollinen.Image = Evil; 97 159 vihollinen.LeftWalkingAnimation = new Animation(Image.Mirror(Evil)); 98 160 vihollinen.RightWalkingAnimation = new Animation(Evil); 99 Timer ajastin = new Timer(); 100 ajastin.Interval = 1.5; 101 ajastin.Trigger += KavelytaVihollista; 102 ajastin.Start(); 103 161 viholliset.Add(vihollinen); 104 162 return vihollinen; 105 163 } 106 void KavelytaVihollista(Timer sender) 107 { 164 165 protected override void Update(Time time) 166 { 167 base.Update(time); 168 foreach (PlatformCharacter vihollinen in viholliset) 169 { 170 if (pelaaja1.X < vihollinen.X) 171 { 172 vihollinen.Walk(-200); 173 } 174 175 if (pelaaja1.X > vihollinen.X) 176 { 177 vihollinen.Walk(200); 178 } 179 } 180 } 181 182 183 void LisaaVihollisenEnergiapalkki() 184 { 185 energiaMittari = new DoubleMeter(5); 186 energiaMittari.MaxValue = 5; 187 energiaMittari.MinValue = 0; 188 BarGauge voimaPalkki = new BarGauge(20, 150); 189 voimaPalkki.BindTo(energiaMittari); 190 Add(voimaPalkki); 191 192 voimaPalkki.X = (0.8 * Screen.RightSafe); 193 voimaPalkki.Y = (0.8 * Screen.TopSafe); 194 voimaPalkki.BarColor = Color.Green; 195 voimaPalkki.BorderColor = Color.Red; 196 voimaPalkki.Angle = Angle.Degrees(90); 197 198 // Kun voima loppuu, kutsutaan VoimaLoppui-aliohjelmaa 199 energiaMittari.LowerLimit += VihollinenKuolee; 200 } 201 202 void VahennaVihollisenVoimia() 203 { 204 energiaMittari.Value--; 205 } 206 207 void VihollinenKuolee(double mittarinArvo) 208 { 209 MessageDisplay.Add("Vihollinen kuoli"); 210 rajahdys.MinScale = 0.2; 211 rajahdys.MaxScale = 1; 212 rajahdys.MinLifetime = 0.2; 213 rajahdys.MaxLifetime = 1.5; 214 rajahdys.MinVelocity = 100; 215 rajahdys.MaxVelocity = 400; 216 rajahdys.AddEffect(vihollinen.X, vihollinen.Y, 100); 217 vihollinen.Destroy(); 108 218 109 219 } -
2010/30/aneesavi/Cyb0rg-City/kentta.txt
r1399 r1419 13 13 = = 14 14 = = 15 = 16 = 1 2=15 = 2 = 16 = 1 = 17 17 = = 18 18 =========================================================================================================
Note: See TracChangeset
for help on using the changeset viewer.