Changeset 3550 for 2012


Ignore:
Timestamp:
2012-07-04 14:59:18 (11 years ago)
Author:
jejokiil
Message:

Talletus.

Location:
2012/27/JesseK
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/JesseK/omapeli/omapeli/omapeli/omapeli.cs

    r3490 r3550  
    99public class omapeli : PhysicsGame 
    1010{ 
    11     Vector nopeusOikea = new Vector(150, 0); 
    12     Vector nopeusVasen = new Vector(-150, 0); 
    13     Vector nopeusHyppy = new Vector(0, 300); 
     11    PhysicsObject kolikko; 
     12    Image idleOikea = LoadImage("hqkeijo"); 
     13    Image idleVasen; 
     14    Image myrkkysieni = LoadImage("hqmyrkkysieni"); 
     15    Image alusta = LoadImage("hqalusta"); 
     16    double tasonopeus = 10; 
     17    const double liikkumisnopeus = 90; 
     18    // Vector nopeusOikea = new Vector(150, 0); 
     19    // Vector nopeusVasen = new Vector(-150, 0); 
     20    // Vector nopeusHyppy = new Vector(0, 300); 
    1421    PlatformCharacter ukko; 
    1522    // PhysicsObject taso; 
    1623    public override void Begin() 
    1724    { 
    18   
     25        idleVasen = Image.Mirror(idleOikea); 
    1926 
    2027        LuoKentta(); 
    21         LuoTaso(-150, Level.Bottom + 40.0); 
    2228        LuoPelaaja(); 
     29        LuoPisteLaskuri(); 
    2330        AsetaKontrollit(); 
    2431        Gravity = new Vector(0, -1100); 
    2532 
    26         Camera.ZoomFactor = 6.0; 
     33        Camera.ZoomFactor = 1.3; 
    2734        Camera.Follow(ukko); 
    28  
    29          
     35        AddCollisionHandler<PlatformCharacter, PhysicsObject>(ukko, KolikkoKeratty); 
     36        AddCollisionHandler<PlatformCharacter, PhysicsObject>(ukko, SieniOsuma); 
    3037    } 
    3138    
     
    3542        ukko.X = -500; 
    3643        ukko.Y = Level.Bottom; 
    37         ukko.Shape = Shape.Rectangle; 
     44        ukko.Shape = Shape.FromImage(idleOikea); 
    3845        ukko.Color = Color.Transparent; 
    3946        ukko.Image = LoadImage("hqkeijo"); 
    4047        ukko.CanRotate = false; 
    41         ukko.MaintainMomentum = true; 
     48        ukko.MaintainMomentum = false; 
    4249        ukko.LinearDamping = 0.93; 
    4350        ukko.CollisionIgnoreGroup = 1; 
     51        ukko.LeftIdleAnimation = new Animation(idleVasen); 
     52        ukko.RightIdleAnimation = new Animation(idleOikea); 
     53        ukko.LeftWalkingAnimation = new Animation(idleVasen); 
     54        ukko.RightWalkingAnimation = new Animation(idleOikea); 
    4455        Add(ukko); 
    4556    } 
     
    5061        PhysicsObject alareuna = Level.CreateBottomBorder(); 
    5162        alareuna.IsVisible = true; 
    52         alareuna.Color = Color.Transparent; 
    53         alareuna.Image = LoadImage("hqmaa"); 
    54   
     63        alareuna.Color = Color.DarkOrange; 
     64 
     65        PhysicsObject koro1 = PhysicsObject.CreateStaticObject(300, 100); 
     66        koro1.X = 200; 
     67        koro1.Y = Level.Bottom + 50; 
     68        koro1.Color = Color.DarkOrange; 
     69        koro1.Shape = Shape.Rectangle; 
     70        Add(koro1); 
     71        // Myrkkysienen tekeminen -- Myrkkysienen koko: 25 x 25 
    5572        LuoMyrkkysieni(-150.0, Level.Bottom + 12.5); 
    56  
    57         PhysicsObject kyltti = PhysicsObject.CreateStaticObject(100, 100); 
     73        LuoMyrkkysieni(-100.0, Level.Bottom + 12.5); 
     74        LuoMyrkkysieni(-50.0, Level.Bottom + 12.5); 
     75        LuoMyrkkysieni(0.0, Level.Bottom + 12.5); 
     76        LuoMyrkkysieni(100.0, Level.Bottom + 112.0); 
     77        // Tasojen tekeminen -- Tason koko: 23 x 9 
     78        LuoTaso(-150, Level.Bottom + 40.0); 
     79        LuoTaso(-100, Level.Bottom + 40.0); 
     80        LuoTaso(-20, Level.Bottom + 60.0); 
     81        LuoTaso(20, Level.Bottom + 100.0); 
     82        LuoTaso(Level.Right - 60, Level.Bottom + 10.0); 
     83        LuoTaso(Level.Right - 20, Level.Bottom + 50.0); 
     84        LuoTaso(Level.Right - 60, Level.Bottom + 90.0); 
     85        LuoTaso(Level.Right - 120, Level.Bottom + 130.0); 
     86        LuoTaso(Level.Right - 150, Level.Bottom + 170.0); 
     87        LuoTaso(Level.Right - 173, Level.Bottom + 170.0); 
     88        LuoTaso(Level.Right - 196, Level.Bottom + 170.0); 
     89        LuoTaso(Level.Right - 219, Level.Bottom + 220.0); 
     90        LuoTaso(Level.Right - 262, Level.Bottom + 270.0); 
     91        LuoTaso(Level.Right - 350, Level.Bottom + 270.0); 
     92        LuoTaso(Level.Right - 390, Level.Bottom + 310.0); 
     93        LuoLiikkuvaTaso(Level.Right - 530, Level.Bottom + 310.0); 
     94        LuoTaso(Level.Right - 560, Level.Bottom + 310.0); 
     95        // Kolikon tekeminen -- Kolikon koko: 12 x 12 
     96        LuoKolikko(-150.0, Level.Bottom + 53.0, "kolikko"); 
     97        LuoKolikko(-100.0, Level.Bottom + 53.0, "kolikko"); 
     98        LuoKolikko(20.0, Level.Bottom + 115.0, "kolikko"); 
     99        LuoKolikko(Level.Right - 100.0, Level.Bottom + 10.0, "kolikko"); 
     100        LuoKolikko(Level.Right - 115.0, Level.Bottom + 10.0, "kolikko"); 
     101        LuoKolikko(Level.Right - 130.0, Level.Bottom + 10.0, "kolikko"); 
     102        LuoKolikko(Level.Right - 219.0, Level.Bottom + 232.5, "kolikko"); 
     103        LuoKolikko(Level.Right - 262.0, Level.Bottom + 282.5, "kolikko"); 
     104        Level.CreateBorders(); 
     105         
     106 
     107        PhysicsObject kyltti = PhysicsObject.CreateStaticObject(100, 50); 
    58108        kyltti.X = -350; 
    59         kyltti.Y = Level.Bottom + 20.0; 
    60         kyltti.Color = Color.Beige; 
     109        kyltti.Y = Level.Bottom + 25.0; 
     110        kyltti.Color = Color.Transparent; 
     111        kyltti.Image = LoadImage("hqinfo"); 
    61112        kyltti.CollisionIgnoreGroup = 1; 
    62113        Add(kyltti); 
    63  
    64     } 
    65  
    66     void LuoMyrkkysieni(double x, double y) 
    67     { 
     114    } 
     115 
     116     void LuoMyrkkysieni(double x, double y) 
     117   { 
    68118        PhysicsObject sieni = PhysicsObject.CreateStaticObject(25, 25); 
    69119        sieni.Color = Color.Transparent; 
    70120        sieni.Image = LoadImage("hqmyrkkysieni"); 
     121        sieni.Shape = Shape.Rectangle; 
     122        sieni.Tag = "sieni"; 
    71123        sieni.X = x; 
    72124        sieni.Y = y; 
     
    74126    } 
    75127 
    76     void AsetaNopeus(PlatformCharacter ukko, double nopeus) 
    77     { 
    78         ukko.Walk(nopeus); 
     128    void LuoKolikko(double x, double y, String tagi) 
     129    { 
     130        PhysicsObject kolikko = PhysicsObject.CreateStaticObject(12, 12); 
     131        kolikko.Color = Color.Transparent; 
     132        kolikko.Image = LoadImage("hqkolikko"); 
     133        kolikko.Tag = "kolikko"; 
     134        kolikko.X = x; 
     135        kolikko.Y = y; 
     136        Add(kolikko); 
     137    } 
     138 
     139   void KolikkoKeratty(PhysicsObject tormaaja, PhysicsObject kohde) 
     140      { 
     141          if (kohde.Tag.ToString() == "kolikko") 
     142          { 
     143              pistelaskuri.Value += 1; 
     144              kohde.Destroy(); 
     145          } 
     146      } 
     147 
     148    void SieniOsuma(PhysicsObject tormaaja, PhysicsObject kohde) 
     149    { 
     150        if (kohde.Tag.ToString() == "sieni") 
     151        { 
     152            ukko.X = -500; 
     153            ukko.Y = Level.Bottom; 
     154        } 
     155    } 
     156 
     157 
     158    IntMeter pistelaskuri; 
     159 
     160    void LuoPisteLaskuri() 
     161    { 
     162        pistelaskuri = new IntMeter(0); 
     163 
     164        Label pisteNaytto = new Label(); 
     165        pisteNaytto.Title = "Kolikot"; 
     166        pisteNaytto.X = Screen.Left + 100; 
     167        pisteNaytto.Y = Screen.Top - 100; 
     168        pisteNaytto.TextColor = Color.Black; 
     169        pisteNaytto.Color = Color.Transparent; 
     170        pisteNaytto.BindTo(pistelaskuri); 
     171        Add(pisteNaytto); 
     172    } 
     173 
     174    void AsetaNopeus(PlatformCharacter ukko, double liikkumisnopeus) 
     175    { 
     176        ukko.Walk(liikkumisnopeus); 
    79177    } 
    80178 
     
    86184    void AsetaKontrollit() 
    87185    { 
    88         Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa oikealle", ukko, 90.0); 
    89         Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa vasemmalle", ukko, -90.0); 
    90         Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Hyppää", ukko, 490.0); 
     186        Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa oikealle", ukko, liikkumisnopeus); 
     187        Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa vasemmalle", ukko, -1 * liikkumisnopeus); 
     188        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Hyppää", ukko, 650.0); 
    91189        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    92190        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    93  
    94191    } 
    95192 
     
    100197        taso.Y = y; 
    101198        taso.Image = LoadImage("hqalusta"); 
     199        taso.Shape = Shape.FromImage(alusta); 
    102200        Add(taso); 
    103201    } 
    104202 
     203    void LuoLiikkuvaTaso(double x, double y) 
     204    { 
     205        PhysicsObject taso = new PhysicsObject(23, 9); 
     206        taso.Collided += VaihdaSuunta; 
     207        taso.IgnoresGravity = true; 
     208        taso.Mass = 100000; 
     209        taso.Velocity = new Vector(tasonopeus, 0); 
     210        taso.X = x; 
     211        taso.Y = y; 
     212        taso.Image = LoadImage("hqalusta"); 
     213        taso.Shape = Shape.FromImage(alusta); 
     214        Add(taso); 
     215    } 
     216 
     217    void VaihdaSuunta(IPhysicsObject törmääjä, IPhysicsObject kohde) 
     218    { 
     219 
     220        törmääjä.Velocity *= -1; 
     221    } 
     222 
    105223} 
  • 2012/27/JesseK/omapeli/omapeli/omapeliContent/omapeliContent.contentproj

    r3490 r3550  
    9898    </Compile> 
    9999  </ItemGroup> 
     100  <ItemGroup> 
     101    <Compile Include="hqinfo.png"> 
     102      <Name>hqinfo</Name> 
     103      <Importer>TextureImporter</Importer> 
     104      <Processor>TextureProcessor</Processor> 
     105    </Compile> 
     106  </ItemGroup> 
     107  <ItemGroup> 
     108    <Compile Include="kenttatest.png"> 
     109      <Name>kenttatest</Name> 
     110      <Importer>TextureImporter</Importer> 
     111      <Processor>TextureProcessor</Processor> 
     112    </Compile> 
     113  </ItemGroup> 
    100114  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    101115  <!--  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.