Changeset 5574 for 2014


Ignore:
Timestamp:
2014-07-23 11:19:11 (9 years ago)
Author:
athebla
Message:

Peli päivitetty + lisää tekstuureja

Location:
2014/30/AtteB
Files:
20 added
13 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/AtteB/Peli/Peli/Peli/Peli.cs

    r5540 r5574  
    1919} 
    2020 
     21class Inventory : Widget 
     22{ 
     23 
     24    /// Tapahtuma, kun esine on valittu. 
     25    public event Action<PhysicsObject> ItemSelected; 
     26 
     27    /// Luo uuden esinevalikon. 
     28    public Inventory() 
     29        : base(new HorizontalLayout()) 
     30    { 
     31    } 
     32 
     33    /// Lisää esineen. 
     34    public void AddItem(PhysicsObject item, Image kuva) 
     35    { 
     36        PushButton icon = new PushButton(kuva); 
     37        Add(icon); 
     38        icon.Clicked += delegate() { SelectItem(item); }; 
     39    } 
     40 
     41    void SelectItem(PhysicsObject item) 
     42    { 
     43        if (ItemSelected != null) 
     44        { 
     45            ItemSelected(item); 
     46        } 
     47    } 
     48} 
     49 
    2150public class Peli : PhysicsGame 
    2251{ 
    23     int pelaajanTerveys = 100; 
    24  
    25     DoubleMeter P1Elämät; 
     52    DoubleMeter elämäLaskuri; 
     53 
     54    AssaultRifle P1FireBall; 
    2655 
    2756    const double nopeus = 200; 
     
    3059 
    3160    PlatformCharacter pelaaja1; 
    32     PlatformCharacter vihollinen1; 
    3361 
    3462    Image tahtiKuva = LoadImage("tahti"); 
     
    3967    Image Pelaaja_Juoksee = LoadImage("Pelaaja_Juoksee"); 
    4068    Image StoneBrickTaso = LoadImage("Stone_brick_tile"); 
    41     Image Slime = LoadImage("Slime"); 
     69    Image Slime1 = LoadImage("Slime"); 
     70    Image FireBall1 = LoadImage("FireBall_1"); 
     71    Image FireBall2 = LoadImage("FireBall_2"); 
     72    Image FireBall3 = LoadImage("FireBall_3"); 
     73    Image FireBall4 = LoadImage("FireBall_4"); 
     74    Image Clear = LoadImage("Clear"); 
     75    Image Heart1 = LoadImage("heart"); 
    4276 
    4377    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    5993        SmoothTextures = false; 
    6094 
    61         P1Elämät= new DoubleMeter(100); 
    62         P1Elämät.MaxValue = 100; 
    63  
    64         BarGauge P1Elämä = new BarGauge(20, Screen.Width / 3); 
    65         P1Elämä.X = Screen.Left + Screen.Width / 2; 
    66         P1Elämä.Y = Screen.Top - 200; 
    67         P1Elämä.Angle = Angle.FromDegrees(90); 
    68         P1Elämä.BindTo(P1Elämät); 
    69         P1Elämä.Color = Color.BloodRed; 
    70         P1Elämä.BarColor = Color.Cyan; 
    71         Add(P1Elämä); 
    72  
     95        Inventory inventory = new Inventory(); 
     96        Add(inventory); 
    7397    } 
    7498 
     
    77101        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    78102        kentta.SetTileMethod('#', LisaaTaso); 
    79         kentta.SetTileMethod('*', LisaaTahti); 
    80103        kentta.SetTileMethod('N', LisaaPelaaja); 
    81104        kentta.SetTileMethod('P', LisaaStoneLattia); 
     
    83106        kentta.SetTileMethod('?', LisaaStoneBrickLattia); 
    84107        kentta.SetTileMethod('S', LuoSlime); 
     108        kentta.SetTileMethod('H', LisaaHeart); 
    85109        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    86110        Level.CreateBorders(); 
     
    117141    } 
    118142 
    119  
    120143    void LisaaStoneKatto(Vector paikka, double leveys, double korkeus) 
    121144    { 
     
    128151    } 
    129152 
    130  
    131     void LisaaTahti(Vector paikka, double leveys, double korkeus) 
    132     { 
    133         PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    134         tahti.IgnoresCollisionResponse = true; 
    135         tahti.Position = paikka; 
    136         tahti.Image = tahtiKuva; 
    137         tahti.Tag = "tahti"; 
    138         Add(tahti); 
     153    void LisaaHeart(Vector paikka, double leveys, double korkeus) 
     154    { 
     155        PhysicsObject heart = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     156        heart.IgnoresCollisionResponse = true; 
     157        heart.Position = paikka; 
     158        heart.Image = Heart1; 
     159        heart.Tag = "health"; 
     160        Add(heart); 
    139161    } 
    140162 
     
    145167        pelaaja1.Mass = 10.0; 
    146168        pelaaja1.Image = Pelaaja_Seisoo; 
    147         AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     169        AddCollisionHandler(pelaaja1, "vihollinen", PelaajaOsuuViholliseen); 
     170        AddCollisionHandler(pelaaja1, "health", PelaajaOsuuHeart); 
    148171        Add(pelaaja1); 
     172 
     173        P1FireBall = new AssaultRifle(30, 10); 
     174 
     175        // Ammusten määrä 
     176        P1FireBall.Ammo.Value = 100000; 
     177 
     178        // Ammus osuu = mitä tapahtuu 
     179        P1FireBall.ProjectileCollision = AmmusOsuiViholliseen; 
     180        P1FireBall.Image = Clear; 
     181 
     182        pelaaja1.Add(P1FireBall); 
    149183    } 
    150184 
     
    153187        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    154188        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    155  
    156         Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
    157         Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    158         Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     189        Keyboard.Listen(Key.LeftShift, ButtonState.Down, AmmuAseella, "Ammu", P1FireBall); 
     190 
     191        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     192        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
     193        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     194        Keyboard.Listen(Key.Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    159195 
    160196        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
     
    177213    } 
    178214 
    179     void TormaaTahteen(PhysicsObject hahmo, PhysicsObject tahti) 
    180     { 
    181         maaliAani.Play(); 
    182         MessageDisplay.Add("Keräsit tähden!"); 
    183         tahti.Destroy(); 
    184     } 
    185  
    186215    void LuoVihollinen(Vector paikka, double leveys, double korkeus) 
    187216    { 
    188217        PhysicsObject vihollinen = new PhysicsObject(leveys, korkeus); 
    189218        vihollinen.Position = paikka; 
    190         vihollinen.Tag = "pahis"; 
     219        vihollinen.Tag = "vihollinen"; 
    191220        Add(vihollinen); 
    192221    } 
     
    200229    } 
    201230 
    202     void TörmäysKäsittelijät() 
    203     { 
    204         AddCollisionHandler(pelaaja1, "pahis", PelaajaOsuu); 
    205         AddCollisionHandler(pelaaja1, "health", PelaajaParantuu); 
    206     } 
    207  
    208     void PelaajaOsuu(PhysicsObject pelaaja1, PhysicsObject kohde) 
    209     { 
    210         pelaajanTerveys--; 
    211  
    212         if (pelaajanTerveys <= 0) 
     231    void PelaajaOsuuViholliseen(PhysicsObject pelaaja1, PhysicsObject kohde) 
     232    { 
     233        elämäLaskuri.Value -= 10; 
     234 
     235        if (elämäLaskuri <= 0) 
    213236            pelaaja1.Destroy(); 
    214237    } 
    215238 
    216     void PelaajaParantuu(PhysicsObject pelaaja1, PhysicsObject kohde) 
    217     { 
    218         pelaajanTerveys++; 
     239    void PelaajaOsuuHeart(PhysicsObject pelaaja1, PhysicsObject kohde) 
     240    { 
     241        if (elämäLaskuri < 65) 
     242        { 
     243            elämäLaskuri.Value += 30; 
     244        } 
    219245    } 
    220246 
    221247    void LuoSlime(Vector paikka, double leveys, double korkeus) 
    222248    { 
    223         Vihollinen Slime1 = new Vihollinen(40, 40); 
    224         Slime1.X = 20; 
    225         Slime1.Y = 20; 
    226         Slime1.Image = Slime; 
    227  
    228     } 
     249        PhysicsObject Slime = new PhysicsObject(leveys, korkeus); 
     250        Slime.CanRotate = false; 
     251        Slime.Position = paikka; 
     252        Slime.Tag = "vihollinen"; 
     253        Slime.Image = Slime1; 
     254        Add(Slime); 
     255    } 
     256 
     257    void AmmusOsuiViholliseen(PhysicsObject ammus, PhysicsObject kohde) 
     258    { 
     259        ammus.Destroy(); 
     260 
     261    } 
     262 
     263    void AmmuAseella(AssaultRifle ase) 
     264    { 
     265        PhysicsObject ammus = ase.Shoot(); 
     266 
     267        if (ammus != null) 
     268        { 
     269            ammus.Image = FireBall1; 
     270            ammus.Size = new Vector(40, 40); 
     271        } 
     272    } 
     273 
     274    void LuoElämäLaskuri() 
     275    { 
     276        elämäLaskuri = new DoubleMeter(100); 
     277        elämäLaskuri.MaxValue = 100; 
     278        elämäLaskuri.LowerLimit += ElämäLoppui; 
     279 
     280        ProgressBar elämäPalkki = new ProgressBar(150, 20); 
     281        elämäPalkki.X = Screen.Left + 150; 
     282        elämäPalkki.Y = Screen.Top - 20; 
     283        elämäPalkki.BindTo(elämäLaskuri); 
     284        elämäPalkki.Color = Color.Transparent; 
     285        elämäPalkki.BarColor = Color.Red; 
     286        elämäPalkki.BorderColor = Color.Black; 
     287        Add(elämäPalkki); 
     288    } 
     289 
     290    void ElämäLoppui() 
     291    { 
     292        MessageDisplay.Add("Elämät loppuivat, voi voi."); 
     293        Remove(pelaaja1); 
     294    } 
     295 
    229296} 
  • 2014/30/AtteB/Peli/Peli/Peli/Peli.csproj.Debug.cachefile

    r5540 r5574  
    1212Content\Stonewall.xnb 
    1313Content\Slime.xnb 
     14Content\Fireball_1.xnb 
     15Content\Fireball_2.xnb 
     16Content\Fireball_3.xnb 
     17Content\Fireball_4.xnb 
     18Content\Clear.xnb 
     19Content\heart.xnb 
  • 2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/ContentPipeline-{2D86B228-748C-44C7-93B1-DCBD6910317C}.xml

    r5540 r5574  
    3636      <Options>None</Options> 
    3737      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\kentta1.xnb</Output> 
    38       <Time>2014-07-22T14:35:50.3392059+03:00</Time> 
     38      <Time>2014-07-23T10:47:44.2742229+03:00</Time> 
    3939    </Item> 
    4040    <Item> 
     
    118118      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Slime.xnb</Output> 
    119119      <Time>2014-07-22T14:06:10.9162814+03:00</Time> 
     120    </Item> 
     121    <Item> 
     122      <Source>Fireball_1.png</Source> 
     123      <Name>Fireball_1</Name> 
     124      <Importer>TextureImporter</Importer> 
     125      <Processor>TextureProcessor</Processor> 
     126      <Options>None</Options> 
     127      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_1.xnb</Output> 
     128      <Time>2014-07-23T10:17:37.7835919+03:00</Time> 
     129    </Item> 
     130    <Item> 
     131      <Source>Fireball_2.png</Source> 
     132      <Name>Fireball_2</Name> 
     133      <Importer>TextureImporter</Importer> 
     134      <Processor>TextureProcessor</Processor> 
     135      <Options>None</Options> 
     136      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_2.xnb</Output> 
     137      <Time>2014-07-23T10:17:37.7795915+03:00</Time> 
     138    </Item> 
     139    <Item> 
     140      <Source>Fireball_3.png</Source> 
     141      <Name>Fireball_3</Name> 
     142      <Importer>TextureImporter</Importer> 
     143      <Processor>TextureProcessor</Processor> 
     144      <Options>None</Options> 
     145      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_3.xnb</Output> 
     146      <Time>2014-07-23T10:17:37.7805916+03:00</Time> 
     147    </Item> 
     148    <Item> 
     149      <Source>Fireball_4.png</Source> 
     150      <Name>Fireball_4</Name> 
     151      <Importer>TextureImporter</Importer> 
     152      <Processor>TextureProcessor</Processor> 
     153      <Options>None</Options> 
     154      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_4.xnb</Output> 
     155      <Time>2014-07-23T10:17:37.7815917+03:00</Time> 
     156    </Item> 
     157    <Item> 
     158      <Source>Clear.png</Source> 
     159      <Name>Clear</Name> 
     160      <Importer>TextureImporter</Importer> 
     161      <Processor>TextureProcessor</Processor> 
     162      <Options>None</Options> 
     163      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Clear.xnb</Output> 
     164      <Time>2014-07-23T10:21:25.007312+03:00</Time> 
     165    </Item> 
     166    <Item> 
     167      <Source>heart.jpg</Source> 
     168      <Name>heart</Name> 
     169      <Importer>TextureImporter</Importer> 
     170      <Processor>TextureProcessor</Processor> 
     171      <Options>None</Options> 
     172      <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\heart.xnb</Output> 
     173      <Time>2014-07-23T10:48:27.5205471+03:00</Time> 
    120174    </Item> 
    121175    <BuildSuccessful>true</BuildSuccessful> 
  • 2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/Peli.csproj.FileListAbsolute.txt

    r5540 r5574  
    2020C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Stonewall.xnb 
    2121C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Slime.xnb 
     22C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_1.xnb 
     23C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_2.xnb 
     24C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_3.xnb 
     25C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Fireball_4.xnb 
     26C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Clear.xnb 
     27C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\heart.xnb 
  • 2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/cachefile-{2D86B228-748C-44C7-93B1-DCBD6910317C}-targetpath.txt

    r5540 r5574  
    1212Content\Stonewall.xnb 
    1313Content\Slime.xnb 
     14Content\Fireball_1.xnb 
     15Content\Fireball_2.xnb 
     16Content\Fireball_3.xnb 
     17Content\Fireball_4.xnb 
     18Content\Clear.xnb 
     19Content\heart.xnb 
  • 2014/30/AtteB/Peli/Peli/PeliContent/PeliContent.contentproj

    r5540 r5574  
    130130    </Compile> 
    131131  </ItemGroup> 
     132  <ItemGroup> 
     133    <Compile Include="Fireball_1.png"> 
     134      <Name>Fireball_1</Name> 
     135      <Importer>TextureImporter</Importer> 
     136      <Processor>TextureProcessor</Processor> 
     137    </Compile> 
     138    <Compile Include="Fireball_2.png"> 
     139      <Name>Fireball_2</Name> 
     140      <Importer>TextureImporter</Importer> 
     141      <Processor>TextureProcessor</Processor> 
     142    </Compile> 
     143    <Compile Include="Fireball_3.png"> 
     144      <Name>Fireball_3</Name> 
     145      <Importer>TextureImporter</Importer> 
     146      <Processor>TextureProcessor</Processor> 
     147    </Compile> 
     148    <Compile Include="Fireball_4.png"> 
     149      <Name>Fireball_4</Name> 
     150      <Importer>TextureImporter</Importer> 
     151      <Processor>TextureProcessor</Processor> 
     152    </Compile> 
     153  </ItemGroup> 
     154  <ItemGroup> 
     155    <Compile Include="Clear.png"> 
     156      <Name>Clear</Name> 
     157      <Importer>TextureImporter</Importer> 
     158      <Processor>TextureProcessor</Processor> 
     159    </Compile> 
     160  </ItemGroup> 
     161  <ItemGroup> 
     162    <Compile Include="heart.jpg"> 
     163      <Name>heart</Name> 
     164      <Importer>TextureImporter</Importer> 
     165      <Processor>TextureProcessor</Processor> 
     166    </Compile> 
     167  </ItemGroup> 
    132168  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    133169  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2014/30/AtteB/Peli/Peli/PeliContent/kentta1.txt

    r5540 r5574  
    66????? 
    77?????? 
    8 ???????..............?.....?. 
     8???????......H.......?.....?. 
    99????????.............?..S..?.                                   
    1010########################################################### 
Note: See TracChangeset for help on using the changeset viewer.