- Timestamp:
- 2016-06-14 15:04:32 (7 years ago)
- Location:
- 2016/24/JesseH/Cubes
- Files:
-
- 12 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/24/JesseH/Cubes/Cubes/Cubes/Cubes.cs
r7259 r7310 10 10 { 11 11 const double nopeus = 200; 12 const double hyppyNopeus = 400;12 const double hyppyNopeus = 700; 13 13 const int RUUDUN_KOKO = 40; 14 14 15 PlatformCharacter Fred; 15 List<Hahmo> pelaajat=new List<Hahmo>(); 16 int aktiivinenPelaaja = 0; 17 Image fredKuva = LoadImage("Fred"); 18 Image lulaKuva = LoadImage("Lula"); 19 Image brandonKuva = LoadImage("Brandon"); 20 Image oviKuva = LoadImage("Ovi"); 21 Image VasenKuva = LoadImage("Vasen"); 22 Image OikeaKuva = LoadImage("Oikea"); 23 IntMeter pelaajiaMaalissa; 16 24 17 Image pelaajanKuva = LoadImage("Fred"); 18 //Image tahtiKuva = LoadImage("tahti"); 19 20 //SoundEffect maaliAani = LoadSoundEffect("maali"); 25 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 26 22 27 public override void Begin() … … 26 31 LuoKentta(); 27 32 LisaaNappaimet(); 28 29 Camera.Follow( Fred);33 LuoPistelaskuri(); 34 Camera.Follow(pelaajat[aktiivinenPelaaja]); 30 35 Camera.ZoomFactor = 1.2; 31 36 Camera.StayInLevel = true; … … 36 41 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 37 42 kentta.SetTileMethod('#', LisaaTaso); 38 kentta.SetTileMethod('*', LisaaTahti); 39 kentta.SetTileMethod('N', LisaaPelaaja); 43 kentta.SetTileMethod('D', LisaaVasen); 44 kentta.SetTileMethod('P', LisaaOikea); 45 kentta.SetTileMethod('*', LisaaOvi); 46 kentta.SetTileMethod('N', LisaaPelaaja, fredKuva, 0.5,hyppyNopeus* 0.5, "fred"); 47 kentta.SetTileMethod('K', LisaaPelaaja, lulaKuva, 1.0,hyppyNopeus* 1.0, "lula"); 48 kentta.SetTileMethod('L', LisaaPelaaja, brandonKuva, 1.5,hyppyNopeus* 1.5, "brandon"); 40 49 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 41 50 Level.CreateBorders(); 42 Level.Background.CreateGradient(Color. White, Color.LightGray);51 Level.Background.CreateGradient(Color.LightGray, Color.Gray); 43 52 } 44 53 … … 50 59 Add(taso); 51 60 } 52 53 void LisaaTahti(Vector paikka, double leveys, double korkeus) 61 void LisaaVasen(Vector paikka, double leveys, double korkeus) 54 62 { 55 PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 56 tahti.IgnoresCollisionResponse = true; 57 tahti.Position = paikka; 58 // tahti.Image = tahtiKuva; 59 tahti.Tag = "tahti"; 60 Add(tahti); 63 PhysicsObject Vasen = PhysicsObject.CreateStaticObject(leveys, korkeus); 64 Vasen.Position = paikka; 65 Vasen.Color = Color.Black; 66 Add(Vasen); 67 } 68 void LisaaOikea(Vector paikka, double leveys, double korkeus) 69 { 70 PhysicsObject Oikea = PhysicsObject.CreateStaticObject(leveys, korkeus); 71 Oikea.Position = paikka; 72 Oikea.Color = Color.Black; 73 Add(Oikea); 74 } 75 void LisaaOvi(Vector paikka, double leveys, double korkeus) 76 { 77 PhysicsObject ovi = PhysicsObject.CreateStaticObject(leveys, korkeus); 78 ovi.IgnoresCollisionResponse = true; 79 ovi.Position = paikka; 80 ovi.Image = oviKuva; 81 ovi.Tag = "Ovi"; 82 Add(ovi); 61 83 } 62 84 63 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 85 86 void LisaaPelaaja(Vector paikka, double leveys, double korkeus, Image kuva, double kerroin,double hyppyNopeus, string nimi) 64 87 { 65 Fred = new PlatformCharacter(leveys*0.5, korkeus*0.5); 66 Fred.Position = paikka; 67 Fred.Mass = 1.0; 68 Fred.Image = pelaajanKuva; 69 //AddCollisionHandler(Fred, "tahti", TormaaTahteen); 70 Add(Fred); 88 Hahmo pelaaja = new Hahmo (leveys * kerroin, korkeus * kerroin); 89 pelaaja.Position = paikka; 90 pelaaja.Mass = 1.0; 91 pelaaja.Image = kuva; 92 pelaaja.Tag = nimi; 93 AddCollisionHandler(pelaaja, "Ovi", TormaaTahteen); 94 Add(pelaaja); 95 pelaajat.Add(pelaaja); 96 pelaaja.Hyppynopeus = hyppyNopeus; 97 } 98 99 100 void LuoPistelaskuri() 101 { 102 pelaajiaMaalissa = new IntMeter(0); 103 104 Label pelaajaNaytto = new Label(); 105 pelaajaNaytto.X = Screen.Left + 100; 106 pelaajaNaytto.Y = Screen.Top - 100; 107 pelaajaNaytto.TextColor = Color.Black; 108 pelaajaNaytto.Color = Color.White; 109 110 pelaajaNaytto.BindTo(pelaajiaMaalissa); 111 Add(pelaajaNaytto); 71 112 } 72 113 73 114 void LisaaNappaimet() 74 115 { 116 Keyboard.Listen(Key.LeftAlt, ButtonState.Pressed, VaihdaPelaajaa, "vaihda pelaaja"); 75 117 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 76 118 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 77 119 78 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", Fred, -nopeus); 79 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", Fred, nopeus); 80 Keyboard.Listen(Key.Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", Fred, hyppyNopeus); 120 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", -nopeus); 121 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", nopeus); 122 Keyboard.Listen(Key.Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää"); 123 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää" ); 124 81 125 82 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä");126 83 127 84 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", Fred, -nopeus); 85 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", Fred, nopeus); 86 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", Fred, hyppyNopeus); 87 88 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 128 129 } 130 void VaihdaPelaajaa() 131 { 132 aktiivinenPelaaja++; 133 if (aktiivinenPelaaja>pelaajat.Count-1) 134 { 135 aktiivinenPelaaja = 0; 136 } 137 Camera.Follow(pelaajat[aktiivinenPelaaja]); 138 } 139 void Liikuta( double nopeus) 140 { 141 pelaajat[aktiivinenPelaaja].Walk(nopeus); 89 142 } 90 143 91 void Liikuta(PlatformCharacter hahmo, double nopeus)144 void Hyppaa() 92 145 { 93 hahmo.Walk(nopeus); 94 } 95 96 void Hyppaa(PlatformCharacter hahmo, double nopeus) 97 { 98 hahmo.Jump(nopeus); 146 pelaajat[aktiivinenPelaaja].Jump(pelaajat[aktiivinenPelaaja].Hyppynopeus); 99 147 } 100 148 101 149 void TormaaTahteen(PhysicsObject hahmo, PhysicsObject tahti) 102 150 { 103 //maaliAani.Play(); 104 MessageDisplay.Add("Voitit Pelin"); 105 tahti.Destroy(); 151 152 hahmo.Destroy(); 153 pelaajiaMaalissa.Value++; 154 155 if (pelaajiaMaalissa.Value >= 3) 156 { 157 MessageDisplay.Add("You Win!"); 158 tahti.Destroy(); 159 } 106 160 } 107 161 } -
2016/24/JesseH/Cubes/Cubes/Cubes/Cubes.csproj
r7259 r7310 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="Hahmo.cs" /> 113 114 <Compile Include="Ohjelma.cs" /> 114 115 <Compile Include="Cubes.cs" /> -
2016/24/JesseH/Cubes/Cubes/Cubes/Cubes.csproj.Debug.cachefile
r7259 r7310 2 2 Content\kentta1.xnb 3 3 Content\Fred.xnb 4 Content\Lula.xnb 5 Content\Brandon.xnb 6 Content\Ovi.xnb 7 Content\Vasen.xnb 8 Content\Oikea.xnb -
2016/24/JesseH/Cubes/Cubes/Cubes/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml
r7259 r7310 18 18 <Options>None</Options> 19 19 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\kentta1.xnb</Output> 20 <Time>2016-06-1 3T14:40:29.6680884+03:00</Time>20 <Time>2016-06-14T14:44:29.6831861+03:00</Time> 21 21 </Item> 22 22 <Item> … … 28 28 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Fred.xnb</Output> 29 29 <Time>2016-06-13T14:49:17.1531058+03:00</Time> 30 </Item> 31 <Item> 32 <Source>Lula.png</Source> 33 <Name>Lula</Name> 34 <Importer>TextureImporter</Importer> 35 <Processor>TextureProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Lula.xnb</Output> 38 <Time>2016-06-14T10:01:28.5741278+03:00</Time> 39 </Item> 40 <Item> 41 <Source>Brandon.png</Source> 42 <Name>Brandon</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Brandon.xnb</Output> 47 <Time>2016-06-14T10:02:20.2437278+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Ovi.png</Source> 51 <Name>Ovi</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Ovi.xnb</Output> 56 <Time>2016-06-14T14:07:08.6737283+03:00</Time> 57 </Item> 58 <Item> 59 <Source>Vasen.png</Source> 60 <Name>Vasen</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Vasen.xnb</Output> 65 <Time>2016-06-14T14:39:58.085175+03:00</Time> 66 </Item> 67 <Item> 68 <Source>Oikea.png</Source> 69 <Name>Oikea</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 <Options>None</Options> 73 <Output>C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Oikea.xnb</Output> 74 <Time>2016-06-14T14:42:59.03721+03:00</Time> 30 75 </Item> 31 76 <BuildSuccessful>true</BuildSuccessful> -
2016/24/JesseH/Cubes/Cubes/Cubes/obj/x86/Debug/Cubes.csproj.FileListAbsolute.txt
r7259 r7310 10 10 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\obj\x86\Debug\Cubes.pdb 11 11 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Fred.xnb 12 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Lula.xnb 13 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Brandon.xnb 14 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Ovi.xnb 15 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Vasen.xnb 16 C:\MyTemp\JesseH\Cubes\Cubes\Cubes\bin\x86\Debug\Content\Oikea.xnb -
2016/24/JesseH/Cubes/Cubes/Cubes/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt
r7259 r7310 2 2 Content\kentta1.xnb 3 3 Content\Fred.xnb 4 Content\Lula.xnb 5 Content\Brandon.xnb 6 Content\Ovi.xnb 7 Content\Vasen.xnb 8 Content\Oikea.xnb -
2016/24/JesseH/Cubes/Cubes/CubesContent/CubesContent.contentproj
r7259 r7310 64 64 </Compile> 65 65 </ItemGroup> 66 <ItemGroup> 67 <None Include="Tahti"> 68 <Name>Tahti</Name> 69 <Importer>TextureImporter</Importer> 70 <Processor>TextureProcessor</Processor> 71 </None> 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="Lula.png"> 75 <Name>Lula</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="Brandon.png"> 82 <Name>Brandon</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="Ovi.png"> 89 <Name>Ovi</Name> 90 <Importer>TextureImporter</Importer> 91 <Processor>TextureProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="Vasen.png"> 96 <Name>Vasen</Name> 97 <Importer>TextureImporter</Importer> 98 <Processor>TextureProcessor</Processor> 99 </Compile> 100 </ItemGroup> 101 <ItemGroup> 102 <Compile Include="Oikea.png"> 103 <Name>Oikea</Name> 104 <Importer>TextureImporter</Importer> 105 <Processor>TextureProcessor</Processor> 106 </Compile> 107 </ItemGroup> 66 108 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 67 109 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2016/24/JesseH/Cubes/Cubes/CubesContent/kentta1.txt
r7259 r7310 1 # # # # # #2 # # # ## #3 # # # # #4 # # # # #5 # ##### # ## #6 # # # ######## # #######7 # ## # ### # #######8 ## # #### # # # #######9 ## N # ##### # #####*#10 ###################################################### 1 # # # # # # 2 # # # # # 3 # # # # # 4 # # # # # 5 # ##### # # #####DP# # 6 # # # ####### # ##### # 7 # ## # ### # ##### # 8 ## # #### # # # ##### # 9 ## NK L # ##### # #####Q##### *# 10 #########################################################
Note: See TracChangeset
for help on using the changeset viewer.