Changeset 899


Ignore:
Timestamp:
2010-06-16 11:32:11 (13 years ago)
Author:
danmarti
Message:

Lisättiin vihollinen ja laskuri joka mittaa jäljellä olevat elämät.

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"> 
    22  <PropertyGroup> 
    33    <ProjectGuid>ec8c4e51-a16f-4f35-9f69-64aeb688c97c</ProjectGuid> 
     
    3434    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 
    3535  </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> 
    3643</Project> 
  • 2010/24/danmarti/Vantaa 2001/Peli.cs

    r880 r899  
    66public class Peli : PhysicsGame 
    77{ 
    8     PlatformCharacter Player; 
     8    PlatformCharacter Player1; 
     9    PlatformCharacter Player2; 
     10    IntMeter LifeP1; 
     11    IntMeter LifeP2; 
     12    ValueDisplay LifeMeterP1; 
     13    ValueDisplay LifeMeterP2; 
    914 
    1015    const double Speed = 200; 
    11     const double JumpStr = 3000; 
     16    const double JumpStr = 2000; 
     17    const int TileWidth = 50; 
     18    const int TileHeight = 50; 
    1219 
    1320    protected override void Begin() 
    1421    { 
    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(); 
    1636    } 
    1737 
    18      
     38    void ShowMenu() 
     39    { 
     40 
     41    } 
     42 
    1943 
    2044    void StartGame() 
     
    2246        Gravity = new Vector(0, -1000); 
    2347        CreateLevel(); 
    24         CreatePlayer(); 
    25         Camera.Follow(Player); 
    26          
     48        CreatePlayer(10, 0); 
     49        Camera.Follow(Player1); 
     50 
    2751        Controls(); 
    2852    } 
    2953 
    30     void CreatePlayer() 
     54    void StartCoop() 
    3155    { 
    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); 
    3371        Player.Mass = 4.0; 
    3472        Add(Player); 
     73        Player.X = x; 
     74        Player.Y = y; 
    3575        Player.Color = Color.Black; 
    3676        Player.KineticFriction = 1.0; 
    3777        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 
    3995    } 
    4096 
    4197    void CreateLevel() 
    4298    { 
    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 
    44106    } 
    45107 
    46108    void Controls() 
    47109    { 
    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); 
    51117    } 
    52118 
     
    61127    } 
    62128 
    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 
    64172} 
  • 2010/24/danmarti/Vantaa 2001/Vantaa 2001.csproj

    r880 r899  
    8585  </ItemGroup> 
    8686  <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> 
    9387    <Compile Include="Properties\AssemblyInfo.cs" /> 
    9488    <Compile Include="Ohjelma.cs" /> 
     
    9690  </ItemGroup> 
    9791  <ItemGroup> 
    98     <Content Include="BetaMap.txt" /> 
    9992    <Content Include="Game.ico" /> 
    10093    <Content Include="GameThumbnail.png" /> 
     94    <Content Include="Split In Synapse.mp3" /> 
    10195  </ItemGroup> 
    10296  <ItemGroup> 
     
    143137    </BootstrapperPackage> 
    144138  </ItemGroup> 
    145   <ItemGroup> 
    146     <EmbeddedResource Include="BetaMap.resx"> 
    147       <DependentUpon>BetaMap.cs</DependentUpon> 
    148     </EmbeddedResource> 
    149   </ItemGroup> 
    150139  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 
    151140  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" /> 
Note: See TracChangeset for help on using the changeset viewer.