Changeset 2377 for 2011/26


Ignore:
Timestamp:
2011-06-30 14:59:50 (12 years ago)
Author:
riroos
Message:

Talletus.

Location:
2011/26/RistoR/ding/ding
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/RistoR/ding/ding/ding/Peli.cs

    r2318 r2377  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
    8 class PeliHahmo : PhysicsObject 
     8 
     9class zombi : PhysicsObject 
    910{ 
    10     public int Elamat = 3; 
    11     public bool OnHidas = false; 
    12     public int KenganNumero = 42; 
    13     public int Rahat = 1000; 
    14     public Vector RespausKoordinaatit = Vector.Zero; 
    15  
    16     public PeliHahmo(double leveys, double korkeus) 
     11    public int elamat = 3; 
     12    public zombi(double leveys, double korkeus) 
    1713        : base(leveys, korkeus) 
    1814    { 
    1915    } 
     16 
    2017} 
    21  
    2218public class Peli : PhysicsGame 
    2319{ 
     
    2521    const double hyppyNopeus = 1000; 
    2622    const int RUUDUN_KOKO = 40; 
    27  
    2823    PlatformCharacter pelaaja1; 
    2924    List<Label> valikonKohdat; 
    3025 
    31     Image pelaajanKuva = LoadImage("norsu"); 
     26    Image paavalikko = LoadImage("paavalikko"); 
     27    Image pelaajanKuva = LoadImage("pelaaja"); 
    3228    Image tahtiKuva = LoadImage("tahti"); 
     29    Image zombikuva = LoadImage("zombikuva"); 
     30    Image pistooli = LoadImage("pistooli"); 
     31    Image maalinkuva = LoadImage("maalinkuva"); 
    3332 
    3433    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    4241        lisaaNappaimet(); 
    4342        luopallo(); 
    44         zombi(); 
    4543        ase(); 
    4644        valikko(); 
     
    4947        Camera.StayInLevel = true; 
    5048    } 
    51  
    5249    void luoKentta() 
    5350    { 
     
    5754        kentta['N'] = lisaaPelaaja; 
    5855        kentta['D'] = lisaavaara; 
     56        kentta['Z'] = lisaazombi; 
     57        kentta['M'] = lisaamaali; 
    5958        kentta.Insert(RUUDUN_KOKO, RUUDUN_KOKO); 
    6059        Level.CreateBorders(); 
    61         Level.Background.CreateGradient(Color.Black, Color.OrangeRed); 
     60        Level.Background.CreateStars(500); 
    6261    } 
    6362    PhysicsObject lisaaTaso() 
     
    7675    PlatformCharacter lisaaPelaaja() 
    7776    { 
    78         pelaaja1 = new PlatformCharacter(35, 35); 
     77        pelaaja1 = new PlatformCharacter(40, 40); 
    7978        pelaaja1.Mass = 4.0; 
    8079        pelaaja1.Image = pelaajanKuva; 
     
    9089        return vaara; 
    9190    } 
     91    PhysicsObject lisaamaali() 
     92    { 
     93        PhysicsObject maali = PhysicsObject.CreateStaticObject(RUUDUN_KOKO, RUUDUN_KOKO); 
     94        maali.Image = maalinkuva; 
     95        maali.Mass = 4.0; 
     96        AddCollisionHandler(maali, MaaliinOsuma); 
     97        return maali; 
     98 
     99    } 
     100    void MaaliinOsuma(PhysicsObject maali, PhysicsObject kohde) 
     101    { 
     102        if (kohde == pelaaja1) 
     103        { 
     104            ClearAll(); 
     105            Voitto(); 
     106 
     107        } 
     108    } 
     109    zombi lisaazombi() 
     110    { 
     111        zombi zombi = new zombi(40.0, 40.0); 
     112        FollowerBrain zombiaivot = new FollowerBrain(); 
     113        zombi.Brain = zombiaivot; 
     114        zombiaivot.Active = true; 
     115        zombi.Image = zombikuva; 
     116        zombi.Mass = 4.0; 
     117        zombi.Color = Color.DarkGreen; 
     118        zombiaivot.Target = pelaaja1; 
     119        zombiaivot.Speed = 150; 
     120        zombi.Tag = "zombi"; 
     121        return zombi; 
     122        { 
     123 
     124        } 
     125 
     126    } 
    92127    void lisaaNappaimet() 
    93128    { 
     
    99134        Keyboard.Listen(Key.Space, ButtonState.Down, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    100135        Keyboard.Listen(Key.Down, ButtonState.Down, AmmuAseella, "Ammu"); 
    101         Keyboard.Listen(Key.W, ButtonState.Down, kaannaasetta,"Käännä asetta ylös"); 
    102         Keyboard.Listen(Key.S, ButtonState.Down, kaannaasetta2, "Käännä asetta alas"); 
     136        Keyboard.Listen(Key.W, ButtonState.Down, kaannaasettaylos, "Käännä asetta ylös"); 
     137        Keyboard.Listen(Key.S, ButtonState.Down, kaannaasettaalas, "Käännä asetta alas"); 
    103138        Keyboard.Listen(Key.Up, ButtonState.Pressed, HeitaKranaatti, "Heitä kranaatti"); 
    104  
    105  
    106139        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    107140 
     
    135168 
    136169        } 
     170        if (kohde.Tag.ToString() == "zombi") 
     171        { 
     172            pelaaja1.Destroy(); 
     173            pistelaskuri.Reset(); 
     174            MessageDisplay.Add("Kuolit, aloita alusta."); 
     175            MessageDisplay.TextColor = Color.Yellow; 
     176            MessageDisplay.MessageTime = new TimeSpan(0, 0, 10); 
     177        } 
     178 
    137179    } 
    138180    void luopallo() 
     
    147189        Add(pallo); 
    148190    } 
    149     void zombi() 
    150     { 
    151         PhysicsObject zombi = new PhysicsObject(40.0,40.0); 
    152         FollowerBrain zombiaivot = new FollowerBrain(); 
    153         zombi.Brain = zombiaivot; 
    154         zombiaivot.Active = true; 
    155         zombi.Color = Color.DarkGreen; 
    156         zombiaivot.Target = pelaaja1; 
    157         zombiaivot.Speed = 150; 
    158         int i = RandomGen.NextInt(1, 100); 
    159         Add(zombi); 
    160     } 
    161191    void ase() 
    162192    { 
    163         pelaaja1.Weapon = new AssaultRifle(35, 20); 
    164         AssaultRifle pyssy = new AssaultRifle(35, 20); 
     193        pelaaja1.Weapon = new AssaultRifle(25, 25); 
     194        AssaultRifle pyssy = new AssaultRifle(25, 25); 
     195        pyssy.Image = pistooli; 
    165196        pyssy.ProjectileCollision = AmmusOsui; 
     197        pyssy.X = pelaaja1.X += 50; 
    166198        pyssy.Ammo.Value = 500; 
    167199        pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 
     
    170202    { 
    171203        PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 
    172  
    173204        if (ammus != null) 
    174205        { 
     
    176207        } 
    177208    } 
    178     void AmmusOsui(PhysicsObject ammus, PhysicsObject taso) 
     209    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
    179210    { 
    180211        ammus.Destroy(); 
     
    182213        rajahdys.Position = ammus.Position; 
    183214        Add(rajahdys); 
    184     } 
    185     void kaannaasetta() 
    186     { 
    187         pelaaja1.Weapon.Angle += Angle.FromDegrees(4); 
    188     } 
    189     void kaannaasetta2() 
    190     { 
    191         pelaaja1.Weapon.Angle += Angle.FromDegrees(-4); 
     215        if (kohde.Tag.ToString() == "zombi") 
     216        { 
     217            zombi vihu = kohde as zombi; 
     218            vihu.elamat -= 1; 
     219            if (vihu.elamat == 0) 
     220            { 
     221                vihu.Destroy(); 
     222                pistelaskuri.Value += 1; 
     223            } 
     224        } 
     225 
     226    } 
     227    void kaannaasettaylos() 
     228    { 
     229        if (pelaaja1.FacingDirection == Direction.Right) 
     230        { 
     231            pelaaja1.Weapon.Angle += Angle.FromDegrees(5); 
     232        } 
     233        if (pelaaja1.FacingDirection == Direction.Left) 
     234        { 
     235            pelaaja1.Weapon.Angle += Angle.FromDegrees(-5); 
     236        } 
     237    } 
     238    void kaannaasettaalas() 
     239    { 
     240        if (pelaaja1.FacingDirection == Direction.Right) 
     241        { 
     242            pelaaja1.Weapon.Angle += Angle.FromDegrees(-5); 
     243        } 
     244        if (pelaaja1.FacingDirection == Direction.Left) 
     245        { 
     246            pelaaja1.Weapon.Angle += Angle.FromDegrees(5); 
     247        } 
     248 
    192249    } 
    193250    void HeitaKranaatti() 
    194251    { 
    195          
     252 
    196253        Grenade kranaatti = new Grenade(4.0); 
    197254        kranaatti.X = pelaaja1.X + 10; 
    198255        kranaatti.Y = pelaaja1.Y + 10; 
    199256        Add(kranaatti); 
    200         Vector heittoVoima = Vector.FromLengthAndAngle(4000, Angle.FromDegrees(45)); 
     257        Vector heittoVoima = Vector.FromLengthAndAngle(4000, pelaaja1.Weapon.Angle); 
    201258        kranaatti.Hit(heittoVoima); 
    202     } 
    203     void valo() 
    204     { 
    205         Level.AmbientLight = 0.3; 
    206  
    207         Light lamppu = new Light(); 
    208         lamppu.Intensity = 0.8; 
    209         lamppu.Distance = 300; 
    210         lamppu.Position = lamppu.Position; 
    211         Add(lamppu); 
    212  
    213     } 
    214     void ajastin() 
    215     { 
    216         Timer ajastin = new Timer(); 
    217         ajastin.Interval = 5.5; 
    218         ajastin.Trigger += tippuvapalikka; 
    219         ajastin.Start(); 
    220  
    221     } 
    222     void tippuvapalikka(Timer ajastin) 
    223     { 
    224         PhysicsObject palikka = new PhysicsObject(20.0, 80.0); 
    225         palikka.Shape = Shape.Rectangle; 
    226         palikka.Color = Color.Purple; 
    227         palikka.X = pelaaja1.X + 120; 
    228         palikka.Y = pelaaja1.Y + 900; 
    229         Add(palikka); 
    230  
    231259    } 
    232260    IntMeter pistelaskuri; 
    233261    void luolaskuri() 
    234         { 
    235             pistelaskuri = new IntMeter(0); 
    236  
    237             Label pisteNaytto = new Label(); 
    238             pisteNaytto.X = Screen.Left + 100; 
    239             pisteNaytto.Y = Screen.Top - 100; 
    240             pisteNaytto.TextColor = Color.Turquoise; 
    241  
    242             pisteNaytto.BindTo(pistelaskuri); 
    243             Add(pisteNaytto); 
    244  
    245             Label pisteTeksti = new Label("Pisteitä: "); 
    246             pisteTeksti.X = Screen.Left + 50; 
    247             pisteTeksti.Y = Screen.Top - 100; 
    248             pisteTeksti.TextColor = Color.SkyBlue; 
    249             Add(pisteTeksti); 
    250             pistelaskuri.Value++; 
    251             pistelaskuri.Value += 1; 
    252             pistelaskuri.Value = pistelaskuri.Value + 1; 
    253             pistelaskuri.Reset(); 
    254             IntMeter laskuri = new IntMeter(0); 
    255             laskuri.MaxValue = 5; 
    256             laskuri.UpperLimit += laskuriYlarajassa; } 
     262    { 
     263        pistelaskuri = new IntMeter(0); 
     264 
     265        Label pisteNaytto = new Label(); 
     266        pisteNaytto.X = Screen.Left + 100; 
     267        pisteNaytto.Y = Screen.Top - 100; 
     268        pisteNaytto.TextColor = Color.Turquoise; 
     269 
     270        pisteNaytto.BindTo(pistelaskuri); 
     271        Add(pisteNaytto); 
     272 
     273        Label pisteTeksti = new Label("Pisteitä: "); 
     274        pisteTeksti.X = Screen.Left + 50; 
     275        pisteTeksti.Y = Screen.Top - 100; 
     276        pisteTeksti.TextColor = Color.SkyBlue; 
     277        Add(pisteTeksti); 
     278        pistelaskuri.Value++; 
     279        pistelaskuri.Value += 1; 
     280        pistelaskuri.Value = pistelaskuri.Value + 1; 
     281        pistelaskuri.Reset(); 
     282        IntMeter laskuri = new IntMeter(0); 
     283        laskuri.MaxValue = 5; 
     284        laskuri.UpperLimit += laskuriYlarajassa; 
     285    } 
    257286    void laskuriYlarajassa(int arvo) 
    258             { 
    259                 MessageDisplay.TextColor = Color.White; 
    260                 MessageDisplay.Add("Pelaaja 1 voitti pelin."); 
    261             } 
     287    { 
     288        MessageDisplay.TextColor = Color.White; 
     289        MessageDisplay.Add("Pelaaja 1 voitti pelin."); 
     290    } 
    262291    void valikko() 
    263292    { 
    264293        ClearAll(); 
     294        Level.Background.Image ("paavalikko"); 
    265295        valikonKohdat = new List<Label>(); 
    266296 
     
    280310        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 
    281311        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
    282          
     312 
    283313        Mouse.IsCursorVisible = true; 
    284314        Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 
     
    301331        } 
    302332    } 
    303  
    304333    void AloitaPeli() 
    305334    { 
     
    310339        lisaaNappaimet(); 
    311340        luopallo(); 
    312         zombi(); 
    313341        ase(); 
    314         ajastin(); 
    315342        Camera.Follow(pelaaja1); 
    316343        Camera.ZoomFactor = 1.2; 
     
    318345        Keyboard.Listen(Key.Escape, ButtonState.Pressed, valikko, "Palaa valikkoon"); 
    319346    } 
    320  
    321  
    322  
     347    void Voitto() 
     348    { 
     349        Label nappi = new Label("Aloita uusi peli"); 
     350        nappi.Position = new Vector(0, 40); 
     351        valikonKohdat.Add(nappi); 
     352 
     353        Label nappi2 = new Label("Lopeta"); 
     354        nappi2.Position = new Vector(0, -40); 
     355        valikonKohdat.Add(nappi2); 
     356        foreach (Label valikonKohta in valikonKohdat) 
     357        { 
     358            Add(valikonKohta); 
     359        } 
     360 
     361        Mouse.ListenOn(nappi, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 
     362        Mouse.ListenOn(nappi2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     363 
     364        Mouse.IsCursorVisible = true; 
     365        Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 
     366        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 
     367 
     368    } 
    323369} 
  • 2011/26/RistoR/ding/ding/ding/kentta1.txt

    r2318 r2377  
    1010          ########## 
    1111          #                                                                                                                      # 
    12           #   *** 
     12          #   ***                                                                                                             Z 
    1313          #   ***                                                                                                       #     # 
    1414#         #   ***                                                                                                  # 
     
    1919#                                                               *                     # 
    2020#                                          #       #           #                # 
    21 #                               #                              #       # 
     21#                               #                              #       #    # 
    2222# 
    23 #       N               ##D 
    24 ################################################DD################################################################################## 
    25 ####################################################################################################################################                                                                                                                                                   *** 
    26 ####################################################################################################################################                                                       *                                                                                     ##################### 
    27 #################################################################################################################################### *                                                     #                                                                                 #########################                                                ** 
    28 #################################################################################################################################### *                                                    ###                                                                           ############################## 
    29 #################################################################################################################################### *                                                   #####                                                                *       ################################             *                              ########### 
    30 #################################################################################################################################### *                                                 #########                                         *                  ##########################################         ######                 *     #### 
    31 #################################################################################################################################### *                                               #############                                     ###############################################################                       *     #### 
    32 #################################################################################################################################### *                                             #################                                ##################################################################                   ########                                     *** 
    33 ######################################################################################################################################                                           #####################                        ########################################################################                                                          ################### 
    34 ######################################################################################################################################################################################################################################################################################################DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 
     23#       N               ## #          Z                Z  Z   Z 
     24##########################D#####################DD######################DDD#DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD#####                                                                                                                                                                                                                                                                           # 
     25####################################################################################################################################                                                                                                                                                   ***                                                                                                                     # 
     26####################################################################################################################################                                                       *                                                                                     #####################                                                                                                         # 
     27#################################################################################################################################### *                                                     #                                                                                 #########################                                                **                                                       # 
     28#################################################################################################################################### *                                                    ###                                                                           ##############################                                                                                                         # 
     29#################################################################################################################################### *                                                   ##### Z                                                               *       ################################             *                              ###########                                                 # 
     30#################################################################################################################################### *                                                 D########                                         *                  ##########################################         ######                 *     ####                                                               # 
     31#################################################################################################################################### *                                               ############# Z                                    ###############################################################                       *     ####                                                   Z                M  # 
     32#################################################################################################################################### *                                             #################                                ##################################################################                   ########                                     ***            ########################### 
     33######################################################################################################################################                 Z                         #####################                        ########################################################################                                                          ###################                            # 
     34######################################################################################################################################################################################################################################################################################################DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD# 
  • 2011/26/RistoR/ding/ding/dingContent/dingContent.contentproj

    r2318 r2377  
    4848      <Processor>SoundEffectProcessor</Processor> 
    4949    </Compile> 
    50     <Compile Include="norsu.png"> 
    51       <Name>norsu</Name> 
     50    <Compile Include="tahti.png"> 
     51      <Name>tahti</Name> 
    5252      <Importer>TextureImporter</Importer> 
    5353      <Processor>TextureProcessor</Processor> 
    5454    </Compile> 
    55     <Compile Include="tahti.png"> 
    56       <Name>tahti</Name> 
     55  </ItemGroup> 
     56  <ItemGroup> 
     57    <Compile Include="pelaaja.png"> 
     58      <Name>pelaaja</Name> 
     59      <Importer>TextureImporter</Importer> 
     60      <Processor>TextureProcessor</Processor> 
     61    </Compile> 
     62  </ItemGroup> 
     63  <ItemGroup> 
     64    <Compile Include="zombikuva.png"> 
     65      <Name>zombikuva</Name> 
     66      <Importer>TextureImporter</Importer> 
     67      <Processor>TextureProcessor</Processor> 
     68    </Compile> 
     69  </ItemGroup> 
     70  <ItemGroup> 
     71    <Compile Include="pistooli.png"> 
     72      <Name>pistooli</Name> 
     73      <Importer>TextureImporter</Importer> 
     74      <Processor>TextureProcessor</Processor> 
     75    </Compile> 
     76  </ItemGroup> 
     77  <ItemGroup> 
     78    <Compile Include="kaupunki.png"> 
     79      <Name>kaupunki</Name> 
     80      <Importer>TextureImporter</Importer> 
     81      <Processor>TextureProcessor</Processor> 
     82    </Compile> 
     83  </ItemGroup> 
     84  <ItemGroup> 
     85    <Compile Include="pelaajahyppy.png"> 
     86      <Name>pelaajahyppy</Name> 
     87      <Importer>TextureImporter</Importer> 
     88      <Processor>TextureProcessor</Processor> 
     89    </Compile> 
     90    <Compile Include="pelaajalaskeutuu.png"> 
     91      <Name>pelaajalaskeutuu</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="maalinkuva.png"> 
     98      <Name>maalinkuva</Name> 
     99      <Importer>TextureImporter</Importer> 
     100      <Processor>TextureProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="paavalikko.png"> 
     105      <Name>paavalikko</Name> 
    57106      <Importer>TextureImporter</Importer> 
    58107      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.