Changeset 3801
- Timestamp:
- 2012-07-27 12:14:13 (11 years ago)
- Location:
- 2012/30/EetuM/Urban Assassin/Urban Assassin
- Files:
-
- 10 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/EetuM/Urban Assassin/Urban Assassin/Urban Assassin/Urban_Assassin.cs
r3732 r3801 9 9 public class Urban_Assassin : PhysicsGame 10 10 { 11 const double nopeus = 200;12 const double hyppyNopeus = 1000;11 const double nopeus = 300; 12 const double hyppyNopeus = 500; 13 13 const int RUUDUN_KOKO = 40; 14 14 15 15 PlatformCharacter pelaaja1; 16 Image taustaKuva = LoadImage("untitled2"); 17 int kenttaNro = 1; 16 18 19 DoubleMeter alaspainLaskuri; 20 Timer aikaLaskuri; 17 21 Image pelaajanKuva = LoadImage("norsu"); 18 22 Image tahtiKuva = LoadImage("tahti"); 19 23 Image ase =LoadImage ("m40a3"); 20 24 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 25 Image ammuskuva = LoadImage("untitled"); 22 26 public override void Begin() 23 27 { 28 LuoKentta(); 29 } 30 31 void LuoKentta() 32 { 33 ClearAll(); 34 35 36 ColorTileMap kentta = ColorTileMap.FromLevelAsset("kenttä"); 37 kentta.SetTileMethod(Color.Black, LisaaTaso); 38 // kentta.SetTileMethod('*', LisaaTahti); 39 kentta.SetTileMethod(Color.Red, LisaaPelaaja); 40 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 41 Level.CreateLeftBorder(); 42 Level.CreateTopBorder(); 43 Level.CreateRightBorder(); 44 PhysicsObject alareuna= Level.CreateBottomBorder(); 45 alareuna.IgnoresCollisionResponse = true; 46 AddCollisionHandler(pelaaja1, alareuna, pelaajatörmäsialareunaan); 47 48 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 49 LuoAikaLaskuri(); 50 Level.Background.Image = taustaKuva; 51 52 24 53 Gravity = new Vector(0, -1000); 25 54 26 LuoKentta();55 27 56 LisaaNappaimet(); 28 57 … … 32 61 } 33 62 34 void LuoKentta()35 {36 TileMap kentta = TileMap.FromLevelAsset("kentta1");37 kentta.SetTileMethod('#', LisaaTaso);38 kentta.SetTileMethod('*', LisaaTahti);39 kentta.SetTileMethod('N', LisaaPelaaja);40 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO);41 Level.CreateBorders();42 Level.Background.CreateGradient(Color.White, Color.SkyBlue);43 }44 45 63 void LisaaTaso(Vector paikka, double leveys, double korkeus) 46 64 { 47 65 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 48 66 taso.Position = paikka; 49 taso.Color = Color. Brown;67 taso.Color = Color.Gray; 50 68 Add(taso); 51 69 } … … 69 87 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 70 88 Add(pelaaja1); 89 pelaaja1.Weapon = new AssaultRifle(30, 10); 90 pelaaja1.Weapon.Image = ase; 91 pelaaja1.Weapon.FireRate = 2.0; 92 pelaaja1.Weapon.AmmoIgnoresGravity = false; 93 pelaaja1.Weapon.Power.DefaultValue = 1000; 94 71 95 } 72 96 … … 80 104 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 81 105 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 82 106 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 83 107 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 84 108 … … 106 130 tahti.Destroy(); 107 131 } 132 void AmmuAseella(PlatformCharacter pelaaja) 133 { 134 PhysicsObject ammus = pelaaja.Weapon.Shoot(); 135 136 if (ammus != null) 137 { 138 //ammus.Size *= 3; 139 ammus.Image = ammuskuva; 140 //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 141 } 142 } 143 void LuoAikaLaskuri() 144 { 145 alaspainLaskuri = new DoubleMeter(25); 146 147 aikaLaskuri = new Timer(); 148 aikaLaskuri.Interval = 0.1; 149 aikaLaskuri.Timeout += LaskeAlaspain; 150 aikaLaskuri.Start(); 151 152 Label aikaNaytto = new Label(); 153 aikaNaytto.TextColor = Color.White; 154 aikaNaytto.DecimalPlaces = 1; 155 aikaNaytto.BindTo(alaspainLaskuri); 156 Add(aikaNaytto); 157 } 158 159 void LaskeAlaspain() 160 { 161 alaspainLaskuri.Value -= 0.1; 162 163 if (alaspainLaskuri.Value <= 0) 164 { 165 MessageDisplay.Add("Aika loppui..."); 166 aikaLaskuri.Stop(); 167 168 // täydennä mitä tapahtuu, kun aika loppuu 169 } 170 } 171 void pelaajatörmäsialareunaan(PhysicsObject pelaaja1, PhysicsObject alareuna) 172 { 173 alareuna.Destroy(); 174 Timer.SingleShot(2.0, LuoKentta ); 175 } 176 void TormasiMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 177 { 178 //Kasvatetaan kenttänumeroa yhdellä ja siirrytään seuraavaan kenttään: 179 kenttaNro++; 180 SeuraavaKentta(); 181 } 182 108 183 } -
2012/30/EetuM/Urban Assassin/Urban Assassin/Urban AssassinContent/Urban AssassinContent.contentproj
r3732 r3801 50 50 <Processor>SoundEffectProcessor</Processor> 51 51 </Compile> 52 < Compile Include="norsu.png">53 <Name> norsu</Name>52 <None Include="Jericho"> 53 <Name>Jericho</Name> 54 54 <Importer>TextureImporter</Importer> 55 55 <Processor>TextureProcessor</Processor> 56 </ Compile>56 </None> 57 57 <Compile Include="tahti.png"> 58 58 <Name>tahti</Name> … … 66 66 </Compile> 67 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="norsu.png"> 70 <Name>norsu</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="G36c.png"> 77 <Name>G36c</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="m40a3.png"> 84 <Name>m40a3</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 89 <ItemGroup> 90 <Compile Include="untitled.png"> 91 <Name>untitled</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 96 <ItemGroup> 97 <Compile Include="400px-FN_P90_Triple_Rail_%28TR%29.png"> 98 <Name>400px-FN_P90_Triple_Rail_%28TR%29</Name> 99 <Importer>TextureImporter</Importer> 100 <Processor>TextureProcessor</Processor> 101 </Compile> 102 </ItemGroup> 103 <ItemGroup> 104 <Compile Include="400px-Rpg-7-1-.png"> 105 <Name>400px-Rpg-7-1-</Name> 106 <Importer>TextureImporter</Importer> 107 <Processor>TextureProcessor</Processor> 108 </Compile> 109 </ItemGroup> 110 <ItemGroup> 111 <Compile Include="imagesCAEA00R52.jpg"> 112 <Name>imagesCAEA00R52</Name> 113 <Importer>TextureImporter</Importer> 114 <Processor>TextureProcessor</Processor> 115 </Compile> 116 </ItemGroup> 117 <ItemGroup> 118 <Compile Include="kenttä.png"> 119 <Name>kenttä</Name> 120 <Importer>TextureImporter</Importer> 121 <Processor>TextureProcessor</Processor> 122 </Compile> 123 </ItemGroup> 124 <ItemGroup> 125 <Compile Include="untitled2.png"> 126 <Name>untitled2</Name> 127 <Importer>TextureImporter</Importer> 128 <Processor>TextureProcessor</Processor> 129 </Compile> 130 </ItemGroup> 131 <ItemGroup> 132 <Compile Include="kenttä2.png"> 133 <Name>kenttä2</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 </ItemGroup> 68 138 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 69 139 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/30/EetuM/Urban Assassin/Urban Assassin/Urban AssassinContent/kentta1.txt
r3732 r3801 12 12 ########### 13 13 # ## ########### 14 N # # 14 N # # ############ 15 15 ###################################################################################################################################
Note: See TracChangeset
for help on using the changeset viewer.