Changeset 5872 for 2015


Ignore:
Timestamp:
2015-06-04 23:21:37 (8 years ago)
Author:
sieerinn
Message:

random huoneen lattia textuuri ja huoneen randomisoinnin aloitus.

Location:
2015/23/HenriK/dungeoncrawlar/dungeoncrawlar
Files:
22 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • 2015/23/HenriK/dungeoncrawlar/dungeoncrawlar/dungeoncrawlar/dungeoncrawlar.cs

    r5865 r5872  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
     8class Pelihahmo : PhysicsObject 
     9{ 
     10    private IntMeter elamaLaskuri; 
     11    public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 
     12 
     13    public Pelihahmo(double leveys, double korkeus, int elämät) 
     14        : base(leveys, korkeus) 
     15    { 
     16        elamaLaskuri = new IntMeter(elämät, 0, elämät); 
     17         
     18    } 
     19} 
    820 
    921public class dungeoncrawlar : PhysicsGame 
    1022{ 
    1123    PhysicsObject ovi; 
    12     PhysicsObject player; 
     24    Pelihahmo player; 
    1325    PhysicsObject ammus; 
     26    PhysicsObject miekka; 
    1427    PhysicsObject avain; 
    15     PhysicsObject vihollinen; 
     28    PhysicsObject l96wallbuy; 
     29    PhysicsObject wallbuymp5; 
     30    PhysicsObject m1911; 
     31    PhysicsObject thecharacterpistol; 
    1632    PhysicsObject ase96; 
     33    PhysicsObject staminup; 
    1734 
    1835    Listener aseNyt; 
     36    Image[] lattiatext = LoadImages("blackwhitegorund bloody1", "blackwhitegorund bloody2", "blackwhitegorund"); 
     37 
     38    Image[] ruumisvihu = LoadImages("zombi1","zombi2","zombi3", "zombi4", "zombi5", "zombi6", "zombi7"); 
    1939 
    2040    int avaintenLkm; 
    2141    int l96 = 0; 
    22     int kilpi; 
    23  
    24     //Surface alaReuna, vasenReuna, oikeaReuna, yläReuna; 
    25  
    26     //PhysicsObject alaReuna, vasenReuna, oikeaReuna, yläReuna; 
     42    int kilpi = 0; 
     43      
     44 
     45     
    2746 
    2847    public override void Begin() 
    2948    { 
    30             
     49        SmoothTextures = false; 
    3150        luohuone(1); 
    3251         
     
    5473    void PoimiAse(PhysicsObject tormaaja, PhysicsObject tormatty) 
    5574    { 
    56         ase96.Destroy(); 
     75         
    5776        l96 += 1; 
    5877        aseet(); 
    5978    } 
     79    void luoruumis(Vector paikka,Image kuva) 
     80    { 
     81        GameObject ruumis = new GameObject(60*1.5, 60*1.5); 
     82        ruumis.Image = kuva; 
     83        ruumis.Position = paikka; 
     84        Add(ruumis, -1); 
     85        ruumis.MaximumLifetime = TimeSpan.FromSeconds(200); 
     86        ruumis.Animation = new Animation(ruumisvihu); 
     87        ruumis.Animation.FPS = 7; 
     88        ruumis.Animation.Start(); 
     89    } 
    6090    void Vihu(Vector paikka, double leveys, double korkeus) 
    6191    { 
    62         PhysicsObject vihu = new PhysicsObject(20, 20); 
    63         vihu.Position = RandomGen.NextVector(0, 500); 
     92        arvotext(paikka, leveys, korkeus); 
     93        Pelihahmo vihu = new Pelihahmo(50, 50, 20); 
     94        vihu.Position = paikka; 
    6495        vihu.LinearDamping = 0.5; 
    6596        Add(vihu); 
    66         Image c = LoadImage("morko"); 
     97         
     98         
     99        Image c = LoadImage("zombi"); 
    67100        vihu.Shape = Shape.FromImage(c); 
    68101        vihu.Image = c; 
     102        vihu.ElamaLaskuri.LowerLimit += delegate 
     103             
     104        {  
     105            vihu.Destroy(); 
     106            luoruumis(vihu.Position, ruumisvihu[0]); 
     107        }; 
    69108 
    70109        FollowerBrain aivo = new FollowerBrain(player); 
    71         aivo.Speed = 300; 
     110        aivo.Speed = 200; 
    72111        vihu.Brain = aivo; 
     112        vihu.Tag = "vihu"; 
     113        aivo.TurnWhileMoving = true; 
     114        AddCollisionHandler(vihu, "player", vahinko); 
    73115 
    74116        Timer ajastin = new Timer(); 
     
    112154        Keyboard.Listen(Key.D2, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 2); 
    113155        Keyboard.Listen(Key.D3, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 3); 
     156        Keyboard.Listen(Key.D4, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 4); 
     157 
    114158         
    115159         
     
    133177                aseNyt = Mouse.Listen(MouseButton.Left, ButtonState.Down, block, "pum pum"); 
    134178                break; 
     179            case 4: 
     180                aseNyt = Mouse.Listen(MouseButton.Left, ButtonState.Pressed, ammupistol, "pum pum"); 
     181                break; 
    135182        }    
    136183    } 
     
    161208        player.Image = c; 
    162209 
    163         ammus = new PhysicsObject(100.0, 10.0); 
    164         ammus.Shape = Shape.Circle; 
    165         ammus.Color = Color.Gray; 
    166         ammus.Position = player.Position; 
    167         ammus.CollisionIgnoreGroup = 1; 
    168         ammus.Angle = player.Angle; 
    169         Add(ammus); 
    170         Vector impulssi = Vector.FromLengthAndAngle(500, player.Angle); 
    171         ammus.Hit(impulssi); 
    172         ammus.MaximumLifetime = new TimeSpan(2000000); 
     210        miekka = new PhysicsObject(50.0, 5.0); 
     211        miekka.Shape = Shape.Circle; 
     212        miekka.Color = Color.Gray; 
     213        Image y = LoadImage("sword"); 
     214        miekka.Image = y; 
     215        miekka.Position = player.Position + (player.Angle + Angle.FromDegrees(90)).GetVector()*-20 + player.Angle.GetVector()*10; 
     216        miekka.CollisionIgnoreGroup = 1; 
     217        miekka.Angle = player.Angle + Angle.FromDegrees(45); 
     218         
     219        Add(miekka); 
     220        Vector impulssi = Vector.FromLengthAndAngle(50, player.Angle + Angle.FromDegrees(45)); 
     221        miekka.Hit(impulssi); 
     222        miekka.MaximumLifetime = new TimeSpan(2000000); 
     223        AddCollisionHandler(miekka, "vihu", vahinko); 
    173224 
    174225    } 
     
    181232         
    182233         
     234 
     235        ammus = new PhysicsObject(5.0, 5.0); 
     236        ammus.Shape = Shape.Circle; 
     237        ammus.Color = Color.Gold; 
     238        ammus.Position = player.Position; 
     239        ammus.CollisionIgnoreGroup = 1; 
     240        Image d = LoadImage("bullet"); 
     241        ammus.Shape = Shape.FromImage(d); 
     242        ammus.Image = d; 
     243        ammus.Angle = player.Angle; 
     244        ammus.Tag = "ammus"; 
     245        Add(ammus); 
     246 
     247        Vector impulssi = Vector.FromLengthAndAngle(2500, player.Angle); 
     248        ammus.Hit(impulssi); 
     249        ammus.MaximumLifetime = new TimeSpan(20000000); 
     250 
     251        AddCollisionHandler(ammus, "vihu", vahinko); 
     252         
     253    } 
     254    void ammupistol() 
     255    { 
     256 
     257        Image i = LoadImage("thecharacterpistol"); 
     258        player.Shape = Shape.FromImage(i); 
     259        player.Image = i; 
     260 
     261 
    183262 
    184263        ammus = new PhysicsObject(10.0, 10.0); 
     
    197276        ammus.Hit(impulssi); 
    198277        ammus.MaximumLifetime = new TimeSpan(20000000); 
    199          
    200     } 
    201  
    202      
     278        AddCollisionHandler(ammus, "vihu", vahinko); 
     279 
     280    } 
     281    void vahinko(PhysicsObject ammus,PhysicsObject vihu  ) 
     282    { 
     283        Pelihahmo hahmo = vihu as Pelihahmo; 
     284        if(hahmo != null) 
     285        { 
     286            hahmo.ElamaLaskuri.Value -= 10; 
     287        } 
     288 
     289    } 
     290 
    203291    void luohuone(int huoneNumero) 
    204292    { 
    205         Window.Width = 1350; 
    206         Window.Height = 850; 
     293        Window.Width = 800; 
     294        Window.Height = 800; 
    207295        Camera.Zoom(0.5); 
    208         Image b = LoadImage("blackwhitegorund"); 
    209  
    210          
    211          
    212          
    213         TileMap ruudut = TileMap.FromLevelAsset("mapeasy lol"); 
    214  
     296 
     297        
     298        //Level.Background.Image = lattiatext[0]; 
     299        //Level.Background.TileToLevel(); 
     300 
     301         
     302         
     303         
     304        TileMap ruudut = TileMap.FromLevelAsset("huone" + huoneNumero); 
     305        TileMap ruudut2 = TileMap.FromLevelAsset("huone" + huoneNumero); 
     306 
     307         
     308            
     309         
     310        //3. Execute luo kentän 
     311        //   Parametreina leveys ja korkeus 
     312         
    215313         
    216314        ruudut.SetTileMethod('p', LuoPelaaja); 
    217315        ruudut.SetTileMethod('w', LuoTaso); 
    218         ruudut.SetTileMethod('h', LuoOvi, Angle.FromDegrees(0)); 
    219         ruudut.SetTileMethod('u', LuoOvi, Angle.FromDegrees(90)); 
    220316        ruudut.SetTileMethod('k', LuoOvi, Angle.FromDegrees(180)); 
    221         ruudut.SetTileMethod('m', LuoOvi, Angle.FromDegrees(270)); 
     317        ruudut.SetTileMethod('u', LuoOvi, Angle.FromDegrees(180)); 
     318        ruudut.SetTileMethod('h', LuoOvi, Angle.FromDegrees(180)); 
     319        ruudut.SetTileMethod('m', LuoOvi, Angle.FromDegrees(180)); 
    222320        ruudut.SetTileMethod('r', luoAvain); 
    223          
     321        ruudut.SetTileMethod('t', LuoL96wallbuy); 
     322        ruudut.SetTileMethod('y', luowallbuymp5); 
     323        //ruudut.SetTileMethod('i', luom1911); 
     324        ruudut.SetTileMethod('s', Staminup); 
     325        ruudut.SetTileMethod('_', arvotext); 
     326 
    224327        ruudut.SetTileMethod('a', LuoAse96); 
    225          
    226         //3. Execute luo kentän 
    227         //   Parametreina leveys ja korkeus 
     328        ruudut2.SetTileMethod('v', Vihu); 
    228329        ruudut.Execute(64, 64); 
    229  
    230         TileMap ruudut2 = TileMap.FromLevelAsset("mapeasy lol"); 
    231         ruudut2.SetTileMethod('v', Vihu); 
    232330        ruudut2.Execute(64, 64); 
    233         Level.Background.Image = b; 
    234         Level.Background.TileToLevel(); 
    235  
     331        Random r = new Random(345356346); 
     332        r.NextDouble(); 
     333        r.NextDouble(); 
    236334 
    237335        Camera.StayInLevel = true; 
     
    262360             
    263361    } 
     362 
     363    void arvotext(Vector paikka, double leveys, double korkeus) 
     364    { 
     365        GameObject taso = new GameObject(leveys, korkeus); 
     366        taso.Position = paikka; 
     367        //taso.CollisionIgnoreGroup = 1; 
     368        if (RandomGen.NextDouble(0, 100) < 95) 
     369        { 
     370            taso.Image = lattiatext[2]; 
     371        } 
     372        else 
     373        { 
     374            int x = RandomGen.NextInt(2); 
     375            taso.Image = lattiatext[x]; 
     376        } 
     377 
     378 
     379 
     380 
     381         
     382        Add(taso, -2); 
     383    } 
    264384    void LuoTaso(Vector paikka, double leveys, double korkeus) 
    265385    { 
     
    275395    void luoAvain(Vector paikka, double leveys, double korkeus) 
    276396    { 
     397        arvotext(paikka, leveys, korkeus); 
    277398        if (RandomGen.NextDouble(0, 100) < 80) 
    278399        { 
     
    292413    void OvenAvaus(PhysicsObject tormaaja, PhysicsObject ovi) 
    293414    { 
    294         if (avaintenLkm >= 1) 
     415        if (Keyboard.GetKeyState(Key.E)==ButtonState.Down) 
    295416        { 
    296417            ClearAll(); 
    297             luohuone(1); 
     418            luohuone(2); 
    298419 
    299420 
     
    302423    void LuoPelaaja(Vector paikka, double leveys, double korkeus) 
    303424    { 
    304         player = new PhysicsObject(50, 50); 
     425        arvotext(paikka, leveys, korkeus); 
     426        player = new Pelihahmo(45, 50, 10); 
    305427        Image c = LoadImage("thecharacter"); 
    306428        player.Shape = Shape.FromImage(c); 
    307429        player.Image = c; 
     430        player.ElamaLaskuri.LowerLimit += delegate 
     431        { 
     432            player.Destroy(); 
     433            luoruumis(player.Position, ruumisvihu[0]); 
     434        }; 
    308435         
    309436        //player. 
     
    312439        player.LinearDamping = 0.6; 
    313440        player.AngularDamping = 0.6; 
     441        player.CollisionIgnoreGroup = 1; 
    314442         
    315443        player.MaxAngularVelocity = 8000.0; 
     
    317445        player.Mass = 1; 
    318446        Add(player); 
     447        player.Tag="player"; 
    319448        AddCollisionHandler(player, "avain", AvaintenKerays); 
    320449        AddCollisionHandler(player, "ovi", OvenAvaus); 
    321         AddCollisionHandler(player, "ase96", PoimiAse); 
     450        AddCollisionHandler(player, "l96wallbuy", PoimiAse); 
     451         
     452 
     453         
     454         
     455         
    322456 
    323457        //player.CollisionIgnoreGroup = 1; 
     
    370504 
    371505    } 
     506    void LuoL96wallbuy(Vector paikka, double leveys, double korkeus) 
     507    { 
     508        PhysicsObject l96wallbuy = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     509        l96wallbuy.Position = paikka; 
     510        Image t = LoadImage("l96wallbuy"); 
     511 
     512        l96wallbuy.Image = t; 
     513        l96wallbuy.Tag = "l96wallbuy"; 
     514 
     515 
     516 
     517        Add(l96wallbuy); 
     518         
     519 
     520 
     521    } 
     522    void luowallbuymp5(Vector paikka, double leveys, double korkeus) 
     523    { 
     524        PhysicsObject wallbuymp5 = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     525        wallbuymp5.Position = paikka; 
     526        Image y = LoadImage("wallbuymp5"); 
     527 
     528        wallbuymp5.Image = y; 
     529        wallbuymp5.Tag = "wallbuymp5"; 
     530 
     531 
     532 
     533        Add(wallbuymp5); 
     534 
     535 
     536    } 
     537    void Staminup(Vector paikka, double leveys, double korkeus) 
     538    { 
     539        arvotext(paikka, leveys, korkeus); 
     540        PhysicsObject staminup = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     541        staminup.Position = paikka; 
     542        Image s = LoadImage("staminup"); 
     543 
     544        staminup.Image = s; 
     545        staminup.Tag = "staminup"; 
     546 
     547 
     548        Add(staminup); 
     549 
     550 
     551    } 
    372552 
    373553} 
  • 2015/23/HenriK/dungeoncrawlar/dungeoncrawlar/dungeoncrawlarContent/dungeoncrawlarContent.contentproj

    r5865 r5872  
    9595  </ItemGroup> 
    9696  <ItemGroup> 
    97     <Compile Include="mapeasy lol.txt"> 
    98       <Name>mapeasy lol</Name> 
     97    <Compile Include="huone1.txt"> 
     98      <Name>huone1</Name> 
    9999      <Importer>TextFileImporter</Importer> 
    100100      <Processor>TextFileContentProcessor</Processor> 
     
    139139    <Compile Include="raygun.png"> 
    140140      <Name>raygun</Name> 
     141      <Importer>TextureImporter</Importer> 
     142      <Processor>TextureProcessor</Processor> 
     143    </Compile> 
     144  </ItemGroup> 
     145  <ItemGroup> 
     146    <Compile Include="zombi.png"> 
     147      <Name>zombi</Name> 
     148      <Importer>TextureImporter</Importer> 
     149      <Processor>TextureProcessor</Processor> 
     150    </Compile> 
     151  </ItemGroup> 
     152  <ItemGroup> 
     153    <Compile Include="Untitled.png"> 
     154      <Name>Untitled</Name> 
     155      <Importer>TextureImporter</Importer> 
     156      <Processor>TextureProcessor</Processor> 
     157    </Compile> 
     158  </ItemGroup> 
     159  <ItemGroup> 
     160    <Compile Include="zombi1.png"> 
     161      <Name>zombi1</Name> 
     162      <Importer>TextureImporter</Importer> 
     163      <Processor>TextureProcessor</Processor> 
     164    </Compile> 
     165    <Compile Include="zombi2.png"> 
     166      <Name>zombi2</Name> 
     167      <Importer>TextureImporter</Importer> 
     168      <Processor>TextureProcessor</Processor> 
     169    </Compile> 
     170    <Compile Include="zombi3.png"> 
     171      <Name>zombi3</Name> 
     172      <Importer>TextureImporter</Importer> 
     173      <Processor>TextureProcessor</Processor> 
     174    </Compile> 
     175    <Compile Include="zombi4.png"> 
     176      <Name>zombi4</Name> 
     177      <Importer>TextureImporter</Importer> 
     178      <Processor>TextureProcessor</Processor> 
     179    </Compile> 
     180    <Compile Include="zombi5.png"> 
     181      <Name>zombi5</Name> 
     182      <Importer>TextureImporter</Importer> 
     183      <Processor>TextureProcessor</Processor> 
     184    </Compile> 
     185    <Compile Include="zombi6.png"> 
     186      <Name>zombi6</Name> 
     187      <Importer>TextureImporter</Importer> 
     188      <Processor>TextureProcessor</Processor> 
     189    </Compile> 
     190    <Compile Include="zombi7.png"> 
     191      <Name>zombi7</Name> 
     192      <Importer>TextureImporter</Importer> 
     193      <Processor>TextureProcessor</Processor> 
     194    </Compile> 
     195  </ItemGroup> 
     196  <ItemGroup> 
     197    <Compile Include="sword.png"> 
     198      <Name>sword</Name> 
     199      <Importer>TextureImporter</Importer> 
     200      <Processor>TextureProcessor</Processor> 
     201    </Compile> 
     202  </ItemGroup> 
     203  <ItemGroup> 
     204    <Compile Include="thecharacterpistol.png"> 
     205      <Name>thecharacterpistol</Name> 
     206      <Importer>TextureImporter</Importer> 
     207      <Processor>TextureProcessor</Processor> 
     208    </Compile> 
     209  </ItemGroup> 
     210  <ItemGroup> 
     211    <Compile Include="playertwo.png"> 
     212      <Name>playertwo</Name> 
     213      <Importer>TextureImporter</Importer> 
     214      <Processor>TextureProcessor</Processor> 
     215    </Compile> 
     216    <Compile Include="wallbuyassaultrifle.png"> 
     217      <Name>wallbuyassaultrifle</Name> 
     218      <Importer>TextureImporter</Importer> 
     219      <Processor>TextureProcessor</Processor> 
     220    </Compile> 
     221    <Compile Include="wallbuymp5.png"> 
     222      <Name>wallbuymp5</Name> 
     223      <Importer>TextureImporter</Importer> 
     224      <Processor>TextureProcessor</Processor> 
     225    </Compile> 
     226    <Compile Include="wallbuyshotgun.png"> 
     227      <Name>wallbuyshotgun</Name> 
     228      <Importer>TextureImporter</Importer> 
     229      <Processor>TextureProcessor</Processor> 
     230    </Compile> 
     231  </ItemGroup> 
     232  <ItemGroup> 
     233    <Compile Include="l96wallbuy.png"> 
     234      <Name>l96wallbuy</Name> 
     235      <Importer>TextureImporter</Importer> 
     236      <Processor>TextureProcessor</Processor> 
     237    </Compile> 
     238  </ItemGroup> 
     239  <ItemGroup> 
     240    <Compile Include="staminup.png"> 
     241      <Name>staminup</Name> 
     242      <Importer>TextureImporter</Importer> 
     243      <Processor>TextureProcessor</Processor> 
     244    </Compile> 
     245  </ItemGroup> 
     246  <ItemGroup> 
     247    <Compile Include="m1911.png"> 
     248      <Name>m1911</Name> 
     249      <Importer>TextureImporter</Importer> 
     250      <Processor>TextureProcessor</Processor> 
     251    </Compile> 
     252  </ItemGroup> 
     253  <ItemGroup> 
     254    <Compile Include="huone2.txt"> 
     255      <Name>huone2</Name> 
     256      <Importer>TextFileImporter</Importer> 
     257      <Processor>TextFileContentProcessor</Processor> 
     258    </Compile> 
     259  </ItemGroup> 
     260  <ItemGroup> 
     261    <Compile Include="blackwhitegorund bloody1.png"> 
     262      <Name>blackwhitegorund bloody1</Name> 
     263      <Importer>TextureImporter</Importer> 
     264      <Processor>TextureProcessor</Processor> 
     265    </Compile> 
     266    <Compile Include="blackwhitegorund bloody2.png"> 
     267      <Name>blackwhitegorund bloody2</Name> 
    141268      <Importer>TextureImporter</Importer> 
    142269      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.