Changeset 1360
- Timestamp:
- 2010-07-28 11:30:28 (13 years ago)
- Location:
- 2010/30/johulkko
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/johulkko/FysiikkaPeli2/Content/Content.contentproj
r1333 r1360 41 41 </Compile> 42 42 </ItemGroup> 43 <ItemGroup> 44 <Compile Include="hahmo2.png"> 45 <Name>hahmo2</Name> 46 <Importer>TextureImporter</Importer> 47 <Processor>TextureProcessor</Processor> 48 </Compile> 49 </ItemGroup> 43 50 </Project> -
2010/30/johulkko/FysiikkaPeli2/Peli.cs
r1333 r1360 6 6 public class Peli : PhysicsGame 7 7 { 8 double maastonLeveys = 800; 9 double maastonKorkeus = 200; 8 double nopeusvasemmalle = 200; 9 double nopeusoikealle = -200; 10 11 double maastonLeveys = 1000; 12 double maastonKorkeus = 300; 10 13 Image maastonKuva = LoadImage("tausta"); 11 14 Shape maastonMuoto; 15 Image olionKuva = LoadImage("hahmo2"); 16 PlatformCharacter hahmo; 12 17 13 18 protected override void Begin() 14 19 { 15 20 LuoKentta(); 21 LuoOhjaimet(); 16 22 Camera.ZoomToLevel(); 17 23 } … … 25 31 maastonKorkeus, 26 32 maastonMuoto); 27 maasto.Image = maastonKuva;33 //maasto.Image = maastonKuva; 28 34 Add(maasto); 35 maasto.Y = -249; 36 37 Level.CreateLeftBorder(); 38 Level.CreateBottomBorder(); 39 Level.CreateRightBorder(); 40 41 hahmo = new PlatformCharacter(50, 72); 42 43 hahmo.Shape = Shapes.Rectangle; 44 hahmo.Image = olionKuva; 45 Add(hahmo); 46 47 hahmo.Y = -199; 48 hahmo.X = -110; 29 49 } 50 51 void Liikuta(PlatformCharacter hahmo, double nopeus) 52 { 53 hahmo.Walk(nopeus); 54 } 55 void LuoOhjaimet() 56 { 57 Keyboard.Listen( Key.Escape, ButtonState.Pressed, Exit, "Poistu" ); 58 59 Keyboard.Listen(Key.Left, ButtonState.Down, HahmoLiikkuu, "hahmo liikkuu vasemmalle", hahmo, nopeusvasemmalle); 60 Keyboard.Listen(Key.Left, ButtonState.Released, HahmoLiikkuu , null, hahmo, 0.0); 61 Keyboard.Listen(Key.Right, ButtonState.Down, HahmoLiikkuu, "hahmo liikkuu oikealle", hahmo, nopeusoikealle); 62 Keyboard.Listen(Key.Right, ButtonState.Released, HahmoLiikkuu, null, hahmo, 0.0); 63 Keyboard.Listen(Key.Up, ButtonState.Down, Hahmohyppaa, "hahmo liikkuu oikealle", hahmo); 64 Keyboard.Listen(Key.Up, ButtonState.Released, Hahmohyppaa, null, hahmo); 65 66 67 } 68 69 void HahmoLiikkuu(PlatformCharacter hahmo, double nopeus) 70 { 71 hahmo.Walk(nopeus); 72 } 73 74 void Hahmohyppaa(PlatformCharacter hahmo) 75 { 76 hahmo.Jump(100); 77 } 78 79 30 80 } 31 81
Note: See TracChangeset
for help on using the changeset viewer.