Changeset 1146


Ignore:
Timestamp:
2010-07-07 14:53:25 (13 years ago)
Author:
frjolehm
Message:

Laitoin peliin elämät ja tein ensimmäisen pikkupelin valmiiksi.

Location:
2010/27/frjolehm/The King of the island/The King of the island
Files:
9 added
4 edited

Legend:

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

    r1125 r1146  
    3535  </ItemGroup> 
    3636  <ItemGroup> 
     37    <Compile Include="Kuollut1.png"> 
     38      <Name>Kuollut1</Name> 
     39      <Importer>TextureImporter</Importer> 
     40      <Processor>TextureProcessor</Processor> 
     41    </Compile> 
     42    <Compile Include="Kuollut2.png"> 
     43      <Name>Kuollut2</Name> 
     44      <Importer>TextureImporter</Importer> 
     45      <Processor>TextureProcessor</Processor> 
     46    </Compile> 
     47  </ItemGroup> 
     48  <ItemGroup> 
     49    <Compile Include="Aita.png"> 
     50      <Name>Aita</Name> 
     51      <Importer>TextureImporter</Importer> 
     52      <Processor>TextureProcessor</Processor> 
     53    </Compile> 
     54  </ItemGroup> 
     55  <ItemGroup> 
    3756    <Compile Include="Tipu1.png"> 
    3857      <Name>Tipu1</Name> 
     
    4059      <Processor>TextureProcessor</Processor> 
    4160    </Compile> 
     61    <Compile Include="Tipu2.png"> 
     62      <Name>Tipu2</Name> 
     63      <Importer>TextureImporter</Importer> 
     64      <Processor>TextureProcessor</Processor> 
     65    </Compile> 
    4266  </ItemGroup> 
    4367</Project> 
  • 2010/27/frjolehm/The King of the island/The King of the island/Peli.cs

    r1125 r1146  
    11using System; 
    22using Jypeli; 
     3using Jypeli.ScreenObjects;  
    34using Jypeli.Widgets; 
    45using Jypeli.Assets; 
     
    67public class Peli : PhysicsGame 
    78{ 
     9  
    810    PlatformCharacter pelaaja1; 
    911    PlatformCharacter pelaaja2; 
     
    1416    PhysicsObject yläreuna; 
    1517 
     18    const int Joukkueenkoko = 3; 
     19    int Pelaajan1joukkue = Joukkueenkoko; 
     20    int Pelaajan2joukkue = Joukkueenkoko; 
     21 
    1622    Boolean Pelaajan1JuoksuAskel; 
    1723    Boolean Pelaajan2JuoksuAskel; 
    18  
    19     const double Juoksunopeus = 20; 
     24    const double Juoksunopeus = 100;//20 
     25    const double Juoksunkiihtyvyys = 2.5; 
     26    double Pelaajan1Juoksunopeus = Juoksunopeus; 
     27    double Pelaajan2Juoksunopeus = Juoksunopeus; 
    2028 
    2129    protected override void Begin() 
     
    2735    { 
    2836        //Kuoleman juoksu 
    29         if (peliMuoto == 1){ 
    30             LuoKenttä(800,700); 
     37        if (peliMuoto == 1) 
     38        { 
     39            LuoKenttä(800,700);     
     40            Camera.ZoomToLevel(); 
     41            LuoElämät(); 
    3142            AddCollisionHandler(oikeareuna, JuoksuVoitto); 
    32             pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75,100, 100); 
    33             pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200, 100, 100); 
     43            pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75,85, 75,"Tipu1"); 
     44            pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200,85, 75,"Tipu2"); 
    3445            JuoksuOhjaimet(); 
    3546        } 
    36  
     47        else if (peliMuoto == 2) 
     48        { 
     49            LuoKenttä(3000, 1000); 
     50            LuoTausta(3000, Level.Bottom); 
     51            pelaaja1 = LuoUkko(Level.Left + 30, Level.Bottom + 75, 85, 75, "Tipu1"); 
     52            Gravity = new Vector(0, -1000); 
     53 
     54            Camera.Follow(pelaaja1); 
     55            LuoElämät(); 
     56            JuoksuOhjaimet(); 
     57        } 
     58 
     59    } 
     60 
     61    void LuoTausta(int w, double y) 
     62    { 
     63        for (int x = 1; x < w; x += 100)  
     64        { 
     65            LuoTaustaEsineitä(x, y, 50, 50, "Aita"); 
     66        } 
     67    } 
     68    void LuoTaustaEsineitä(double x, double y, double w, double h, string nimi) 
     69    { 
     70        PhysicsObject ukko = new PhysicsObject(w,h,Shapes.Rectangle); 
     71        ukko.Image = LoadImage(nimi); 
     72        ukko.X = x; 
     73        ukko.Y = y; 
     74        Add(ukko); 
    3775    } 
    3876 
     
    5290 
    5391        alareuna = Level.CreateBottomBorder(); 
    54         alareuna.IsVisible = false; 
    55  
    56  
    57         Camera.ZoomToLevel(); 
     92        alareuna.Color = Color.Green; 
     93        alareuna.IsVisible = true; 
    5894 
    5995    } 
     
    76112            if (näppäin == Pelaajan1JuoksuAskel) 
    77113            { 
    78                 Liikuta(ukko, Juoksunopeus); 
     114                Pelaajan1Juoksunopeus += Juoksunkiihtyvyys; 
     115                Liikuta(ukko,Pelaajan1Juoksunopeus); 
    79116                if (Pelaajan1JuoksuAskel == true) 
    80117                { 
    81118                    Pelaajan1JuoksuAskel = false; 
    82119                } 
    83  
     120                else 
     121                { 
     122                    Pelaajan1JuoksuAskel = true; 
     123                } 
     124 
     125            } 
     126            if (Pelaajan1Juoksunopeus >= Juoksunopeus) 
     127            { 
     128                Pelaajan1Juoksunopeus -= 1; 
    84129            } 
    85130        } 
     
    88133            if (näppäin == Pelaajan2JuoksuAskel) 
    89134            { 
    90                 Liikuta(ukko, Juoksunopeus); 
     135                Pelaajan2Juoksunopeus += Juoksunkiihtyvyys; 
     136                Liikuta(ukko, Pelaajan2Juoksunopeus); 
    91137                if (Pelaajan2JuoksuAskel == true) 
    92138                { 
    93139                    Pelaajan2JuoksuAskel = false; 
    94140                } 
    95             } 
    96         } 
    97     } 
    98  
    99     void JuoksuVoitto(PhysicsObject maali, PlatformCharacter kohde)  
     141                else 
     142                { 
     143                    Pelaajan2JuoksuAskel = true; 
     144                } 
     145            } 
     146            if (Pelaajan2Juoksunopeus >= Juoksunopeus) 
     147            { 
     148                Pelaajan2Juoksunopeus -= 1; 
     149            } 
     150        } 
     151    } 
     152 
     153    void JuoksuVoitto(PhysicsObject maali, PhysicsObject kohde)  
    100154    {  
    101155        if(kohde == pelaaja1) 
    102156        { 
    103157            ClearAll(); 
     158            Pelaajan2joukkue--; 
     159            Aloitapikkupeli(2);     
    104160        } 
    105161        else if (kohde == pelaaja2)  
    106162        { 
    107163            ClearAll(); 
    108         } 
    109     } 
    110  
    111  
     164            Pelaajan2joukkue--;   
     165            Aloitapikkupeli(2); 
     166        } 
     167    } 
     168 
     169    void LuoElämät()  
     170    { 
     171        for(int i = 1; i < Joukkueenkoko+1; i++) 
     172        { 
     173            if (i <= Pelaajan1joukkue) 
     174            { 
     175                LuoUkkokuva(Screen.Left + i * 50, Screen.Top - 25, 40, 35, "Tipu1"); 
     176            } 
     177            else  
     178            { 
     179                LuoUkkokuva(Screen.Left + i * 50, Screen.Top - 25, 40, 35, "Kuollut1"); 
     180            } 
     181            if (i <= Pelaajan2joukkue) 
     182            { 
     183                LuoUkkokuva(Screen.Right - i * 50, Screen.Top - 25, 40, 35, "Tipu2"); 
     184            } 
     185            else 
     186            { 
     187                LuoUkkokuva(Screen.Right - i * 50, Screen.Top - 25, 40, 35, "Kuollut2"); 
     188            } 
     189        } 
     190    } 
     191 
     192    void LuoUkkokuva(double x, double y, double w, double h, string nimi) 
     193    { 
     194        ImageDisplay ukko = new ImageDisplay(); 
     195        ukko.Image = LoadImage(nimi); 
     196        ukko.AutoSize = false; 
     197        ukko.Width = w; 
     198        ukko.Height = h; 
     199        ukko.X = x; 
     200        ukko.Y = y; 
     201        Add(ukko); 
     202 
     203    } 
    112204 
    113205    void Liikuta(PlatformCharacter ukko, double nopeus) 
     
    116208    } 
    117209 
    118     PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY) 
     210    PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY, string nimi) 
    119211    { 
    120212        PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes.Circle); 
     
    122214        ukko.X = x; 
    123215        ukko.Y = y; 
    124         ukko.Image = LoadImage("Tipu1"); 
     216        ukko.Image = LoadImage(nimi); 
    125217        Add(ukko); 
    126218        return ukko; 
Note: See TracChangeset for help on using the changeset viewer.