- Timestamp:
- 2015-06-29 14:16:14 (8 years ago)
- Location:
- 2015/27/JimiS/Pong
- Files:
-
- 6 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/JimiS/Pong/Pong/Pong/Pong.cs
r6508 r6511 9 9 public class Pong : PhysicsGame 10 10 { 11 //vektorit 11 12 Vector nopeusYlos = new Vector(0, 200); 12 13 Vector nopeusAlas = new Vector(0, -200); 14 //reunat 15 PhysicsObject vasenReuna; 16 PhysicsObject oikeaReuna; 17 //pallo 13 18 PhysicsObject pallo; 19 //mailat 14 20 PhysicsObject maila1; 15 21 PhysicsObject maila2; 22 //pisteet 16 23 IntMeter pelaajan1Pisteet; 17 24 IntMeter pelaajan2Pisteet; 25 Image pallokuva = LoadImage("jalkapallo"); 26 Image pallokenttä = LoadImage("jalkapallokenttä"); 18 27 19 28 public override void Begin() … … 23 32 LisaaLaskurit(); 24 33 AloitaPeli(); 34 ohjeteksti(); 25 35 } 26 36 void LuoKenttä() … … 31 41 pallo.X = -200.0; 32 42 pallo.Y = 0.0; 33 Level.CreateBorders(1.0, false); 43 pallo.Image = pallokuva; 44 //Kentän reunat, vasen 45 vasenReuna = Level.CreateLeftBorder(); 46 vasenReuna.Restitution = 1.0; 47 vasenReuna.IsVisible = false; 48 // oikea 49 oikeaReuna = Level.CreateRightBorder(); 50 oikeaReuna.Restitution = 1.0; 51 oikeaReuna.IsVisible = false; 52 //ala 53 PhysicsObject alaReuna = Level.CreateBottomBorder(); 54 alaReuna.Restitution = 1.0; 55 alaReuna.IsVisible = false; 56 //ylä 57 PhysicsObject yläReuna = Level.CreateTopBorder(); 58 yläReuna.Restitution = 1.0; 59 yläReuna.IsVisible = false; 60 //reunat loppuu 34 61 pallo.Restitution = 1.0; 35 Level.Background.Color = Color. Black;62 Level.Background.Color = Color.Green; 36 63 pallo.Color = Color.Green; 37 64 Camera.ZoomToLevel(); 38 65 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 39 66 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 40 67 AddCollisionHandler(pallo, KasittelePallonTormays); 68 } 69 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 70 { 71 if (kohde == oikeaReuna) 72 { 73 pelaajan1Pisteet.Value += 1; 74 } 75 else if (kohde == vasenReuna) 76 { 77 pelaajan2Pisteet.Value += 1; 78 } 41 79 } 42 80 void LisaaLaskurit() 43 81 { 44 82 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 83 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 45 84 } 46 85 void AloitaPeli() … … 57 96 maila.Restitution = 1.0; 58 97 Add(maila); 98 maila.Color = Color.Blue; 59 99 return maila; 60 100 } 61 101 void AsetaOhjaimet() 62 102 { 63 Keyboard.Listen(Key. A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta maila ylös", maila1, nopeusYlos);64 Keyboard.Listen(Key. A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero);65 Keyboard.Listen(Key. Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas);66 Keyboard.Listen(Key. Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero);103 Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta maila ylös", maila1, nopeusYlos); 104 Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 105 Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 106 Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 67 107 68 108 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); … … 102 142 return laskuri; 103 143 } 144 void ohjeteksti() 145 { 146 Label ohje = new Label("ohje painamalla F1"); 147 ohje.X = Level.Left + 100.0; 148 ohje.Y = Level.Top - 100.0; 149 ohje.TextColor = Color.Red; 150 ohje.BorderColor = Level.Background.Color; 151 ohje.Color = Level.Background.Color; 152 ohje.TextScale *= 2; 153 Add(ohje); 154 } 155 104 156 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 105 157 { -
2015/27/JimiS/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{43441B02-A17B-4AA5-9B96-F0812FDBF432}.xml
r6505 r6511 2 2 <XnaContent xmlns:Pipeline="Microsoft.Xna.Framework.Content.Pipeline"> 3 3 <Asset Type="Pipeline:BuildItemCollection"> 4 <Item> 5 <Source>jalkapallo.png</Source> 6 <Name>jalkapallo</Name> 7 <Importer>TextureImporter</Importer> 8 <Processor>TextureProcessor</Processor> 9 <Options>None</Options> 10 <Output>C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallo.xnb</Output> 11 <Time>2015-06-29T13:39:58.6999532+03:00</Time> 12 </Item> 13 <Item> 14 <Source>jalkapallokenttä.png</Source> 15 <Name>jalkapallokenttä</Name> 16 <Importer>TextureImporter</Importer> 17 <Processor>TextureProcessor</Processor> 18 <Options>None</Options> 19 <Output>C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallokenttä.xnb</Output> 20 <Time>2015-06-29T13:42:56.6095532+03:00</Time> 21 </Item> 4 22 <BuildSuccessful>true</BuildSuccessful> 5 23 <Settings> … … 16 34 <Assemblies> 17 35 <Assembly> 36 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 37 <Value>2014-11-26T00:23:34+02:00</Value> 38 </Assembly> 39 <Assembly> 40 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key> 41 <Value>2011-09-01T16:22:30+03:00</Value> 42 </Assembly> 43 <Assembly> 44 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</Key> 45 <Value>2011-09-01T16:22:30+03:00</Value> 46 </Assembly> 47 <Assembly> 48 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</Key> 49 <Value>2011-09-01T16:22:30+03:00</Value> 50 </Assembly> 51 <Assembly> 52 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</Key> 53 <Value>2011-09-01T16:22:30+03:00</Value> 54 </Assembly> 55 <Assembly> 56 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</Key> 57 <Value>2011-09-01T16:22:30+03:00</Value> 58 </Assembly> 59 <Assembly> 60 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</Key> 61 <Value>2011-09-01T16:22:30+03:00</Value> 62 </Assembly> 63 <Assembly> 64 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\AnimationExtension.dll</Key> 65 <Value>2014-11-26T00:23:36+02:00</Value> 66 </Assembly> 67 <Assembly> 18 68 <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 19 69 <Value>2014-04-23T00:22:29.3372049+03:00</Value> -
2015/27/JimiS/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt
r6505 r6511 7 7 C:\MyTemp\JimiS\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 8 8 C:\MyTemp\JimiS\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 9 C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallo.xnb 10 C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallokenttÀ.xnb -
2015/27/JimiS/Pong/Pong/PongContent/PongContent.contentproj
r6505 r6511 45 45 <Reference Include="AnimationExtension" /> 46 46 </ItemGroup> 47 <ItemGroup> 48 <Compile Include="jalkapallo.png"> 49 <Name>jalkapallo</Name> 50 <Importer>TextureImporter</Importer> 51 <Processor>TextureProcessor</Processor> 52 </Compile> 53 </ItemGroup> 54 <ItemGroup> 55 <Compile Include="jalkapallokenttä.png"> 56 <Name>jalkapallokenttä</Name> 57 <Importer>TextureImporter</Importer> 58 <Processor>TextureProcessor</Processor> 59 </Compile> 60 </ItemGroup> 47 61 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 48 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.