- Timestamp:
- 2010-07-08 14:57:08 (13 years ago)
- Location:
- 2010/27/viaawipi/samsh cubes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/viaawipi/samsh cubes/Content/Content.contentproj
r1127 r1195 75 75 </Compile> 76 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="seina.png"> 79 <Name>seina</Name> 80 <Importer>TextureImporter</Importer> 81 <Processor>TextureProcessor</Processor> 82 </Compile> 83 </ItemGroup> 77 84 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 78 85 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/27/viaawipi/samsh cubes/Peli.cs
r1151 r1195 13 13 const double hyppyVoima = 3000; 14 14 15 IntMeter pisteLaskuri;16 Label pisteNaytto;15 IntMeter isku1; 16 IntMeter isku2; 17 17 18 18 PlatformCharacter pelaaja1; 19 19 PlatformCharacter pelaaja2; 20 20 21 PhysicsObject reuna1; 22 PhysicsObject reuna2; 23 PhysicsObject reuna3; 24 PhysicsObject reuna4; 25 21 26 22 27 protected override void Begin() 23 28 { 24 Level.Width = 2000; 25 Level.Height = 1000; 26 27 pisteLaskuri = new IntMeter(0); 29 isku1 = new IntMeter(0); 30 isku2 = new IntMeter(0); 28 31 29 32 // Zoomataan lähemmäksi 33 34 seuraavaKentta(); 35 Camera.StayInLevel = true; 30 36 Camera.ZoomToLevel(); 31 Camera.StayInLevel = true;32 33 seuraavaKentta();34 37 } 35 38 36 39 void seuraavaKentta() 37 40 { 38 41 ClearAll(); 42 43 isku1 = new IntMeter(20); 44 isku2 = new IntMeter(20); 45 46 47 39 48 // Asetetaan painovoima 40 49 Gravity = new Vector(0, -1000); 41 50 42 // luodaan pistelaskunäyttö43 pisteNaytto = new Label();44 pisteNaytto.X = Screen.RightSafe - 250;45 pisteNaytto.Y = Screen.TopSafe - 50;46 pisteNaytto.BindTo(pisteLaskuri);47 Add(pisteNaytto);48 49 51 luoKentta(); 50 52 lisaaNappaimet(); 51 Camera.Follow(pelaaja1);52 53 } 53 54 54 55 void luoKentta() 55 56 { 56 TileMap ruudut = TileMap.FromFile("ken tta.txt");57 TileMap ruudut = TileMap.FromFile("kennta.txt"); 57 58 ruudut['#'] = Luotaso; 58 59 ruudut.Insert(rulev, rukor); 59 60 60 Level.CreateBorders(); 61 reuna1 = Level.CreateLeftBorder(); 62 reuna2 = Level.CreateRightBorder(); 63 reuna3 = Level.CreateTopBorder(); 64 reuna4 = Level.CreateBottomBorder(); 65 66 reuna1.Tag = "reuna"; 67 reuna2.Tag = "reuna"; 68 reuna3.Tag = "reuna"; 69 reuna4.Tag = "reuna"; 70 71 61 72 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 62 73 Level.Background.Image = LoadImage("aa"); … … 64 75 65 76 lisaaPelaajat(); 77 78 Timer ajastin = new Timer(); 79 ajastin.Interval = 1; 80 ajastin.Trigger += HeitaKranaatti; 81 Add(ajastin); 82 ajastin.Start(); 83 66 84 } 67 85 … … 69 87 { 70 88 PhysicsObject taso = PhysicsObject.CreateStaticObject(50.0, 50.0); 89 taso.Image = LoadImage("seina"); 71 90 return taso; 72 91 } … … 78 97 pelaaja1.Image = LoadImage("aa"); 79 98 pelaaja1.X = 100; 80 pelaaja1.Y = 120;81 99 pelaaja1.Y = 120; 100 82 101 pelaaja2 = new PlatformCharacter(40, 40); 83 102 pelaaja2.Mass = 4.0; 84 103 pelaaja2.Image = LoadImage("ss"); 85 104 pelaaja2.X = -100; 86 pelaaja2.Y =120; 87 88 AddCollisionHandler(pelaaja1, PelaajaOsuu); 89 AddCollisionHandler(pelaaja2, PelaajaOsuu); 105 pelaaja2.Y = 120; 106 107 AddCollisionHandler(pelaaja1, kasitteletormays); 108 AddCollisionHandler(pelaaja2, kasitteletormays); 109 90 110 91 111 Add(pelaaja1); … … 101 121 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, nopeus); 102 122 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); 103 Keyboard.Listen(Key.P, ButtonState.Pressed, poks1, "rajauta"); 104 Keyboard.Listen(Key.O, ButtonState.Pressed, poks2, "rajauta"); 105 Keyboard.Listen(Key.I, ButtonState.Pressed, HeitaKranaatti , "rajauta"); 123 Keyboard.Listen(Key.Down, ButtonState.Pressed, iske1, "tiputa"); 124 125 126 106 127 107 128 Keyboard.Listen(Key.A, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 108 129 Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja2, nopeus); 109 130 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja2, hyppyVoima); 131 Keyboard.Listen(Key.S, ButtonState.Pressed, iske2, "tiputa"); 132 133 Keyboard.Listen(Key.Enter, ButtonState.Pressed, seuraavaKentta , "Hyppää"); 110 134 111 135 … … 132 156 } 133 157 134 void PelaajaOsuu(PhysicsObject collidingObject, PhysicsObject pum) 135 { 158 void kasitteletormays(PhysicsObject pelaaja, PhysicsObject kohde) 159 { 160 if (kohde.Tag.ToString() == "reuna") 161 { 162 pelaaja.Destroy(); 163 if (pelaaja.Equals(pelaaja1)) 164 { 165 MessageDisplay.Add("turkoosi voitti"); 166 MessageDisplay.Add("enter = uusi peli"); 167 return; 168 } 169 MessageDisplay.Add("punainen voitti"); 170 MessageDisplay.Add("enter = uusi peli"); 171 } 172 } 173 174 void iske1() 175 { 176 Vector aba = new Vector(pelaaja2.X - pelaaja1.X, pelaaja2.Y - pelaaja1.Y); 177 if (aba.Magnitude<75) 178 { 179 isku1.Value +=RandomGen.NextInt(1,10); 180 pelaaja2.Hit(new Vector(aba.X * isku1, aba.Y * isku1)); 181 } 182 183 } 184 void iske2() 185 { 186 187 Vector aba = new Vector(pelaaja1.X - pelaaja2.X, pelaaja1.Y - pelaaja2.Y); 188 if (aba.Magnitude < 75) 189 { 190 isku2.Value += RandomGen.NextInt(1, 10); 191 pelaaja1.Hit(new Vector(aba.X * isku2, aba.Y * isku2)); 192 } 193 194 } 195 void HeitaKranaatti(Timer sender) 196 { 197 198 Explosion rajahdys = new Explosion(RandomGen.NextDouble(10,50)); 199 rajahdys.X = RandomGen.NextDouble(Level.Left, Level.Right); 200 rajahdys.Force = 500; 201 rajahdys.Y = RandomGen.NextDouble(Level.Left, Level.Right); 202 Add(rajahdys); 203 204 } 205 136 206 137 } 138 void poks1() 139 { 140 Explosion rajahdys = new Explosion(10.0); 141 rajahdys.Position = pelaaja2.Position; 142 rajahdys.X-=40; 143 rajahdys.Y -= 25; 144 rajahdys.Speed = 1000.0; 145 rajahdys.Force =50; 146 rajahdys.ShockwaveColor = Color.Cyan; 147 Add(rajahdys); 148 } 149 void poks2() 150 { 151 Explosion rajahdys = new Explosion(10.0); 152 rajahdys.Position = pelaaja1.Position; 153 rajahdys.Y -= 15; 154 rajahdys.Speed = 1000.0; 155 rajahdys.Force =50; 156 rajahdys.ShockwaveColor = Color.Red; 157 Add(rajahdys); 158 } 159 void pumpum () 160 { 161 PhysicsObject pum = PhysicsObject.CreateStaticObject(20.0, 20.0); 162 pum.Position = pelaaja2.Position; 163 pum.Shape = Shapes.Circle; 164 Add(pum); 165 } 166 void HeitaKranaatti() 167 { 168 ClusterGrenade kranaatti = new ClusterGrenade(4.0, 2); 169 kranaatti.X = pelaaja1.X; 170 kranaatti.Y = pelaaja1.Y; 171 Add(kranaatti); 172 Vector heittoVoima = Vector.FromLengthAndAngle(10, Angle.Degrees(0)); 173 kranaatti.Hit(heittoVoima); 174 } 207 175 208 } -
2010/27/viaawipi/samsh cubes/samsh cubes.csproj
r1151 r1195 89 89 <Content Include="Game.ico" /> 90 90 <Content Include="GameThumbnail.png" /> 91 <Content Include="kentta.txt" /> 91 <Content Include="kennta.txt"> 92 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 93 </Content> 92 94 </ItemGroup> 93 95 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.