- Timestamp:
- 2010-06-10 11:41:46 (13 years ago)
- Location:
- 2010/23/lasakauh/Testi
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/lasakauh/Testi/Content/Content.contentproj
r627 r656 109 109 </Compile> 110 110 </ItemGroup> 111 <ItemGroup> 112 <Compile Include="b1.png"> 113 <Name>b1</Name> 114 <Importer>TextureImporter</Importer> 115 <Processor>TextureProcessor</Processor> 116 </Compile> 117 <Compile Include="b2.png"> 118 <Name>b2</Name> 119 <Importer>TextureImporter</Importer> 120 <Processor>TextureProcessor</Processor> 121 </Compile> 122 <Compile Include="b3.png"> 123 <Name>b3</Name> 124 <Importer>TextureImporter</Importer> 125 <Processor>TextureProcessor</Processor> 126 </Compile> 127 <Compile Include="b4.png"> 128 <Name>b4</Name> 129 <Importer>TextureImporter</Importer> 130 <Processor>TextureProcessor</Processor> 131 </Compile> 132 </ItemGroup> 111 133 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 112 134 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/23/lasakauh/Testi/Peli.cs
r627 r656 16 16 PlatformCharacter p1; 17 17 PlatformCharacter p2; 18 int hp1 = 100;19 int hp2 = 100;18 //int hp1 = 100; 19 //int hp2 = 100; 20 20 21 21 … … 43 43 lisaap2(); 44 44 hpbar1(); 45 lisaaTaso(0, -154); 45 46 hpbar2(); 46 47 hpp1(145,100); … … 50 51 void lisaaMaaTaso(double x, double y) 51 52 { 52 PhysicsObject taso = PhysicsObject.CreateStaticObject(302, 5);53 PhysicsObject taso = PhysicsObject.CreateStaticObject(302, 30); 53 54 taso.Image = LoadImage("taso_maa"); 54 55 taso.X = x; … … 68 69 void lisaaTaso(double x, double y) 69 70 { 70 PhysicsObject taso = PhysicsObject.CreateStaticObject(30 , 10);71 PhysicsObject taso = PhysicsObject.CreateStaticObject(300, 1); 71 72 taso.Image = LoadImage("taso_vaakaseina"); 72 73 taso.X = x; 73 74 taso.Y = y; 75 AddCollisionHandler(taso,Tuhous); 74 76 Add(taso); 75 77 } 76 78 79 void Tuhous(PhysicsObject taso, PhysicsObject kohde) 80 { 81 kohde.Destroy(); 82 MessageDisplay.Add("Pelaaja tuhoutui"); 83 } 77 84 void lisaaPelaajat() 78 85 { … … 108 115 Keyboard.Listen(Key.D, ButtonState.Down, liikutaEteen, "Liikkuu oikealle", p1,nopeusEteen); 109 116 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", p1, hyppyVoima); 117 Keyboard.Listen(Key.S, ButtonState.Pressed, iske,"iskee"); 118 Keyboard.Listen(Key.S, ButtonState.Released, lp_isku, "lopettaaiskun"); 110 119 111 120 Keyboard.Listen(Key.Left, ButtonState.Down, liikutaTaakse, "Liikkuu vasemmalle", p2, nopeusTaakse); 112 121 Keyboard.Listen(Key.Right, ButtonState.Down, liikutaEteen, "Liikkuu oikealle", p2, nopeusEteen); 113 122 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", p2, hyppyVoima); 114 Keyboard.Listen(Key.NumPad0, ButtonState.Pressed, iske,"iske"); 115 116 lisaaGamePadNappaimet(ControllerOne, p1); 117 lisaaGamePadNappaimet(ControllerTwo, p2); 118 } 119 120 void lisaaGamePadNappaimet(GamePad controller, PlatformCharacter hahmo) 123 Keyboard.Listen(Key.Down, ButtonState.Pressed, iske2, "iskee"); 124 Keyboard.Listen(Key.Down, ButtonState.Released, lp_isku2, "lopettaa iskun"); 125 126 127 lisaaGamePadNappaimet(ControllerOne, p1, iske, lp_isku); 128 lisaaGamePadNappaimet(ControllerTwo, p2, iske2, lp_isku2); 129 } 130 131 void lisaaGamePadNappaimet(GamePad controller, PlatformCharacter hahmo, Handler ikse,Handler end) 121 132 { 122 133 controller.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 124 135 controller.Listen(Button.DPadRight, ButtonState.Down, liikutaEteen, "Pelaaja liikkuu oikealle", hahmo, nopeusEteen); 125 136 controller.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", hahmo, hyppyVoima); 126 Vector tatinAsento = ControllerOne.LeftThumbDirection; 127 } 137 controller.Listen(Button.B, ButtonState.Pressed, ikse, "iskee"); 138 controller.Listen(Button.B, ButtonState.Released, end, "lopettaa iskun"); 139 } 128 140 129 141 void liikutaEteen(PlatformCharacter hahmo, double nopeus) … … 135 147 { 136 148 hahmo.Walk(-nopeus); 149 150 137 151 } 138 152 … … 141 155 hahmo.Jump(voima); 142 156 } 157 143 158 void hpbar1() 144 159 { … … 182 197 } 183 198 } 199 184 200 void iske() 185 201 { 186 Vector isku = new Vector(kohde.Position.X + 5, kohde.Position.Y + 5); 187 kohde.Hit(isku); 188 Image[] iskuKuvat = LoadImages("a1", "a2", "a3", "a4"); 202 Image[]iskuKuvat = LoadImages("a1", "a2", "a3", "a4"); 189 203 p1.Animation = new Animation(iskuKuvat); 190 p1.Animation.Start; 191 hp2 =-10; 192 for (int i = 1; i < 102 - hp1; i++) 193 { 194 PhysicsObject hpp1 = PhysicsObject.CreateStaticObject(1, 8.5); 195 hpp1.Shape = Shapes.Rectangle; 196 hpp1.Color = Color.Green; 197 hpp1.X = -146 + i; 198 hpp1.Y = 144.8; 199 Add(hpp1); 200 } 201 } 202 } 203 204 p1.Animation.Start(); 205 p1.Animation.FPS = 20; 206 } 207 208 void iske2() 209 { 210 Image[]p2Kuvat = LoadImages("b1", "b2", "b3", "b4"); 211 p2.Animation = new Animation(p2Kuvat); 212 p2.Animation.Start(); 213 p2.Animation.FPS = 20; 214 } 215 216 void lp_isku() 217 { 218 p1.Image = LoadImage("ninja"); 219 } 220 221 void lp_isku2() 222 { 223 p2.Image = LoadImage("ninja2"); 224 } 204 225 } 205 226 }
Note: See TracChangeset
for help on using the changeset viewer.