Changeset 1178 for 2010


Ignore:
Timestamp:
2010-07-08 11:31:36 (13 years ago)
Author:
frjolehm
Message:

Paransin peliäni, lisäsin mapin.

Location:
2010/27/frjolehm/The King of the island/The King of the island
Files:
8 added
5 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/frjolehm/The King of the island/The King of the island/Content/Content.contentproj

    r1146 r1178  
    4747  </ItemGroup> 
    4848  <ItemGroup> 
    49     <Compile Include="Aita.png"> 
    50       <Name>Aita</Name> 
    51       <Importer>TextureImporter</Importer> 
    52       <Processor>TextureProcessor</Processor> 
    53     </Compile> 
    54   </ItemGroup> 
    55   <ItemGroup> 
    5649    <Compile Include="Tipu1.png"> 
    5750      <Name>Tipu1</Name> 
     
    6558    </Compile> 
    6659  </ItemGroup> 
     60  <ItemGroup> 
     61    <Compile Include="Kenttä1.png"> 
     62      <Name>Kenttä1</Name> 
     63      <Importer>TextureImporter</Importer> 
     64      <Processor>TextureProcessor</Processor> 
     65    </Compile> 
     66  </ItemGroup> 
     67  <ItemGroup> 
     68    <Compile Include="1.png"> 
     69      <Name>1</Name> 
     70      <Importer>TextureImporter</Importer> 
     71      <Processor>TextureProcessor</Processor> 
     72    </Compile> 
     73  </ItemGroup> 
     74  <ItemGroup> 
     75    <Compile Include="2.png"> 
     76      <Name>2</Name> 
     77      <Importer>TextureImporter</Importer> 
     78      <Processor>TextureProcessor</Processor> 
     79    </Compile> 
     80    <Compile Include="3.png"> 
     81      <Name>3</Name> 
     82      <Importer>TextureImporter</Importer> 
     83      <Processor>TextureProcessor</Processor> 
     84    </Compile> 
     85  </ItemGroup> 
     86  <ItemGroup> 
     87    <Compile Include="Aita.png"> 
     88      <Name>Aita</Name> 
     89      <Importer>TextureImporter</Importer> 
     90      <Processor>TextureProcessor</Processor> 
     91    </Compile> 
     92  </ItemGroup> 
    6793</Project> 
  • 2010/27/frjolehm/The King of the island/The King of the island/Peli.cs

    r1157 r1178  
    1919    int Pelaajan1joukkue = Joukkueenkoko; 
    2020    int Pelaajan2joukkue = Joukkueenkoko; 
     21    int peliMuoto = 2; 
    2122 
    2223    Boolean Pelaajan1JuoksuAskel; 
     
    2728    double Pelaajan2Juoksunopeus = Juoksunopeus; 
    2829 
     30    const double HyppyVoima = 4000; 
     31 
     32    ImageDisplay numero; 
     33    DoubleMeter alaspainLaskuri; 
     34 
    2935    protected override void Begin() 
    3036    { 
    31         Aloitapikkupeli(1); 
    32     } 
    33  
    34     void Aloitapikkupeli(int peliMuoto) 
     37        Aloitapikkupeli(); 
     38    } 
     39 
     40    void Aloitapikkupeli() 
    3541    { 
    3642        //Kuoleman juoksu 
    3743        if (peliMuoto == 1) 
    3844        { 
    39             LuoKenttä(800,700);     
     45            LuoKenttä(800,700); 
    4046            Camera.ZoomToLevel(); 
     47            Level.Background.Image = LoadImage("Kenttä1"); 
    4148            LuoElämät(); 
    42             AddCollisionHandler(oikeareuna, JuoksuVoitto); 
     49            AddCollisionHandler(oikeareuna, Voitto); 
    4350            pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75,85, 75,"Tipu1"); 
    4451            pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200,85, 75,"Tipu2"); 
    45             JuoksuOhjaimet(); 
     52            LuoAikaLaskuri(); 
    4653        } 
    4754        else if (peliMuoto == 2) 
    4855        { 
    49             LuoKenttä(3000, 1000); 
    50             LuoTausta(3000, Level.Bottom+75); 
    51             pelaaja1 = LuoUkko(Level.Left + 30, Level.Bottom + 75, 85, 75, "Tipu1"); 
     56            LuoKenttä(30000, 1000); 
     57            LuoTausta(30000, Level.Bottom+75); 
     58 
     59            pelaaja1 = LuoUkko(Level.Left + 150, Level.Bottom + 75, 85, 75, "Tipu1"); 
     60            pelaaja2 = LuoUkko(Level.Left + 10, Level.Bottom + 75, 85, 75, "Tipu2"); 
     61            Pelaajan1Juoksunopeus = 5000; 
     62            Pelaajan2Juoksunopeus = 5000; 
     63 
    5264            Gravity = new Vector(0, -1000); 
    5365 
    54             Camera.Follow(pelaaja1); 
    5566            LuoElämät(); 
    56             JuoksuOhjaimet(); 
     67            LuoAikaLaskuri(); 
    5768        } 
    5869 
     
    6172    void LuoTausta(int w, double y) 
    6273    { 
    63         for (double x = Level.Left; x < w; x += 100)  
    64         { 
    65             LuoTaustaEsineitä(x, y, 50, 50, "Aita"); 
     74        for (double x = Level.Left+2500; x < w; x += RandomGen.NextDouble(600,1000) ) 
     75        { 
     76            LuoTaustaEsineitä(x, y, 100, 50, "Aita"); 
    6677        } 
    6778    } 
     
    7081        PhysicsObject ukko = new PhysicsObject(w,h,Shapes.Rectangle); 
    7182        ukko.Image = LoadImage(nimi); 
     83        ukko.Restitution = 0; 
    7284        ukko.X = x; 
    7385        ukko.Y = y; 
     
    95107    } 
    96108 
     109    void HyppyOhjaimet() 
     110    { 
     111        Keyboard.Listen(Key.W, ButtonState.Pressed, LuoHyppy, "Pelaaja1 hyppää", pelaaja1, false); 
     112        Keyboard.Listen(Key.Up, ButtonState.Pressed, LuoHyppy, "Pelaaja1 hyppää", pelaaja2, true); 
     113    } 
     114 
     115    void LuoHyppy(PlatformCharacter ukko,Boolean pelaaja) 
     116    { 
     117        ukko.Jump(HyppyVoima); 
     118        if (pelaaja == false) 
     119        { 
     120            Pelaajan1Juoksunopeus += Juoksunkiihtyvyys * 100; 
     121        } 
     122        else 
     123        { 
     124            Pelaajan2Juoksunopeus += Juoksunkiihtyvyys * 100; 
     125        } 
     126    } 
     127 
     128 
    97129    void JuoksuOhjaimet()  
    98130    { 
    99         Keyboard.Listen(Key.A, ButtonState.Pressed, LuoJuoksu, "Pelaaja liikkuu", pelaaja1, false, false); 
    100         Keyboard.Listen(Key.D, ButtonState.Pressed, LuoJuoksu, "Pelaaja liikkuu", pelaaja1, false, true); 
     131        Keyboard.Listen(Key.A, ButtonState.Pressed, LuoJuoksu, "Pelaaja1 liikkuu", pelaaja1, false, false); 
     132        Keyboard.Listen(Key.D, ButtonState.Pressed, LuoJuoksu, "Pelaaja1 liikkuu", pelaaja1, false, true); 
    101133 
    102134        Keyboard.Listen(Key.Left, ButtonState.Pressed, LuoJuoksu, "Pelaaja2 liikkuu", pelaaja2, true, false); 
     
    151183    } 
    152184 
    153     void JuoksuVoitto(PhysicsObject maali, PhysicsObject kohde)  
     185    void Voitto(PhysicsObject maali, PhysicsObject kohde)  
    154186    {  
    155187        if(kohde == pelaaja1) 
    156188        { 
    157             ClearAll(); 
    158             Pelaajan2joukkue--; 
    159             Aloitapikkupeli(2);     
     189            if (peliMuoto == 1) 
     190            { 
     191                ClearAll(); 
     192                Pelaajan2joukkue--; 
     193                peliMuoto++; 
     194                Aloitapikkupeli(); 
     195            } 
     196            else if (peliMuoto == 2) 
     197            { 
     198                ClearAll(); 
     199                Pelaajan1joukkue--; 
     200                peliMuoto++; 
     201                Aloitapikkupeli(); 
     202            } 
    160203        } 
    161204        else if (kohde == pelaaja2)  
    162205        { 
    163             ClearAll(); 
    164             Pelaajan2joukkue--;   
    165             Aloitapikkupeli(2); 
    166         } 
    167     } 
     206            if (peliMuoto == 1) 
     207            { 
     208                ClearAll(); 
     209                Pelaajan1joukkue--; 
     210                peliMuoto++; 
     211                Aloitapikkupeli(); 
     212            } 
     213            else if (peliMuoto == 2) 
     214            { 
     215                ClearAll(); 
     216                Pelaajan2joukkue--; 
     217                peliMuoto++; 
     218                Aloitapikkupeli(); 
     219            } 
     220        } 
     221    } 
     222 
    168223 
    169224    void LuoElämät()  
     
    203258    } 
    204259 
     260    void LuoAikaLaskuri() 
     261    { 
     262        alaspainLaskuri = new DoubleMeter(4); 
     263        numero = new ImageDisplay(); ; 
     264 
     265        Timer aikaLaskuri = new Timer(); 
     266        aikaLaskuri.Interval = 1; 
     267        aikaLaskuri.Trigger += LaskeAlaspäin; 
     268        Add(aikaLaskuri); 
     269        aikaLaskuri.Start(); 
     270 
     271    } 
     272 
     273    void LaskeAlaspäin(Timer timer) 
     274    { 
     275        alaspainLaskuri.Value -= 1; 
     276        if (alaspainLaskuri.Value <= 0) 
     277        { 
     278            if (peliMuoto == 1) 
     279            { 
     280                JuoksuOhjaimet(); 
     281            } 
     282            else if (peliMuoto == 2) 
     283            { 
     284                HyppyOhjaimet(); 
     285            } 
     286             
     287            timer.Stop(); 
     288            numero.Destroy(); 
     289 
     290            // täydennä mitä tapahtuu, kun aika loppuu 
     291        }else if (alaspainLaskuri.Value <= 1) 
     292        { 
     293                numero.Image = LoadImage("1"); 
     294             
     295        } 
     296        else if (alaspainLaskuri.Value <= 2) 
     297        { 
     298            numero.Image = LoadImage("2"); 
     299        } 
     300        else if (alaspainLaskuri.Value <= 3) 
     301        { 
     302            numero.Image = LoadImage("3"); 
     303            Add(numero); 
     304        } 
     305    } 
     306 
     307 
    205308    void Liikuta(PlatformCharacter ukko, double nopeus) 
    206309    { 
     
    208311    } 
    209312 
     313 
    210314    PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY, string nimi) 
    211315    { 
    212         PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes.Circle); 
     316        PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes.Rectangle); 
    213317        ukko.Mass = 4.0; 
    214318        ukko.X = x; 
     
    218322        return ukko; 
    219323    } 
     324 
     325    protected override void Update(Time time) 
     326    { 
     327        base.Update(time); 
     328        if (peliMuoto == 2) 
     329        { 
     330            pelaaja1.Push(new Vector(Pelaajan1Juoksunopeus, 0)); 
     331            pelaaja2.Push(new Vector(Pelaajan2Juoksunopeus, 0)); 
     332            Camera.X = (pelaaja1.X + pelaaja2.X) / 2; 
     333        } 
     334    } 
    220335} 
  • 2010/27/frjolehm/The King of the island/The King of the island/The King of the island.csproj

    r1125 r1178  
    5757  </PropertyGroup> 
    5858  <ItemGroup> 
    59     <Reference Include="Jypeli2, Version=2.3.1.0, Culture=neutral, processorArchitecture=x86"> 
     59    <Reference Include="Jypeli2, Version=2.2.3.0, Culture=neutral, processorArchitecture=x86"> 
    6060      <SpecificVersion>False</SpecificVersion> 
    6161      <HintPath>..\..\..\lib\Jypeli2.dll</HintPath> 
Note: See TracChangeset for help on using the changeset viewer.