Changeset 1154
- Timestamp:
- 2010-07-07 14:55:11 (13 years ago)
- Location:
- 2010/27/jomiilri/Duel
- Files:
-
- 5 added
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
2010/27/jomiilri/Duel/Content/Content.contentproj
r1131 r1154 47 47 <Processor>TextureProcessor</Processor> 48 48 </Compile> 49 </ItemGroup>50 <ItemGroup>51 49 <Compile Include="taustakuva1.bmp"> 52 50 <Name>taustakuva1</Name> … … 55 53 </Compile> 56 54 </ItemGroup> 55 <ItemGroup> 56 <Compile Include="pelaaja1.png"> 57 <Name>pelaaja1</Name> 58 <Importer>TextureImporter</Importer> 59 <Processor>TextureProcessor</Processor> 60 </Compile> 61 </ItemGroup> 62 <ItemGroup> 63 <Compile Include="pelaaja2.png"> 64 <Name>pelaaja2</Name> 65 <Importer>TextureImporter</Importer> 66 <Processor>TextureProcessor</Processor> 67 </Compile> 68 </ItemGroup> 57 69 </Project> -
2010/27/jomiilri/Duel/Peli.cs
r1131 r1154 6 6 public class Peli : PhysicsGame 7 7 { 8 P latformCharacterp1;9 P latformCharacterp2;8 PhysicsObject p1; 9 PhysicsObject p2; 10 10 11 11 double tyontovoima = 400; 12 12 const int ruudunLeveys = 32; 13 13 const int ruudunKorkeus = 32; … … 18 18 AloitaPeli(); 19 19 IsFullScreen = true; 20 p1 = LuoHahmo(); 20 p1 = LuoHahmo1(); 21 p1.LinearDamping = 0.95; 21 22 Add(p1); 23 24 p2 = LuoHahmo2(); 25 p2.LinearDamping = 0.95; 26 Add(p2); 22 27 LuoOhjaimet(); 23 28 } … … 30 35 ylareuna.Image = LoadImage("tausta1"); 31 36 32 //Level.Background.Image = LoadImage("taustakuva1");33 //Level.Background.FitToLevel();37 Level.Background.Image = LoadImage("taustakuva1"); 38 Level.Background.FitToLevel(); 34 39 35 40 Camera.ZoomToLevel(); … … 39 44 { 40 45 TileMap ruudut = TileMap.FromFile("TextFile1.txt"); 41 42 46 ruudut['I'] = LuoSeina; 43 47 ruudut.Insert(ruudunLeveys, ruudunKorkeus); … … 49 53 seina.Shape = Shapes.Rectangle; 50 54 seina.Image = LoadImage("tausta1"); 55 51 56 return seina; 52 57 } 53 58 54 P latformCharacter LuoHahmo()59 PhysicsObject LuoHahmo1() 55 60 { 56 P latformCharacter ukko = new PlatformCharacter(32, 32);57 61 PhysicsObject ukko = new PhysicsObject (32, 32); 62 ukko.Image = LoadImage("pelaaja1"); 58 63 return ukko; 59 64 } 60 65 61 void LiikutaPelaajaa()66 PhysicsObject LuoHahmo2() 62 67 { 68 PhysicsObject ukko = new PhysicsObject(32, 32); 69 ukko.Image = LoadImage("pelaaja2"); 70 return ukko; 71 } 63 72 73 void LiikutaPelaajaa(PhysicsObject pelaaja) 74 { 75 Vector tyonto = Vector.FromLengthAndAngle(tyontovoima, pelaaja.Angle); 76 pelaaja.Push(tyonto); 77 } 78 79 void LiikutaPelaajaaTaakse(PhysicsObject pelaaja) 80 { 81 Vector taakse = Vector.FromLengthAndAngle(-tyontovoima, pelaaja.Angle); 82 pelaaja.Push(taakse); 64 83 } 65 84 66 85 void LuoOhjaimet() 67 86 { 68 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null); 69 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null); 70 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null); 71 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null); 87 Keyboard.Listen(Key.Left, ButtonState.Down, KaannaPelaajaa, null, 3, p1); 88 Keyboard.Listen(Key.Right, ButtonState.Down, KaannaPelaajaa, null, -3, p1); 89 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, p1); 90 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaPelaaja, null, p1); 91 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaaTaakse, null, p1); 92 93 Keyboard.Listen(Key.A, ButtonState.Down, KaannaPelaajaa, null, 3, p2); 94 Keyboard.Listen(Key.D, ButtonState.Down, KaannaPelaajaa, null, -3, p2); 95 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, null, p2); 96 Keyboard.Listen(Key.W, ButtonState.Released, PysaytaPelaaja, null, p2); 97 Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaaTaakse, null, p2); 98 } 99 100 void KaannaPelaajaa(int kulma, PhysicsObject pelaaja) 101 { 102 pelaaja.Angle += Angle.Degrees(kulma); 103 } 104 105 void PysaytaPelaaja(PhysicsObject pelaaja) 106 { 107 pelaaja.Stop(); 72 108 } 73 109
Note: See TracChangeset
for help on using the changeset viewer.