Changeset 899
- Timestamp:
- 2010-06-16 11:32:11 (13 years ago)
- Location:
- 2010/24/danmarti/Vantaa 2001
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/danmarti/Vantaa 2001/Content/Content.contentproj
r880 r899 1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> 2 2 <PropertyGroup> 3 3 <ProjectGuid>ec8c4e51-a16f-4f35-9f69-64aeb688c97c</ProjectGuid> … … 34 34 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 35 35 </ItemGroup> 36 <ItemGroup> 37 <Compile Include="Split In Synapse.mp3"> 38 <Name>Split In Synapse</Name> 39 <Importer>Mp3Importer</Importer> 40 <Processor>SongProcessor</Processor> 41 </Compile> 42 </ItemGroup> 36 43 </Project> -
2010/24/danmarti/Vantaa 2001/Peli.cs
r880 r899 6 6 public class Peli : PhysicsGame 7 7 { 8 PlatformCharacter Player; 8 PlatformCharacter Player1; 9 PlatformCharacter Player2; 10 IntMeter LifeP1; 11 IntMeter LifeP2; 12 ValueDisplay LifeMeterP1; 13 ValueDisplay LifeMeterP2; 9 14 10 15 const double Speed = 200; 11 const double JumpStr = 3000; 16 const double JumpStr = 2000; 17 const int TileWidth = 50; 18 const int TileHeight = 50; 12 19 13 20 protected override void Begin() 14 21 { 15 StartGame(); 22 SetWindowSize(1024, 720, false); 23 24 LifeP1 = new IntMeter( 3 ); // Pelaajan 1 osumat 25 LifeP2 = new IntMeter( 3 ); // Pelaajan 2 osumat 26 LifeMeterP1 = new ValueDisplay(); 27 LifeMeterP2 = new ValueDisplay(); 28 LifeMeterP1.X = Screen.Left + 100; 29 LifeMeterP1.Y = Screen.Top - 100; 30 LifeMeterP2.X = Screen.Right - 500; 31 LifeMeterP2.Y = Screen.Top - 100; 32 LifeMeterP1.BindTo(LifeP1); 33 LifeMeterP2.BindTo(LifeP2); 34 35 StartCoop(); 16 36 } 17 37 18 38 void ShowMenu() 39 { 40 41 } 42 19 43 20 44 void StartGame() … … 22 46 Gravity = new Vector(0, -1000); 23 47 CreateLevel(); 24 CreatePlayer( );25 Camera.Follow(Player );26 48 CreatePlayer(10, 0); 49 Camera.Follow(Player1); 50 27 51 Controls(); 28 52 } 29 53 30 void CreatePlayer()54 void StartCoop() 31 55 { 32 Player = new PlatformCharacter(30,60); 56 MediaPlayer.Play("Split In Synapse"); 57 Gravity = new Vector(0, -1000); 58 CreateLevel(); 59 Player1 = CreatePlayer(Level.Left + 100.0, Level.Bottom + 100.0); 60 Player2 = CreatePlayer(Level.Left + 200.0, Level.Bottom + 100.0); 61 Add(LifeMeterP1); 62 Add(LifeMeterP2); 63 Camera.Follow(Player1); 64 65 Controls(); 66 } 67 68 PlatformCharacter CreatePlayer(double x, double y) 69 { 70 PlatformCharacter Player = new PlatformCharacter(40, 60); 33 71 Player.Mass = 4.0; 34 72 Add(Player); 73 Player.X = x; 74 Player.Y = y; 35 75 Player.Color = Color.Black; 36 76 Player.KineticFriction = 1.0; 37 77 Player.StaticFriction = 0; 38 78 return Player; 79 80 } 81 82 void CreateEnemy(double x, double y) 83 { 84 PhysicsObject Enemy = new PhysicsObject(40, 65); 85 Enemy.Mass = 3.0; 86 Enemy.X = x; 87 Enemy.Y = y; 88 Enemy.Color = Color.Red; 89 Enemy.KineticFriction = 0.1; 90 Enemy.StaticFriction = 0.1; 91 AddCollisionHandler(Enemy, EnemyPlayerCollision); 92 Enemy.CanRotate = false; 93 Add(Enemy); 94 39 95 } 40 96 41 97 void CreateLevel() 42 98 { 43 Level.CreateBorders(); 99 TileMap Tiles = TileMap.FromFile("BetaMap.txt"); 100 Tiles['x'] = CreateFloor; 101 Tiles.Insert(TileWidth, TileHeight); 102 CreateEnemy(Level.Left + 300.0, Level.Bottom + 100.0); 103 104 105 44 106 } 45 107 46 108 void Controls() 47 109 { 48 Keyboard.Listen(Key.Left, ButtonState.Down, Walk, "Move left", Player, -Speed); 49 Keyboard.Listen(Key.Right, ButtonState.Down, Walk, "Move right", Player, Speed); 50 Keyboard.Listen(Key.Space, ButtonState.Down, Jump, "Jump", Player, JumpStr); 110 Keyboard.Listen(Key.A, ButtonState.Down, Walk, "Move left", Player1, -Speed); 111 Keyboard.Listen(Key.D, ButtonState.Down, Walk, "Move right", Player1, Speed); 112 Keyboard.Listen(Key.W, ButtonState.Down, Jump, "Jump", Player1, JumpStr); 113 114 Keyboard.Listen(Key.Left, ButtonState.Down, Walk, "Move left", Player2, -Speed); 115 Keyboard.Listen(Key.Right, ButtonState.Down, Walk, "Move right", Player2, Speed); 116 Keyboard.Listen(Key.Up, ButtonState.Down, Jump, "Jump", Player2, JumpStr); 51 117 } 52 118 … … 61 127 } 62 128 63 129 PhysicsObject CreateFloor() 130 { 131 PhysicsObject Floor = PhysicsObject.CreateStaticObject(50.0, 50.0); 132 return Floor; 133 } 134 135 void EnemyPlayerCollision(PhysicsObject Enemy, PhysicsObject Target) 136 { 137 if (Target is PlatformCharacter) 138 { 139 // Tarkista onko elämiä jäljellä 140 // Aloita kuolemattomuusjakso esim. 5 sekuntia (tarvitaan ajastin) 141 if (Target == Player1) 142 { 143 LifeP1.Value--; 144 if (LifeP1.Value == 0) 145 { 146 DeathP1(); 147 } 148 } 149 else if (Target == Player2) 150 { 151 LifeP2.Value--; 152 if (LifeP2.Value == 0) 153 { 154 DeathP2(); 155 } 156 } 157 } 158 } 159 160 161 void DeathP1() 162 { 163 Player1.Destroy(); 164 } 165 166 void DeathP2() 167 { 168 Player2.Destroy(); 169 170 } 171 64 172 } -
2010/24/danmarti/Vantaa 2001/Vantaa 2001.csproj
r880 r899 85 85 </ItemGroup> 86 86 <ItemGroup> 87 <Compile Include="BetaMap.cs">88 <SubType>Form</SubType>89 </Compile>90 <Compile Include="BetaMap.Designer.cs">91 <DependentUpon>BetaMap.cs</DependentUpon>92 </Compile>93 87 <Compile Include="Properties\AssemblyInfo.cs" /> 94 88 <Compile Include="Ohjelma.cs" /> … … 96 90 </ItemGroup> 97 91 <ItemGroup> 98 <Content Include="BetaMap.txt" />99 92 <Content Include="Game.ico" /> 100 93 <Content Include="GameThumbnail.png" /> 94 <Content Include="Split In Synapse.mp3" /> 101 95 </ItemGroup> 102 96 <ItemGroup> … … 143 137 </BootstrapperPackage> 144 138 </ItemGroup> 145 <ItemGroup>146 <EmbeddedResource Include="BetaMap.resx">147 <DependentUpon>BetaMap.cs</DependentUpon>148 </EmbeddedResource>149 </ItemGroup>150 139 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 151 140 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
Note: See TracChangeset
for help on using the changeset viewer.