- Timestamp:
- 2012-07-03 15:01:54 (9 years ago)
- Location:
- 2012/27/JesseK
- Files:
-
- 17 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/JesseK/omapeli/omapeli/omapeli/omapeli.cs
r3444 r3490 11 11 Vector nopeusOikea = new Vector(150, 0); 12 12 Vector nopeusVasen = new Vector(-150, 0); 13 14 P hysicsObjectukko;15 13 Vector nopeusHyppy = new Vector(0, 300); 14 PlatformCharacter ukko; 15 // PhysicsObject taso; 16 16 public override void Begin() 17 17 { 18 19 18 20 LuoKentta(); 19 AsetaNopeus(); 21 LuoTaso(-150, Level.Bottom + 40.0); 22 LuoPelaaja(); 20 23 AsetaKontrollit(); 24 Gravity = new Vector(0, -1100); 21 25 22 ukko = new PhysicsObject(15, 25); 26 Camera.ZoomFactor = 6.0; 27 Camera.Follow(ukko); 28 29 30 } 31 32 void LuoPelaaja() 33 { 34 ukko = new PlatformCharacter(15, 25); 35 ukko.X = -500; 36 ukko.Y = Level.Bottom; 23 37 ukko.Shape = Shape.Rectangle; 24 ukko.Color = Color.Teal; 38 ukko.Color = Color.Transparent; 39 ukko.Image = LoadImage("hqkeijo"); 40 ukko.CanRotate = false; 41 ukko.MaintainMomentum = true; 42 ukko.LinearDamping = 0.93; 43 ukko.CollisionIgnoreGroup = 1; 25 44 Add(ukko); 45 } 46 47 void LuoKentta() 48 { 49 Level.BackgroundColor = Color.SkyBlue; 50 PhysicsObject alareuna = Level.CreateBottomBorder(); 51 alareuna.IsVisible = true; 52 alareuna.Color = Color.Transparent; 53 alareuna.Image = LoadImage("hqmaa"); 54 55 LuoMyrkkysieni(-150.0, Level.Bottom + 12.5); 26 56 27 Camera.ZoomToLevel(); 57 PhysicsObject kyltti = PhysicsObject.CreateStaticObject(100, 100); 58 kyltti.X = -350; 59 kyltti.Y = Level.Bottom + 20.0; 60 kyltti.Color = Color.Beige; 61 kyltti.CollisionIgnoreGroup = 1; 62 Add(kyltti); 28 63 64 } 65 66 void LuoMyrkkysieni(double x, double y) 67 { 68 PhysicsObject sieni = PhysicsObject.CreateStaticObject(25, 25); 69 sieni.Color = Color.Transparent; 70 sieni.Image = LoadImage("hqmyrkkysieni"); 71 sieni.X = x; 72 sieni.Y = y; 73 Add(sieni); 74 } 75 76 void AsetaNopeus(PlatformCharacter ukko, double nopeus) 77 { 78 ukko.Walk(nopeus); 79 } 80 81 void Hyppaa(PlatformCharacter ukko, double hyppy) 82 { 83 ukko.Jump(hyppy); 84 } 85 86 void AsetaKontrollit() 87 { 88 Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa oikealle", ukko, 90.0); 89 Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa vasemmalle", ukko, -90.0); 90 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Hyppää", ukko, 490.0); 29 91 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 30 92 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 31 }32 void LuoKentta()33 {34 Level.BackgroundColor = Color.Black;35 93 36 94 } 37 void AsetaNopeus() 95 96 void LuoTaso(double x, double y) 38 97 { 39 ukko.Velocity = nopeus; 40 } 41 void AsetaKontrollit() 42 { 43 Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa oikealle", ukko, nopeusOikea); 44 Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, ukko, Vector.Zero); 98 PhysicsObject taso = PhysicsObject.CreateStaticObject(23, 9); 99 taso.X = x; 100 taso.Y = y; 101 taso.Image = LoadImage("hqalusta"); 102 Add(taso); 45 103 } 46 104 47 48 105 } -
2012/27/JesseK/omapeli/omapeli/omapeliContent/omapeliContent.contentproj
r3444 r3490 44 44 <Reference Include="TextFileContentExtension" /> 45 45 </ItemGroup> 46 <ItemGroup> 47 <Compile Include="keijo.png"> 48 <Name>keijo</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 52 </ItemGroup> 53 <ItemGroup> 54 <Compile Include="myrkkysieni.png"> 55 <Name>myrkkysieni</Name> 56 <Importer>TextureImporter</Importer> 57 <Processor>TextureProcessor</Processor> 58 </Compile> 59 </ItemGroup> 60 <ItemGroup> 61 <Compile Include="alusta.png"> 62 <Name>alusta</Name> 63 <Importer>TextureImporter</Importer> 64 <Processor>TextureProcessor</Processor> 65 </Compile> 66 </ItemGroup> 67 <ItemGroup> 68 <Compile Include="hqalusta.png"> 69 <Name>hqalusta</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 <Compile Include="hqmyrkkysieni.png"> 74 <Name>hqmyrkkysieni</Name> 75 <Importer>TextureImporter</Importer> 76 <Processor>TextureProcessor</Processor> 77 </Compile> 78 </ItemGroup> 79 <ItemGroup> 80 <Compile Include="hqkeijo.png"> 81 <Name>hqkeijo</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="hqkolikko.png"> 88 <Name>hqkolikko</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="hqmaa.png"> 95 <Name>hqmaa</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 46 100 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 47 101 <!-- 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.