- Timestamp:
- 2013-07-24 15:04:54 (10 years ago)
- Location:
- 2013/30/ArtturiN
- Files:
-
- 15 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/30/ArtturiN/Omapeli/Omapeli/Omapeli/Omapeli.cs
r4588 r4638 7 7 using Jypeli.Widgets; 8 8 9 10 public class Sinko : Weapon 11 { 12 public Sinko( double width, double height ) 13 : base( width, height ) 14 { 15 Power.DefaultValue = Power.Value = 15000; 16 TimeBetweenUse = TimeSpan.FromSeconds( 4 ); 17 18 Image = Game.LoadImage( "RPG7" ); 19 AttackSound = Game.LoadSoundEffectFromResources( "CannonFire" ); 20 } 21 22 protected override PhysicsObject CreateProjectile() 23 { 24 return new CannonBall( 5 ); 25 } 26 } 27 9 28 public class Omapeli : PhysicsGame 10 29 { 11 30 12 31 PhysicsObject minaMies; 32 33 PhysicsObject sinaMies; 34 35 Image KuvaT = LoadImage("kuva"); 13 36 14 Image KuvaT = LoadImage("Kuva");15 Image RPG7 = LoadImage("RPG7");16 37 Image tulenKuva = LoadImage("Tuli"); 17 38 18 Animation minaJuoksee = new Animation(LoadImages("MinaMies2", "MinaMies")); 19 39 Animation minaJuoksee = new Animation(LoadImages("MinaMies", "MinaMies3")); 40 41 Animation sinaJuoksee = new Animation(LoadImages("SinäMies2", "SinäMies3")); 42 43 bool painovoima = false; 20 44 21 45 public override void Begin() 22 46 { 23 24 47 Mouse.IsCursorVisible = true; 48 Alkuvalikko(); 49 MediaPlayer.Play("Maclemore"); 50 } 51 52 void Aloitapeli() 53 { 54 25 55 //LuoKentta(); 56 57 if (painovoima) 58 { 59 Gravity = new Vector(0, -200); 60 } 26 61 27 62 minaMies = new PhysicsObject(250, 250); … … 29 64 minaMies.Animation = minaJuoksee; 30 65 minaMies.Animation.FPS = 5; 66 if (painovoima) minaMies.CanRotate = false; 31 67 Add(minaMies); 68 69 Sinko minaSinko = new Sinko( 250, 40); 70 minaMies.Add(minaSinko); 71 72 sinaMies = new PhysicsObject(250, 250); 73 sinaMies.Position = new Vector(0, -400); 74 sinaMies.Animation = sinaJuoksee; 75 sinaMies.Animation.FPS = 5; 76 if (painovoima) sinaMies.CanRotate = false; 77 Add(sinaMies); 78 79 Sinko sinaSinko = new Sinko(250, 40); 80 sinaMies.Add(sinaSinko); 32 81 33 82 taustakuva(); … … 36 85 Level.BackgroundColor = Color.Black; 37 86 Level.CreateBorders(1.0, true, Color.Red); 38 87 39 88 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 40 89 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, Ammu, "ampuu"); 41 90 42 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikuttaa", minaMies, new Vector(-200, 0));91 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikuttaa", minaMies, minaSinko, new Vector(-200, 0)); 43 92 Keyboard.Listen(Key.Left, ButtonState.Released, Pysahdy, "Liikuttaa", minaMies); 44 93 45 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikuttaa", minaMies, new Vector(200, 0));94 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikuttaa", minaMies, minaSinko, new Vector(200, 0)); 46 95 Keyboard.Listen(Key.Right, ButtonState.Released, Pysahdy, "Liikuttaa", minaMies); 96 97 98 99 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikuttaa", sinaMies, sinaSinko, new Vector(-200, 0)); 100 Keyboard.Listen(Key.A, ButtonState.Released, Pysahdy, "Liikuttaa", sinaMies); 101 102 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikuttaa", sinaMies, sinaSinko, new Vector(200, 0)); 103 Keyboard.Listen(Key.D, ButtonState.Released, Pysahdy, "Liikuttaa", sinaMies); 104 } 105 106 void Alkuvalikko() 107 { 108 MultiSelectWindow alkuValikko = new MultiSelectWindow("Funny RPG 7", "Aloita peli", "Asetukset", "Lopeta peli"); 109 Add(alkuValikko); 110 111 alkuValikko.AddItemHandler(0, Aloitapeli); 112 alkuValikko.AddItemHandler(1, Asetukset); 113 alkuValikko.AddItemHandler(2, Exit); 114 } 115 116 void Asetukset() 117 { 118 MultiSelectWindow asetusValikko = new MultiSelectWindow("Asetukset", "Painovoima päälle", "Painovoima pois", "Takaisin"); 119 Add(asetusValikko); 120 121 asetusValikko.AddItemHandler(0, delegate { painovoima = true; }); 122 asetusValikko.AddItemHandler(1, delegate { painovoima = false; }); 123 asetusValikko.Closed += delegate { Alkuvalikko(); }; 47 124 } 48 125 … … 54 131 55 132 56 void Liikuta(PhysicsObject mies, Vector suunta) 57 { 133 void Liikuta(PhysicsObject mies, Sinko ase, Vector suunta) 134 { 135 ase.Angle = suunta.Angle; 58 136 mies.Push(suunta); 59 137 mies.Animation.Resume(); … … 86 164 void LuoSampo(Vector paikka, double leveys, double korkeus) 87 165 { 88 PhysicsObject sampo = new PhysicsObject(leveys *8, korkeus*8);166 PhysicsObject sampo = new PhysicsObject(leveys * 8, korkeus * 8); 89 167 sampo.Position = paikka; 90 168 sampo.Image = LoadImage("Sampo"); … … 100 178 101 179 Level.Background.Image = KuvaT; 180 181 102 182 Level.Background.FitToLevel(); 103 104 } 105 106 183 184 } 185 186 107 187 void taustakuva1() 108 188 { 109 110 189 190 111 191 112 192 // TODO: Kirjoita ohjelmakoodisi tähän 113 193 114 115 116 } 194 195 196 } 197 198 199 200 201 202 117 203 } -
2013/30/ArtturiN/Omapeli/Omapeli/OmapeliContent/OmapeliContent.contentproj
r4588 r4638 53 53 </ItemGroup> 54 54 <ItemGroup> 55 <Compile Include="RPG7.jpg">56 <Name>RPG7</Name>57 <Importer>TextureImporter</Importer>58 <Processor>TextureProcessor</Processor>59 </Compile>60 </ItemGroup>61 <ItemGroup>62 55 <Compile Include="Sampo.png"> 63 56 <Name>Sampo</Name> … … 92 85 </Compile> 93 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="MinaMies3.png"> 89 <Name>MinaMies3</Name> 90 <Importer>TextureImporter</Importer> 91 <Processor>TextureProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="Sinämies2.png"> 96 <Name>Sinämies2</Name> 97 <Importer>TextureImporter</Importer> 98 <Processor>TextureProcessor</Processor> 99 </Compile> 100 </ItemGroup> 101 <ItemGroup> 102 <Compile Include="Sinämies3.png"> 103 <Name>Sinämies3</Name> 104 <Importer>TextureImporter</Importer> 105 <Processor>TextureProcessor</Processor> 106 </Compile> 107 </ItemGroup> 108 <ItemGroup> 109 <Compile Include="Arkku.png"> 110 <Name>Arkku</Name> 111 <Importer>TextureImporter</Importer> 112 <Processor>TextureProcessor</Processor> 113 </Compile> 114 </ItemGroup> 115 <ItemGroup> 116 <Compile Include="ES..jpg"> 117 <Name>ES.</Name> 118 <Importer>TextureImporter</Importer> 119 <Processor>TextureProcessor</Processor> 120 </Compile> 121 </ItemGroup> 122 <ItemGroup> 123 <Compile Include="tausta.jpg"> 124 <Name>tausta</Name> 125 <Importer>TextureImporter</Importer> 126 <Processor>TextureProcessor</Processor> 127 </Compile> 128 </ItemGroup> 129 <ItemGroup> 130 <Compile Include="RPG7.png"> 131 <Name>RPG7</Name> 132 <Importer>TextureImporter</Importer> 133 <Processor>TextureProcessor</Processor> 134 </Compile> 135 </ItemGroup> 136 <ItemGroup> 137 <Compile Include="Maclemore.mp3"> 138 <Name>Maclemore</Name> 139 <Importer>Mp3Importer</Importer> 140 <Processor>SongProcessor</Processor> 141 </Compile> 142 </ItemGroup> 94 143 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 95 144 <!-- 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.