Changeset 3667 for 2012/27


Ignore:
Timestamp:
2012-07-06 12:46:28 (11 years ago)
Author:
maolkuus
Message:

Talletus.

Location:
2012/27/MarkusK/projekti/Kouura/Kouura
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/MarkusK/projekti/Kouura/Kouura/Kouura/Kouura.cs

    r3603 r3667  
    1212    const int ruudunkorkeus = 1; 
    1313 
    14     IntMeter  Ammukset; 
     14     
     15    IntMeter Paukut; 
    1516 
    1617    PhysicsObject Pelaaja; 
    1718 
    18     Vector NopeusYlos = new Vector(0, 50); 
    19     Vector NopeusAlas = new Vector(0, -50); 
    20     Vector NopeusVasen = new Vector(-50, 0); 
    21     Vector NopeusOikea = new Vector(50, 0); 
    22  
     19    Vector NopeusYlos = new Vector(0, 30); 
     20    Vector NopeusAlas = new Vector(0, -30); 
     21    Vector NopeusVasen = new Vector(-30, 0); 
     22    Vector NopeusOikea = new Vector(30, 0); 
     23 
     24    Image taustaKuva = LoadImage("Hypnotoad"); 
    2325 
    2426    public override void Begin() 
    2527    { 
    2628 
     29         
     30        LuoKentta(); 
     31        Lisaalaskuri(); 
    2732        LataaOhjaimet(); 
    28         LuoKentta(); 
    2933 
    3034        // TODO: Kirjoita ohjelmakoodisi tähän 
     
    3842        ruudut.SetTileMethod(Color.White, LuoItem); 
    3943        ruudut.SetTileMethod(Color.Yellow, LuoTrigger); 
     44        ruudut.SetTileMethod(Color.Green, LuoMaali); 
    4045        ruudut.Execute(ruudunkorkeus, ruudunleveys); 
    4146 
     
    5964 
    6065 
    61         Level.BackgroundColor = Color.Green; 
     66        Level.Background.Image = taustaKuva; 
    6267        Camera.ZoomToLevel(); 
    6368    } 
     
    7075        Pelaaja.Position = paikka; 
    7176        Pelaaja.Mass = 10; 
    72         Pelaaja. 
     77        AddCollisionHandler(Pelaaja, "Sydän", Pistelisa); 
     78        AddCollisionHandler(Pelaaja, "Miinus", PisteMiinus); 
     79        AddCollisionHandler(Pelaaja, "Maali", Maali); 
     80 
    7381 
    7482        Add(Pelaaja); 
     
    8189        Seina.Shape = Shape.Rectangle; 
    8290        Seina.Color = Color.MediumVioletRed; 
     91         
    8392        Add(Seina); 
     93    } 
     94    void LuoMaali(Vector paikka, double leveys, double korkeus) 
     95    { 
     96        PhysicsObject Maali = PhysicsObject.CreateStaticObject(1, 1); 
     97        Maali.Position = paikka; 
     98        Maali.Shape = Shape.Rectangle; 
     99        Maali.Color = Color.Red; 
     100        Maali.Tag = "Maali"; 
     101         
     102        Add(Maali); 
    84103    } 
    85104 
     
    92111        Item.Restitution = 1.0; 
    93112        Item.Image = null; 
    94         AddCollisionHandler(Item, Pistelisa); 
     113 
     114        Item.Tag = "Sydän"; 
    95115        Add(Item, 1); 
    96116 
     
    101121        PhysicsObject Trigger = new PhysicsObject(1, 1); 
    102122        Trigger.Position = paikka; 
    103         Trigger.Mass = 0.005; 
     123        Trigger.Mass = 5; 
    104124        Trigger.Color = Color.Crimson; 
    105         Trigger.Shape = Shape.Heart; 
    106         Trigger.Restitution = 1.0; 
     125        Trigger.Shape = Shape.Rectangle; 
     126        Trigger.Restitution = 0; 
    107127        Trigger.Image = null; 
    108         AddCollisionHandler(Trigger, Triggerlaunch); 
     128        Trigger.Tag = "Miinus"; 
    109129 
    110130        Add(Trigger, 1); 
    111131    } 
    112132 
     133 
     134         
     135         
    113136    void LataaOhjaimet() 
    114137    { 
     
    132155    { 
    133156        if ((Nopeus.Y > 0) && (Pelaaja.Top > Level.Top)) 
    134             Pelaaja.Velocity = Vector.Zero; 
    135         return; 
    136  
    137         if ((Nopeus.Y > 0) && (Pelaaja.Bottom < Level.Bottom)) 
    138             Pelaaja.Velocity = Vector.Zero; 
    139         return; 
    140  
    141         if ((Nopeus.X > 0) && (Pelaaja.Left > Level.Left)) 
    142             Pelaaja.Velocity = Vector.Zero; 
    143         return; 
     157        { 
     158            Pelaaja.Velocity = Vector.Zero; 
     159            return; 
     160        } 
     161        if ((Nopeus.Y < 0) && (Pelaaja.Bottom < Level.Bottom)) 
     162        { 
     163            Pelaaja.Velocity = Vector.Zero; 
     164            return; 
     165        } 
     166 
     167        if ((Nopeus.X < 0) && (Pelaaja.Left < Level.Left)) 
     168        { 
     169            Pelaaja.Velocity = Vector.Zero; 
     170            return; 
     171        } 
    144172 
    145173        if ((Nopeus.X > 0) && (Pelaaja.Right > Level.Right)) 
    146             Pelaaja.Velocity = Vector.Zero; 
    147         return; 
     174        { 
     175            Pelaaja.Velocity = Vector.Zero; 
     176            return; 
     177        } 
     178        Pelaaja.Velocity = Nopeus; 
    148179    } 
    149180 
     
    152183    { 
    153184 
    154         Ammukset = Luopistelaskuri (Screen.Left + 100.0, Screen.Top - 100.0);  
     185       Paukut = Luopistelaskuri (Screen.Left + 100.0, Screen.Top - 100.0);  
    155186    } 
    156187 
    157188    IntMeter Luopistelaskuri(double x, double y) 
    158     { 
    159         IntMeter laskuri = new IntMeter (0); 
    160         laskuri.MaxValue = 10; 
     189    { //Jos laskuri laskee 0:an peli loppuu 
     190       IntMeter laskuri = new IntMeter (1); 
     191        laskuri.MaxValue = 20; 
    161192 
    162193        Label naytto = new Label (); 
     
    167198        naytto.BorderColor = Level.BackgroundColor; 
    168199        Add(naytto); 
     200        return laskuri; 
    169201    } 
    170202 
    171203    void Pistelisa(PhysicsObject Pelaaja, PhysicsObject Kohde) 
    172204    { 
    173         if (Pelaaja == Kohde) 
    174             Ammukset.AddValue += 1;  
    175      
    176  
    177         } 
    178                  
     205        
     206        Paukut.AddValue(Paukut+1); 
     207        Kohde.Destroy();   
     208  
     209             
     210 
     211        } 
     212    void PisteMiinus(PhysicsObject Pelaaja, PhysicsObject Kohde) 
     213    { 
     214 
     215        Paukut.AddValue (+-1); 
     216        Kohde.Destroy(); 
     217 
     218 
     219 
     220    } 
     221 
     222    void GameOver() 
     223    { 
     224        if (Paukut <= 0) 
     225        { 
     226            Pelaaja.Destroy(); 
     227        EndRun(); 
     228        } 
     229    } 
     230    void Maali(PhysicsObject Pelaaja, PhysicsObject Kohde) 
     231    { 
     232        //:::// 
     233    } 
     234         
    179235} 
  • 2012/27/MarkusK/projekti/Kouura/Kouura/KouuraContent/KouuraContent.contentproj

    r3597 r3667  
    5252    </Compile> 
    5353  </ItemGroup> 
     54  <ItemGroup> 
     55    <Compile Include="Hypnotoad.png"> 
     56      <Name>Hypnotoad</Name> 
     57      <Importer>TextureImporter</Importer> 
     58      <Processor>TextureProcessor</Processor> 
     59    </Compile> 
     60  </ItemGroup> 
    5461  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    5562  <!--  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.