Changeset 2035
- Timestamp:
- 2011-06-15 15:04:56 (12 years ago)
- Location:
- 2011/24/EliasY
- Files:
-
- 12 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/EliasY/Pixel Quest/Pixel Quest/Pixel Quest/Peli.cs
r2000 r2035 9 9 public class Peli : PhysicsGame 10 10 { 11 Image Tausta = LoadImage("TaustaKentta"); 12 Image kivikuva = LoadImage("kiviValmis"); 11 Image Tausta = LoadImage("Tausta"); 12 Image kivikuva = LoadImage("kivi"); 13 Image pelaajankuva = LoadImage("Pelaaja"); 14 Image tiematsku = LoadImage("Tiematsku"); 15 Image hallitsijankuva = LoadImage("Hallitsija"); 16 PhysicsObject Pelaaja; 17 PhysicsObject hallitsija; 18 GameObject tie; 19 Vector ylos = new Vector(0, 200); 13 20 public override void Begin() 14 21 { … … 17 24 void LuoKentta() 18 25 { 26 Level.Width = 2000; 27 Level.Height = 2000; 19 28 Level.CreateBorders(); 20 Camera.ZoomFactor = 14.0;29 Camera.ZoomFactor = 5.0; 21 30 Level.Background.Image = Tausta; 22 LuoKivi(7, 7); 31 Level.Background.FitToLevel(); 32 33 34 LuoTie(1600, 30, 0, 0); 35 LuoTie(30, 600, -800, 285); 36 LuoTie(30, 600, -700, -285); 37 LuoTie(30, 1200, 800, 0); 38 LuoTie(400, 30, 700, 600); 39 LuoTie(400, 30, 700, -600); 40 41 //LuoKivi(100, 100); 42 LuoPelaaja(); 43 Camera.Follow(Pelaaja); 44 45 LuoOlennot(); 23 46 } 24 void LuoKivi(double x, double y) 47 //void LuoKivi(double x, double y) 48 //{ 49 // PhysicsObject kivi = PhysicsObject.CreateStaticObject(x, y); 50 // kivi.Angle = RandomGen.NextAngle(); 51 // kivi.Shape = Shape.FromImage(kivikuva); 52 // kivi.Image = kivikuva; 53 // Add(kivi); 54 //} 55 void LuoTie(double kokoX, double kokoY, double sijaintiX, double sijaintiY) 25 56 { 26 PhysicsObject kivi = PhysicsObject.CreateStaticObject(x, y); 27 kivi.Angle = RandomGen.NextAngle(); 28 kivi.Shape = Shape.FromImage(kivikuva); 29 kivi.Image = kivikuva; 30 Add(kivi); 57 tie = new GameObject(kokoX, kokoY, Shape.Rectangle); 58 tie.X = sijaintiX; 59 tie.Y = sijaintiY; 60 tie.Image = tiematsku; 61 Add(tie); 62 } 63 void LuoPelaaja() 64 { 65 Pelaaja = new PhysicsObject(10,10); 66 Pelaaja.Image = pelaajankuva; 67 Pelaaja.Shape = Shape.FromImage(pelaajankuva); 68 Pelaaja.CanRotate = false; 69 Add(Pelaaja); 70 LuoLiikunta(); 71 } 72 void LuoLiikunta() 73 { 74 Keyboard.Listen(Key.W, ButtonState.Pressed, LiikuYlos, "Liikuta Pelaajaa ylös."); 75 Keyboard.Listen(Key.W, ButtonState.Released, Pysayta, null); 76 Keyboard.Listen(Key.S, ButtonState.Pressed, LiikuAlas, "Liikuta Pelaajaa alas."); 77 Keyboard.Listen(Key.S, ButtonState.Released, Pysayta, null); 78 Keyboard.Listen(Key.A, ButtonState.Pressed, LiikuVasemmalle, "Liikuta Pelaajaa vasemmalle."); 79 Keyboard.Listen(Key.A, ButtonState.Released, Pysayta, null); 80 Keyboard.Listen(Key.D, ButtonState.Pressed, LiikuOikealle, "Liikuta Pelaajaa oikealle."); 81 Keyboard.Listen(Key.D, ButtonState.Released, Pysayta, null); 82 Keyboard.Listen(Key.M, ButtonState.Pressed, Kartta, "Näytä kartta"); 83 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 84 } 85 void LuoOlennot() 86 { 87 hallitsija = new PhysicsObject(10,10); 88 //hallitsija.Shape = Shape.FromImage(hallitsijankuva); 89 hallitsija.Image = hallitsijankuva; 90 hallitsija.X = -100; 91 hallitsija.Y = 100; 92 hallitsija.LinearDamping = 0.7; 93 hallitsija.CanRotate = false; 94 //Tee kääntymisenesto 95 Add(hallitsija); 96 } 97 void LiikuYlos() 98 { 99 Vector ylos = new Vector(0, 200); 100 Pelaaja.Angle = Angle.FromDegrees(0); 101 Pelaaja.Hit(ylos); 102 } 103 void LiikuAlas() 104 { 105 Vector alas = new Vector(0, -200); 106 Pelaaja.Angle = Angle.FromDegrees(180); 107 Pelaaja.Hit(alas); 108 } 109 void LiikuVasemmalle() 110 { 111 Vector vasemmalle = new Vector(-200, 0); 112 Pelaaja.Angle = Angle.FromDegrees(90); 113 Pelaaja.Hit(vasemmalle); 114 } 115 void LiikuOikealle() 116 { 117 Vector oikealle = new Vector(200, 0); 118 Pelaaja.Angle = Angle.FromDegrees(270); 119 Pelaaja.Hit(oikealle); 120 } 121 void Pysayta() 122 { 123 Pelaaja.Velocity = Vector.Zero; 124 } 125 void Kartta() 126 { 127 if (Camera.ZoomFactor >= 5.0) 128 { 129 Camera.ZoomFactor = 1.0; 130 } 131 else if (Camera.ZoomFactor <= 1.0) 132 { 133 Camera.ZoomFactor = 5.0; 134 } 31 135 } 32 136 } -
2011/24/EliasY/Pixel Quest/Pixel Quest/Pixel QuestContent/Pixel QuestContent.contentproj
r2017 r2035 43 43 </ItemGroup> 44 44 <ItemGroup> 45 <Compile Include=" TaustaKentta.png">46 <Name> TaustaKentta</Name>45 <Compile Include="kivi.png"> 46 <Name>kivi</Name> 47 47 <Importer>TextureImporter</Importer> 48 48 <Processor>TextureProcessor</Processor> … … 50 50 </ItemGroup> 51 51 <ItemGroup> 52 <Compile Include="kivi.png"> 53 <Name>kivi</Name> 52 <Compile Include="Tausta.bmp"> 53 <Name>Tausta</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 </ItemGroup> 58 <ItemGroup> 59 <Compile Include="Pelaaja.png"> 60 <Name>Pelaaja</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 </Compile> 64 </ItemGroup> 65 <ItemGroup> 66 <Compile Include="Tiematsku.png"> 67 <Name>Tiematsku</Name> 68 <Importer>TextureImporter</Importer> 69 <Processor>TextureProcessor</Processor> 70 </Compile> 71 </ItemGroup> 72 <ItemGroup> 73 <Compile Include="Hallitsija.png"> 74 <Name>Hallitsija</Name> 54 75 <Importer>TextureImporter</Importer> 55 76 <Processor>TextureProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.