- Timestamp:
- 2013-07-03 14:04:48 (10 years ago)
- Location:
- 2013/27/LeoL/Hounted Hause/Hounted Hause
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/LeoL/Hounted Hause/Hounted Hause/Hounted Hause/Hounted_Hause.cs
r4368 r4397 15 15 PhysicsObject pelaaja; 16 16 17 //Pelin alussa ollaan kentässä 1 18 int kenttaNro = 1; 19 20 21 22 Vector ylos = new Vector(0, 100); 23 Vector alas = new Vector(0, -100); 24 Vector vasen = new Vector(-100, 0); 25 Vector oikea = new Vector(100, 0); 26 17 27 public override void Begin() 18 28 { 19 LuoKentta();29 SeuraavaKentta(); 20 30 31 32 } 33 void SeuraavaKentta() 34 { 35 ClearAll(); 36 37 if (kenttaNro == 1) LuoKentta("kentta1"); 38 else if (kenttaNro == 2) LuoKentta("kentta2"); 39 else if (kenttaNro == 3) LuoKentta("kentta3"); 40 else if (kenttaNro == 4) LuoKentta("kentta4"); 41 else if (kenttaNro > 4) Exit(); 21 42 MediaPlayer.Play("taustamusiikki"); 22 43 23 44 Camera.Follow(pelaaja); 24 Camera.ZoomFactor = 5.0;45 Camera.ZoomFactor = 9.0; 25 46 Camera.StayInLevel = true; 26 47 … … 33 54 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 34 55 } 35 36 56 void LiikutaPelaajaa(Vector vektori, PhysicsObject pelaaja) 37 57 { … … 40 60 } 41 61 42 void LuoKentta( )62 void LuoKentta(string kentat) 43 63 { 44 64 //1. Luetaan kuva uuteen ColorTileMappiin, kuvan nimen perässä ei .png-päätettä. 45 ColorTileMap ruudut = ColorTileMap.FromLevelAsset( "kentta1");65 ColorTileMap ruudut = ColorTileMap.FromLevelAsset(kentat); 46 66 47 67 //2. Kerrotaan mitä aliohjelmaa kutsutaan, kun tietyn värinen pikseli tulee vastaan kuvatiedostossa. … … 64 84 pelaaja.Position = paikka; 65 85 pelaaja.Restitution = 0.0; 86 pelaaja.Tag = "pelaaja"; 66 87 pelaaja.KineticFriction = 0.0; 67 88 AddCollisionHandler(pelaaja, "avain", TormaaAvaimeen); … … 71 92 void LuoÖrkki(Vector paikka, double leveys, double korkeus) 72 93 { 73 PhysicsObject orkki = new PhysicsObject(3 9,39);74 orkki.Shape = Shape. Circle;94 PhysicsObject orkki = new PhysicsObject(30,30); 95 orkki.Shape = Shape.Rectangle; 75 96 orkki.Image = örkkiKuva; 76 97 orkki.CanRotate = false; … … 78 99 orkki.Restitution = 0.0; 79 100 orkki.KineticFriction = 0.0; 80 //AddCollisionHandler(orkki, "pelaaja", Tormaaorkkiin); 101 //orkki.CollisionIgnoreGroup = 1; 102 orkki.IgnoresCollisionResponse = true; 103 //AddCollisionHandler(orkki, "pelaaja", Tormaaorkkiin); 104 AddCollisionHandler(orkki, "taso", TormaaSeinaan); 81 105 Add(orkki); 106 //SatunnainenSuunta(orkki); 107 108 FollowerBrain aivot = new FollowerBrain( "pelaaja" ); 109 orkki.Brain = aivot; 110 aivot.Speed = 50.50; 111 } 112 113 void SatunnainenSuunta(PhysicsObject orkki) 114 { 115 Vector nopeus = orkki.Velocity; 116 117 if (orkki.Velocity.X >= 0) 118 { 119 orkki.X -= 2; 120 nopeus = RandomGen.SelectOne(ylos, alas, vasen); 121 } 122 else if (orkki.Velocity.X < 0) 123 { 124 orkki.X += 2; 125 nopeus = RandomGen.SelectOne(ylos, alas, oikea); 126 } 127 // orkki.Velocity = RandomGen.SelectOne(ylos, alas, vasen, oikea); 128 else if (orkki.Velocity.Y >= 0) 129 { 130 orkki.Y -= 2; 131 nopeus = RandomGen.SelectOne(alas, oikea, vasen); 132 } 133 else if (orkki.Velocity.Y < 0) 134 { 135 orkki.Y += 2; 136 nopeus = RandomGen.SelectOne(ylos, oikea, vasen); 137 } 138 orkki.Stop(); 139 orkki.Acceleration = Vector.Zero; 140 orkki.Velocity = nopeus; 141 142 143 } 144 145 void TormaaSeinaan(PhysicsObject orkki, PhysicsObject taso) 146 { 147 SatunnainenSuunta(orkki); 82 148 } 83 149 … … 85 151 { 86 152 avain.Destroy(); 153 87 154 } 88 155 … … 94 161 taso.Color = new Color(15,3,11); 95 162 taso.CollisionIgnoreGroup = 1; 163 taso.Restitution = 0.0; 164 taso.Tag = "taso"; 96 165 Add(taso); 97 166 } … … 106 175 } 107 176 177 IntMeter pisteLaskuri; 178 179 void LuoPistelaskuri() 180 { 181 pisteLaskuri = new IntMeter(0); 182 183 Label pisteNaytto = new Label(); 184 pisteNaytto.X = Screen.Left + 100; 185 pisteNaytto.Y = Screen.Top - 100; 186 pisteNaytto.TextColor = Color.Red; 187 pisteNaytto.Color = Color.Black; 188 189 pisteNaytto.BindTo(pisteLaskuri); 190 Add(pisteNaytto); 191 } 192 108 193 } -
2013/27/LeoL/Hounted Hause/Hounted Hause/Hounted HauseContent/Hounted HauseContent.contentproj
r4368 r4397 80 80 </Compile> 81 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="kentta2.png"> 84 <Name>kentta2</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 89 <ItemGroup> 90 <Compile Include="kentta3.png"> 91 <Name>kentta3</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 96 <ItemGroup> 97 <Compile Include="kentta4.png"> 98 <Name>kentta4</Name> 99 <Importer>TextureImporter</Importer> 100 <Processor>TextureProcessor</Processor> 101 </Compile> 102 </ItemGroup> 82 103 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 83 104 <!-- 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.