- Timestamp:
- 2012-07-06 12:46:28 (11 years ago)
- Location:
- 2012/27/MarkusK/projekti/Kouura/Kouura
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/MarkusK/projekti/Kouura/Kouura/Kouura/Kouura.cs
r3603 r3667 12 12 const int ruudunkorkeus = 1; 13 13 14 IntMeter Ammukset; 14 15 IntMeter Paukut; 15 16 16 17 PhysicsObject Pelaaja; 17 18 18 Vector NopeusYlos = new Vector(0, 50); 19 Vector NopeusAlas = new Vector(0, -50); 20 Vector NopeusVasen = new Vector(-50, 0); 21 Vector NopeusOikea = new Vector(50, 0); 22 19 Vector NopeusYlos = new Vector(0, 30); 20 Vector NopeusAlas = new Vector(0, -30); 21 Vector NopeusVasen = new Vector(-30, 0); 22 Vector NopeusOikea = new Vector(30, 0); 23 24 Image taustaKuva = LoadImage("Hypnotoad"); 23 25 24 26 public override void Begin() 25 27 { 26 28 29 30 LuoKentta(); 31 Lisaalaskuri(); 27 32 LataaOhjaimet(); 28 LuoKentta();29 33 30 34 // TODO: Kirjoita ohjelmakoodisi tähän … … 38 42 ruudut.SetTileMethod(Color.White, LuoItem); 39 43 ruudut.SetTileMethod(Color.Yellow, LuoTrigger); 44 ruudut.SetTileMethod(Color.Green, LuoMaali); 40 45 ruudut.Execute(ruudunkorkeus, ruudunleveys); 41 46 … … 59 64 60 65 61 Level.Background Color = Color.Green;66 Level.Background.Image = taustaKuva; 62 67 Camera.ZoomToLevel(); 63 68 } … … 70 75 Pelaaja.Position = paikka; 71 76 Pelaaja.Mass = 10; 72 Pelaaja. 77 AddCollisionHandler(Pelaaja, "Sydän", Pistelisa); 78 AddCollisionHandler(Pelaaja, "Miinus", PisteMiinus); 79 AddCollisionHandler(Pelaaja, "Maali", Maali); 80 73 81 74 82 Add(Pelaaja); … … 81 89 Seina.Shape = Shape.Rectangle; 82 90 Seina.Color = Color.MediumVioletRed; 91 83 92 Add(Seina); 93 } 94 void LuoMaali(Vector paikka, double leveys, double korkeus) 95 { 96 PhysicsObject Maali = PhysicsObject.CreateStaticObject(1, 1); 97 Maali.Position = paikka; 98 Maali.Shape = Shape.Rectangle; 99 Maali.Color = Color.Red; 100 Maali.Tag = "Maali"; 101 102 Add(Maali); 84 103 } 85 104 … … 92 111 Item.Restitution = 1.0; 93 112 Item.Image = null; 94 AddCollisionHandler(Item, Pistelisa); 113 114 Item.Tag = "Sydän"; 95 115 Add(Item, 1); 96 116 … … 101 121 PhysicsObject Trigger = new PhysicsObject(1, 1); 102 122 Trigger.Position = paikka; 103 Trigger.Mass = 0.005;123 Trigger.Mass = 5; 104 124 Trigger.Color = Color.Crimson; 105 Trigger.Shape = Shape. Heart;106 Trigger.Restitution = 1.0;125 Trigger.Shape = Shape.Rectangle; 126 Trigger.Restitution = 0; 107 127 Trigger.Image = null; 108 AddCollisionHandler(Trigger, Triggerlaunch);128 Trigger.Tag = "Miinus"; 109 129 110 130 Add(Trigger, 1); 111 131 } 112 132 133 134 135 113 136 void LataaOhjaimet() 114 137 { … … 132 155 { 133 156 if ((Nopeus.Y > 0) && (Pelaaja.Top > Level.Top)) 134 Pelaaja.Velocity = Vector.Zero; 135 return; 136 137 if ((Nopeus.Y > 0) && (Pelaaja.Bottom < Level.Bottom)) 138 Pelaaja.Velocity = Vector.Zero; 139 return; 140 141 if ((Nopeus.X > 0) && (Pelaaja.Left > Level.Left)) 142 Pelaaja.Velocity = Vector.Zero; 143 return; 157 { 158 Pelaaja.Velocity = Vector.Zero; 159 return; 160 } 161 if ((Nopeus.Y < 0) && (Pelaaja.Bottom < Level.Bottom)) 162 { 163 Pelaaja.Velocity = Vector.Zero; 164 return; 165 } 166 167 if ((Nopeus.X < 0) && (Pelaaja.Left < Level.Left)) 168 { 169 Pelaaja.Velocity = Vector.Zero; 170 return; 171 } 144 172 145 173 if ((Nopeus.X > 0) && (Pelaaja.Right > Level.Right)) 146 Pelaaja.Velocity = Vector.Zero; 147 return; 174 { 175 Pelaaja.Velocity = Vector.Zero; 176 return; 177 } 178 Pelaaja.Velocity = Nopeus; 148 179 } 149 180 … … 152 183 { 153 184 154 Ammukset = Luopistelaskuri (Screen.Left + 100.0, Screen.Top - 100.0);185 Paukut = Luopistelaskuri (Screen.Left + 100.0, Screen.Top - 100.0); 155 186 } 156 187 157 188 IntMeter Luopistelaskuri(double x, double y) 158 { 159 IntMeter laskuri = new IntMeter (0);160 laskuri.MaxValue = 10;189 { //Jos laskuri laskee 0:an peli loppuu 190 IntMeter laskuri = new IntMeter (1); 191 laskuri.MaxValue = 20; 161 192 162 193 Label naytto = new Label (); … … 167 198 naytto.BorderColor = Level.BackgroundColor; 168 199 Add(naytto); 200 return laskuri; 169 201 } 170 202 171 203 void Pistelisa(PhysicsObject Pelaaja, PhysicsObject Kohde) 172 204 { 173 if (Pelaaja == Kohde) 174 Ammukset.AddValue += 1; 175 176 177 } 178 205 206 Paukut.AddValue(Paukut+1); 207 Kohde.Destroy(); 208 209 210 211 } 212 void PisteMiinus(PhysicsObject Pelaaja, PhysicsObject Kohde) 213 { 214 215 Paukut.AddValue (+-1); 216 Kohde.Destroy(); 217 218 219 220 } 221 222 void GameOver() 223 { 224 if (Paukut <= 0) 225 { 226 Pelaaja.Destroy(); 227 EndRun(); 228 } 229 } 230 void Maali(PhysicsObject Pelaaja, PhysicsObject Kohde) 231 { 232 //:::// 233 } 234 179 235 } -
2012/27/MarkusK/projekti/Kouura/Kouura/KouuraContent/KouuraContent.contentproj
r3597 r3667 52 52 </Compile> 53 53 </ItemGroup> 54 <ItemGroup> 55 <Compile Include="Hypnotoad.png"> 56 <Name>Hypnotoad</Name> 57 <Importer>TextureImporter</Importer> 58 <Processor>TextureProcessor</Processor> 59 </Compile> 60 </ItemGroup> 54 61 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 55 62 <!-- 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.