Changeset 3041 for 2012/24


Ignore:
Timestamp:
2012-06-14 15:15:36 (11 years ago)
Author:
tovalile
Message:

Talletus.

Location:
2012/24/ToniV
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • 2012/24/ToniV/Try to survive/Try to survive/Try to survive/Try to survive.csproj

    r2998 r3041  
    6262  </PropertyGroup> 
    6363  <ItemGroup> 
    64     <Reference Include="Jypeli4"> 
     64    <Reference Include="Jypeli"> 
     65      <HintPath>..\..\..\Jypeli.dll</HintPath> 
    6566    </Reference> 
    6667    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> 
  • 2012/24/ToniV/Try to survive/Try to survive/Try to survive/Try_to_survive.cs

    r2998 r3041  
    77using Jypeli.Widgets; 
    88 
     9class Zombi : PhysicsObject 
     10{ 
     11    public int Elamat = 2; 
     12 
     13    public Zombi(double leveys, double korkeus) 
     14        : base(leveys, korkeus) 
     15    { 
     16    } 
     17} 
     18 
     19 
    920public class Try_to_survive : PhysicsGame 
    1021{ 
     
    1223    Image Zombikuva = LoadImage("Zombi"); 
    1324 
    14     PhysicsObject ukko; 
     25    public PhysicsObject ukko; 
     26    int healt = 5; 
    1527 
    16     Vector[] pisteet = { new Vector(600, 470), new Vector(600, -470), new Vector(-600, 470), new Vector(-600, -470) }; 
     28    bool saakoampua = true; 
     29 
     30    Vector[] pisteet = { new Vector(600, 470), new Vector(600, -470), new Vector(0, 470), new Vector(-600,-450) }; 
     31    Vector suunta = Vector.Zero; 
    1732 
    1833    public override void Begin() 
    1934    { 
    2035        ukko = new PhysicsObject(40.0, 40.0); 
    21  
    2236        ukko.Image = ukkokuva; 
     37        ukko.Mass = 1; 
    2338        Add(ukko); 
    2439 
    2540        luoajastin(); 
    2641        luoohjain(); 
    27         rajahda(); 
     42 
     43        luoseina(400, 190, 24, 400); 
     44        luoseina(400, -280, 24, 250); 
     45        luoseina(-400, -10, 200, 700); 
     46        luoseina(-100, -0, 40, 700); 
     47        luoseina(220, 2, 350, 24); 
     48        luoseina(215, -167, 350, 24); 
    2849 
    2950 
     51        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     52        ControllerOne.Listen(Button.Start, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    3053 
     54        Level.Width = 1250; 
     55        Level.Height = 1000; 
     56        PhysicsObject alareuna = Level.CreateBottomBorder(); 
     57        PhysicsObject yläreuna = Level.CreateTopBorder(); 
     58        PhysicsObject vasenreuna = Level.CreateLeftBorder(); 
     59        PhysicsObject oikeareuna = Level.CreateRightBorder(); 
    3160 
    32         PhysicsObject seinä = new PhysicsObject(24, 400); 
    33         seinä.Color = Color.Black; 
    34         seinä.X = (400); 
    35         seinä.Y = (190); 
    36         Add(seinä); 
     61        alareuna.Tag = "reuna"; 
     62        yläreuna.Tag = "reuna"; 
     63        vasenreuna.Tag = "reuna"; 
     64        oikeareuna.Tag = "reuna"; 
     65         
     66    } 
    3767 
    38  
    39         PhysicsObject seinä2 = new PhysicsObject(24, 250); 
    40         seinä2.Color = Color.Black; 
    41         seinä2.X = (400); 
    42         seinä2.Y = (-280); 
    43         Add(seinä2); 
    44  
    45         PhysicsObject seinä3 = new PhysicsObject(200, 700); 
    46         seinä3.Color = Color.Black; 
    47         seinä3.X = (-400); 
    48         seinä3.Y = (-10); 
    49         Add(seinä3); 
    50  
    51         PhysicsObject seinä4 = new PhysicsObject(40, 700); 
    52         seinä4.Color = Color.Black; 
    53         seinä4.X = (-100); 
    54         seinä4.Y = (-0); 
    55         Add(seinä4); 
    56  
    57  
    58         PhysicsObject seinä5 = new PhysicsObject(350, 24); 
    59         seinä5.Color = Color.Black; 
    60         seinä5.X = (220); 
    61         seinä5.Y = (2); 
    62         Add(seinä5); 
    63  
    64         PhysicsObject seinä6 = new PhysicsObject(350, 24); 
    65         seinä6.Color = Color.Black; 
    66         seinä6.X = (215); 
    67         seinä6.Y = (-167); 
    68         Add(seinä6); 
    69  
    70         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    71         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     68    void luoZombi() 
     69    { 
     70        FollowerBrain seuraajanaivot = new FollowerBrain(ukko); 
     71        Zombi Zombi2 = new Zombi(40, 40); 
     72        Zombi2.Position = pisteet[RandomGen.NextInt(0, 4)]; 
     73        Zombi2.Image = Zombikuva; 
     74        Zombi2.Brain = seuraajanaivot; 
     75        Zombi2.Tag = "Zombi"; 
     76        seuraajanaivot.Speed = 100; 
     77        seuraajanaivot.TargetFollowDistance = 60000; 
     78        seuraajanaivot.FollowAlways = true; 
     79        seuraajanaivot.TargetCloseDistance = 0; 
     80        Add(Zombi2); 
     81        AddCollisionHandler(Zombi2, ukko, pelaajaanosui); 
    7282 
    7383 
     
    7585    } 
    7686 
    77  
    78     void luoZombi() 
     87    void luoseina(double X, double Y, double leveys, double korkeus) 
    7988    { 
    80         FollowerBrain seuraajanaivot = new FollowerBrain(); 
    81         PhysicsObject Zombi = new PhysicsObject(40, 40); 
    82         Zombi.Position = pisteet[RandomGen.NextInt(0, 4)]; 
    83         Zombi.Image = Zombikuva; 
    84         Zombi.Brain = seuraajanaivot; 
    85         seuraajanaivot.Speed = 300; 
    86         seuraajanaivot.TargetFollowDistance = 600000; 
    87         seuraajanaivot.FollowAlways = true; 
    88         seuraajanaivot.TargetCloseDistance = 0; 
    89  
    90         Add(Zombi); 
    91  
     89        PhysicsObject seinä = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     90        seinä.Color = Color.Black; 
     91        seinä.X = (X); 
     92        seinä.Y = (Y); 
     93        seinä.Tag = "seina"; 
     94        Add(seinä); 
    9295    } 
    9396 
     
    9699 
    97100        Timer ajastin = new Timer(); 
    98         ajastin.Interval = 0.7; 
     101        ajastin.Interval = 0.1; 
    99102        ajastin.Timeout += luoZombi; 
    100         ajastin.Start(); 
     103        ajastin.Start(200); 
    101104 
    102105 
     
    106109    { 
    107110        ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, liikutapelaajaa, "liiku"); 
     111        ControllerOne.ListenAnalog(AnalogControl.RightStick, 0.1, tahtaa, "tähtää"); 
     112        ControllerOne.Listen(Button.RightTrigger, ButtonState.Down, ammu, "ammu"); 
    108113    } 
    109114 
    110115    void liikutapelaajaa(AnalogState tikku) 
    111116    { 
    112         ukko.Move(tikku.StateVector * 170); 
     117        ukko.Move(tikku.StateVector * 150); 
     118    } 
     119 
     120    void tahtaa(AnalogState tikku) 
     121    { 
     122        suunta = tikku.StateVector; 
     123    } 
     124 
     125    void ammu() 
     126    { 
     127        if (saakoampua == false) return; 
     128        PhysicsObject panos = new PhysicsObject(5, 5); 
     129        panos.Shape = Shape.Circle; 
     130        panos.Color = Color.Black; 
     131        panos.Hit(suunta * 1100); 
     132        panos.Position = ukko.Position; 
     133        AddCollisionHandler(panos, "Zombi", Zombikuoli); 
     134        AddCollisionHandler(panos, "seina", TuhoaAmmus); 
     135        AddCollisionHandler(panos, "reuna", TuhoaAmmus); 
     136        Add(panos); 
     137 
     138        saakoampua = false; 
     139        Timer.SingleShot(0.25, saaampua); 
     140    } 
     141 
     142    void saaampua() 
     143    { 
     144        saakoampua = true; 
     145    } 
     146    void TuhoaAmmus(PhysicsObject panos, PhysicsObject kohde) 
     147    { 
     148        panos.Destroy(); 
     149    } 
     150 
     151    void pelaajaanosui(PhysicsObject pelaaja, PhysicsObject zombi) 
     152    { 
     153        healt--; 
     154        if (healt == 0) 
     155        { 
     156            ukko.Destroy(); 
     157            rajahda(); 
     158        } 
     159    } 
     160 
     161    void Zombikuoli(PhysicsObject panos, PhysicsObject kohde) 
     162    { 
     163        panos.Destroy(); 
     164        Zombi Zombi2 = kohde as Zombi; 
     165 
     166        if (Zombi2 == null) return; 
     167 
     168        Zombi2.Elamat--; 
     169        if (Zombi2.Elamat == 0) 
     170        { 
     171            Zombi2.Destroy(); 
     172 
     173        } 
    113174    } 
    114175 
    115176    void rajahda() 
    116177    { 
    117         Explosion rajahdys = new Explosion( 40 ); 
     178        Explosion rajahdys = new Explosion(50); 
    118179        rajahdys.Position = ukko.Position; 
    119         rajahdys.Speed = 500.0; 
    120         rajahdys.Force = 10000; 
     180        rajahdys.Speed = 100.0; 
     181        rajahdys.Force = 1000000; 
    121182        rajahdys.ShockwaveColor = Color.Red; 
    122         Add( rajahdys ); 
    123  
     183        Add(rajahdys); 
    124184    } 
    125185 
     186        void kierräeste() 
     187        { 
     188             
     189        } 
    126190} 
  • 2012/24/ToniV/Try to survive/Try to survive/Try to survive/obj/x86/Debug/Try to survive.csproj.FileListAbsolute.txt

    r2998 r3041  
    33C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Try to survive.exe 
    44C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Try to survive.pdb 
    5 C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Jypeli4.dll 
    6 C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Jypeli4.xml 
    75C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\obj\x86\Debug\Try to survive.exe 
    86C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\obj\x86\Debug\Try to survive.pdb 
    97C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Content\ukko.xnb 
    108C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Content\Zombi.xnb 
     9C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Jypeli.dll 
     10C:\MyTemp\ToniV\Try to survive\Try to survive\Try to survive\bin\x86\Debug\Jypeli.xml 
Note: See TracChangeset for help on using the changeset viewer.