- Timestamp:
- 2010-07-07 14:56:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/Vekakart/Catch The Rainbow/Catch The Rainbow/Peli.cs
r1129 r1156 7 7 8 8 { 9 const int ruudunleveys = 50; 10 const int ruudunkorkeus = 50; 11 12 Vector NopeusEteen = new Vector(200, 0); 13 14 PlatformCharacter Chandler; 15 9 16 protected override void Begin() 10 17 { 11 18 LuoChandler(); 19 AsetaOhjaimet(); 12 20 LuoKentta(); 13 AsetaOhjaimet();21 14 22 } 15 23 void LuoKentta() 16 24 { 17 Level.CreateBorders (); 25 Camera.FollowedObject = Chandler; 26 27 TileMap ruudut = TileMap.FromFile("Kentta1.txt"); 28 ruudut ['='] = LuoPalikka; 29 ruudut['C'] = LuoRainbow; 30 ruudut.Insert(ruudunleveys, ruudunkorkeus); 31 18 32 Gravity = new Vector(0.0, -800.0); 19 33 34 } 35 PhysicsObject LuoPalikka() 36 { 37 PhysicsObject Palikka = PhysicsObject.CreateStaticObject(50, 50); 38 Palikka.Color = Color.Brown; 39 return Palikka; 40 } 41 PhysicsObject LuoRainbow() 42 { 43 PhysicsObject Rainbow = PhysicsObject.CreateStaticObject(25, 25); 44 Rainbow.Image = Image.FromFile (" 45 return Rainbow; 20 46 } 21 47 22 48 void LuoChandler() 23 49 { 24 PhysicsObject Chandler = new PhysicsObject(20,60);50 Chandler = new PlatformCharacter(20,45); 25 51 Chandler.Restitution = 0.0; 52 Chandler.CanRotate = false; 26 53 Chandler.X = -450; 27 Chandler.Y = -375; 54 Chandler.Y = -365; 55 Chandler.KineticFriction = 0.0; 28 56 Add (Chandler); 29 57 return; 30 58 } 31 59 32 void AsetaOhjaimet( PhysicsObject Chandler)60 void AsetaOhjaimet() 33 61 { 34 Keyboard.Listen(Key.D, ButtonState.Down, PelaajaLiikuEteenpain); 62 Keyboard.Listen(Key.A, ButtonState.Down, PelaajaLiikuTaakse, "Liiku Taaksepäin"); 63 Keyboard.Listen(Key.A, ButtonState.Released, PelaajaPysahdy, null); 64 Keyboard.Listen(Key.D, ButtonState.Down, PelaajaLiikuEteenpain, "Liiku Eteenpäin"); 65 Keyboard.Listen(Key.D, ButtonState.Released, PelaajaPysahdy, null); 66 Keyboard.Listen(Key.W, ButtonState.Down, PelaajaHypaa, "Hyppää"); 67 68 69 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 70 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 35 71 } 36 72 void PelaajaLiikuEteenpain() 37 73 { 74 Chandler.Walk(200); 75 } 76 77 void PelaajaLiikuTaakse() 78 { 79 Chandler.Walk (-200); 80 } 81 82 void PelaajaPysahdy() 83 { 84 Vector nopeus = new Vector(0.0, 0); 85 } 86 87 void PelaajaHypaa() 88 { 89 Chandler.Jump(1000); 38 90 } 39 91 }
Note: See TracChangeset
for help on using the changeset viewer.