- Timestamp:
- 2017-06-15 10:34:46 (6 years ago)
- Location:
- 2017/24/IlariI/piXgel GAmE/piXgel GAmE/piXgel_GAmE
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/24/IlariI/piXgel GAmE/piXgel GAmE/piXgel_GAmE/piXgel_GAmE.cs
r8663 r8686 10 10 { 11 11 AssaultRifle hahmonase; 12 12 13 14 IntMeter pisteLaskuri; 15 16 13 17 PhysicsObject hahmo; 14 18 Vector nopeusVasemmalle = new Vector(-100.0, 0.0); … … 29 33 30 34 hahmonase = new AssaultRifle(30, 10); 31 35 hahmonase.Image = null; 32 36 33 37 … … 36 40 37 41 Keyboard.Listen(Key.Space, ButtonState.Down, Ammuaseella, "Ammu", hahmonase); 38 39 42 40 43 PhysicsObject vihollinen = new PhysicsObject(40, 40); … … 42 45 vihollinen.X = -300; 43 46 vihollinen.Y = -200; 44 45 47 vihollinen.Tag = "vihu"; 48 49 50 51 46 52 FollowerBrain seuraajanAivot = new FollowerBrain(hahmo); 47 53 Add(vihollinen); … … 49 55 vihollinen.Brain = seuraajanAivot; 50 56 51 seuraajanAivot.Speed = 60;57 seuraajanAivot.Speed = 80; 52 58 seuraajanAivot.DistanceFar = 600; 53 59 seuraajanAivot.DistanceClose = 37; … … 55 61 56 62 57 seuraajanAivot.TargetClose += KunPaaseeLahelle; 58 63 seuraajanAivot.TargetClose += KunPaaseeLahelle; 59 64 60 65 61 66 Luopistelaskuri(); 67 62 68 Add(hahmo); 63 69 64 70 65 71 LuoKentta(); 66 72 // TODO: Kirjoita ohjelmakoodisi tähän(); … … 69 75 Keyboard.Listen(Key.Right, ButtonState.Down, KavelytaPelaajaa, null, nopeusOikealle); 70 76 Keyboard.Listen(Key.Up, ButtonState.Down, KavelytaPelaajaa, null, nopeusYlos); 71 Keyboard.Listen(Key.Down, ButtonState.Down, KavelytaPelaajaa, null, nopeusAlas);77 Keyboard.Listen(Key.Down, ButtonState.Down, KavelytaPelaajaa, null, nopeusAlas); 72 78 73 Keyboard.Listen(Key.Left, ButtonState.Released, KavelytaPelaajaa, null, pysahtuuVasemmalle);79 Keyboard.Listen(Key.Left, ButtonState.Released, KavelytaPelaajaa, null, pysahtuuVasemmalle); 74 80 Keyboard.Listen(Key.Right, ButtonState.Released, KavelytaPelaajaa, null, pysahtuuOikealle); 75 81 Keyboard.Listen(Key.Up, ButtonState.Released, KavelytaPelaajaa, null, pysahtuuYlos); 76 82 Keyboard.Listen(Key.Down, ButtonState.Released, KavelytaPelaajaa, null, pysahtuuAlas); 77 83 78 84 79 85 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 80 86 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 81 87 88 } 89 90 void Luopistelaskuri() 91 { 92 pisteLaskuri = new IntMeter(0); 93 94 Label pisteNaytto = new Label(); 95 pisteNaytto.X = Screen.Left + 100; 96 pisteNaytto.Y = Screen.Top - 100; 97 pisteNaytto.TextColor = Color.White; 98 pisteNaytto.Color = Color.Black; 99 100 pisteNaytto.BindTo(pisteLaskuri); 101 Add(pisteNaytto); 102 103 if (Ammus.hit("vihu")) 104 { 105 pisteLaskuri.Value += 1; 106 } 107 82 108 } 83 109 … … 95 121 Camera.Follow(hahmo); 96 122 Camera.Zoom(2.0); 97 98 123 124 99 125 } 100 126 101 127 void Ammusosui(PhysicsObject ammus, PhysicsObject kohde) 102 128 { 103 129 ammus.Destroy(); 104 kohde.Destroy(); 130 if (kohde.Tag.Equals("vihu")) 131 { 132 kohde.Destroy(); 133 } 134 105 135 } 106 136 … … 109 139 PhysicsObject ammus = ase.Shoot(); 110 140 111 if (ammus != null)141 if (ammus != null) 112 142 { 113 143 ammus.Size *= 0.5; 114 144 115 145 ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 116 146 } 117 147 } 118 148 void KunPaaseeLahelle() 149 { 150 hahmo.Destroy(); 151 } 119 152 void KavelytaPelaajaa(Vector suunta) 120 153 { 121 154 hahmo.Velocity = suunta; 122 if (suunta.X<0)155 if (suunta.X < 0) 123 156 { 124 157 hahmonase.Angle = Angle.FromDegrees(180.0); 125 158 } 126 if (suunta.X >0)159 if (suunta.X > 0) 127 160 { 128 hahmonase.Angle = Angle.FromDegrees( 180.0);129 161 hahmonase.Angle = Angle.FromDegrees(0.0); 162 130 163 } 131 164 if (suunta.Y > 0) 132 { hahmonase.Angle = Angle.FromDegrees(90.0);133 134 135 }136 if (suunta.Y < 0)137 165 { 138 166 hahmonase.Angle = Angle.FromDegrees(90.0); 167 168 139 169 } 140 141 void KunPaaseeLahelle() 142 { 143 hahmo.Color = Color.Red; 170 if (suunta.Y < 0) 171 { 172 hahmonase.Angle = Angle.FromDegrees(270.0); 173 } 174 175 176 144 177 } 145 146 147 148 149 } 178 }
Note: See TracChangeset
for help on using the changeset viewer.