Changeset 1625
- Timestamp:
- 2010-08-05 14:57:13 (13 years ago)
- Location:
- 2010/31/arsajukk/fat-man adventures
- Files:
-
- 15 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/31/arsajukk/fat-man adventures/fat-man adventures/Content/Content.contentproj
r1607 r1625 47 47 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 48 48 </ItemGroup> 49 <ItemGroup> 50 <Compile Include="Fat-man.png"> 51 <Name>Fat-man</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 </Compile> 55 </ItemGroup> 56 <ItemGroup> 57 <Compile Include="tiiliseina.png"> 58 <Name>tiiliseina</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="ruoho.png"> 65 <Name>ruoho</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="pilvi.png"> 72 <Name>pilvi</Name> 73 <Importer>TextureImporter</Importer> 74 <Processor>TextureProcessor</Processor> 75 </Compile> 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="multaa.png"> 79 <Name>multaa</Name> 80 <Importer>TextureImporter</Importer> 81 <Processor>TextureProcessor</Processor> 82 </Compile> 83 </ItemGroup> 84 <ItemGroup> 85 <Compile Include="background.png"> 86 <Name>background</Name> 87 <Importer>TextureImporter</Importer> 88 <Processor>TextureProcessor</Processor> 89 </Compile> 90 </ItemGroup> 91 <ItemGroup> 92 <Compile Include="Fat-man 2.png"> 93 <Name>Fat-man 2</Name> 94 <Importer>TextureImporter</Importer> 95 <Processor>TextureProcessor</Processor> 96 </Compile> 97 </ItemGroup> 98 <ItemGroup> 99 <Compile Include="apple.png"> 100 <Name>apple</Name> 101 <Importer>TextureImporter</Importer> 102 <Processor>TextureProcessor</Processor> 103 </Compile> 104 </ItemGroup> 105 <ItemGroup> 106 <Compile Include="Hamburger.png"> 107 <Name>Hamburger</Name> 108 <Importer>TextureImporter</Importer> 109 <Processor>TextureProcessor</Processor> 110 </Compile> 111 </ItemGroup> 49 112 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 50 113 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/31/arsajukk/fat-man adventures/fat-man adventures/Kentta1.txt
r1607 r1625 1 1 2 3 4 5 6 7 ,,,,,,,,, 8 1 ========= 9 ,,,,,,,,,,,========= 10 ==================== 11 ==================== 12 ==================== 2 * 3 . 4 5 . 6 7 2 8 ,,,,,,,,, ,,,, ,,,,,,,,,, . 9 1 ========= ---- 2 ========== ,, . . ,,,,, 10 ,,,,,,,,,,,========= ---- ,,,,,, == , ,,, . . ,,,, ===== 11 ==================== ---- ====== * == =,,,=== ---- ,,,,,===== ,,, : 12 ==================== ---- ======____________== ======= ---- ==========,,,,,,,,===,,,,,,,, 13 ==================== ---- ==================== ======= ---- ============================= -
2010/31/arsajukk/fat-man adventures/fat-man adventures/Peli.cs
r1607 r1625 3 3 using Jypeli.Widgets; 4 4 using Jypeli.Assets; 5 using System.Collections.Generic; 5 6 6 7 class Tasohyppely : PhysicsGame … … 11 12 const int ruudunKorkeus = 50; 12 13 PlatformCharacter pelaaja1; 14 PhysicsObject vasenReuna; 15 PhysicsObject oikeaReuna; 16 PhysicsObject alaReuna; 17 Image taustaKuva = LoadImage("background"); 18 Image pelaajanKuva = LoadImage("Fat-man"); 19 Image pelaajanKuva2 = LoadImage("Fat-man 2"); 20 Image vihollinenKuva = LoadImage("Hamburger"); 21 22 List<PhysicsObject> viholliset; 13 23 14 24 protected override void Begin() … … 16 26 LuoKentta(); 17 27 lisaaNappaimet(); 18 28 19 29 Camera.Follow(pelaaja1); 20 30 Camera.ZoomFactor = -100.0; 21 31 Camera.StayInLevel = true; 32 33 34 35 22 36 } 23 37 24 38 void LuoKentta() 25 39 { 40 viholliset = new List<PhysicsObject>(); 26 41 TileMap ruudut = TileMap.FromFile("Kentta1.txt"); 27 42 ruudut['='] = LuoPalikka; 28 43 ruudut['*'] = LuoTahti; 29 44 ruudut['1'] = lisaaPelaajat; 45 ruudut['-'] = LuoPalikka3; 46 ruudut['_'] = LuoPalikka4; 30 47 ruudut[','] = LuoPalikka2; 48 ruudut['.'] = LuoPalikka5; 49 ruudut[':'] = LuoOmena; 50 ruudut['2'] = lisaaVihollinen; 31 51 ruudut.Insert(ruudunLeveys, ruudunKorkeus); 32 52 Gravity = new Vector(0.0, -850.0); 33 34 35 } 53 PhysicsObject vasenReuna = Level.CreateLeftBorder(); 54 vasenReuna.Restitution = 1.0; 55 vasenReuna.IsVisible = false; 56 PhysicsObject oikeaReuna = Level.CreateRightBorder(); 57 vasenReuna.Restitution = 1.0; 58 vasenReuna.IsVisible = false; 59 alaReuna = Level.CreateBottomBorder(); 60 Level.Background.Image = taustaKuva; 61 Level.Background.Height = Level.Height; 62 Level.Background.Width = Level.Width; 63 64 TeeVihollisilleAivot(); 65 66 67 68 } 69 70 void TeeVihollisilleAivot() 71 { 72 foreach (PhysicsObject vihu in viholliset) 73 { 74 List<Vector> polku = new List<Vector>(); 75 polku.Add(new Vector(vihu.X-100,vihu.Y)); 76 polku.Add(new Vector(vihu.X+100,vihu.Y)); 77 PathFollowerBrain polkuAivot = new PathFollowerBrain(); 78 polkuAivot.Path = polku; 79 polkuAivot.Speed = 200; 80 vihu.Brain = polkuAivot; 81 } 82 } 83 36 84 GameObject lisaaPelaajat() 37 85 { 38 pelaaja1 = new PlatformCharacter(40, 40); 39 pelaaja1.Mass = 4.0; 40 pelaaja1.Image = LoadImage("norsu"); 41 return(pelaaja1); 42 } 86 pelaaja1 = new PlatformCharacter(40, 70); 87 pelaaja1.Mass = 4.5; 88 pelaaja1.Image = pelaajanKuva; 89 AddCollisionHandler(pelaaja1, PelaajaTormasi); 90 LaserGun laserPyssy = new LaserGun(45, 10); 91 pelaaja1.Weapon = laserPyssy; 92 pelaaja1.RightIdleAnimation = new Animation(pelaajanKuva); 93 pelaaja1.LeftIdleAnimation = new Animation(pelaajanKuva2); 94 pelaaja1.RightWalkingAnimation = new Animation(pelaajanKuva); 95 pelaaja1.LeftWalkingAnimation = new Animation(pelaajanKuva2); 96 return (pelaaja1); 97 98 99 } 100 101 102 103 43 104 void lisaaNappaimet() 44 105 { 45 106 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 46 107 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 108 109 Keyboard.Listen(Key.Space, ButtonState.Down, pelaaja1.Weapon.Use, "Ammu"); 47 110 48 111 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 55 118 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 56 119 ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyVoima); 57 } 58 120 } 121 59 122 PhysicsObject LuoPalikka() 60 123 { 61 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 85.0);124 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 95.0); 62 125 palikka.Color = Color.Red; 126 palikka.Image = LoadImage("tiiliseina"); 63 127 return palikka; 64 128 } … … 67 131 { 68 132 PhysicsObject tahti = PhysicsObject.CreateStaticObject(25.0, 25.0); 133 tahti.Image = LoadImage("tahti"); 69 134 return tahti; 70 135 } 71 136 PhysicsObject LuoPalikka2() 72 137 { 73 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 15.0); 74 palikka.Color = Color.LightGreen; 75 return palikka; 76 } 77 138 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 5.0); 139 palikka.Image = LoadImage("ruoho"); 140 palikka.Restitution = 0.0; 141 return palikka; 142 } 143 144 PhysicsObject LuoPalikka3() 145 { 146 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 95.0); 147 palikka.Image = LoadImage("tiiliseina"); 148 return palikka; 149 } 150 151 PhysicsObject LuoPalikka4() 152 { 153 PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 5.0); 154 palikka.Color = Color.Brown; 155 palikka.Image = LoadImage("multaa"); 156 return palikka; 157 } 158 159 PhysicsObject LuoPalikka5() 160 { 161 PhysicsObject palikka = PhysicsObject.CreateStaticObject(100.0, 50.0); 162 palikka.Color = Color.White; 163 palikka.Image = LoadImage("pilvi"); 164 return palikka; 165 } 166 PhysicsObject LuoOmena() 167 { 168 PhysicsObject omena = PhysicsObject.CreateStaticObject(35.0, 35.0); 169 omena.Image = LoadImage("apple"); 170 return omena; 171 } 172 173 PhysicsObject lisaaVihollinen() 174 { 175 PhysicsObject vihollinen = new PhysicsObject(50, 30); 176 vihollinen.Image = vihollinenKuva; 177 vihollinen.Restitution = 0.0; 178 viholliset.Add(vihollinen); 179 return (vihollinen); 180 } 181 78 182 void liikuta(PlatformCharacter hahmo, double nopeus) 79 183 { … … 81 185 } 82 186 83 void hyppaa(PlatformCharacter hahmo, double voima) 84 { 85 hahmo.Jump(voima); 86 } 187 void hyppaa(PlatformCharacter hahmo, double voima) 188 { 189 hahmo.Jump(voima); 190 } 191 192 void PelaajaTormasi(PhysicsObject pelaaja1, PhysicsObject kohde) 193 { 194 if ((kohde == alaReuna)) 195 { 196 AloitaAlusta(); 197 } 198 } 199 200 void AloitaAlusta() 201 { 202 ClearAll(); 203 Begin(); 204 } 205 206 void AmmuAseella() 207 { 208 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 209 210 if (ammus != null) 211 { 212 ammus.Size *= 3; 213 } 214 } 87 215 88 216
Note: See TracChangeset
for help on using the changeset viewer.