Changeset 6207 for 2015


Ignore:
Timestamp:
2015-06-23 20:15:47 (4 years ago)
Author:
empaheik
Message:

Tonkka ja laatikot saivat kuvioita (tosin laatikot kenties liian pieniä).

Location:
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs

    r6203 r6207  
    88using Jypeli.Widgets; 
    99 
     10/* Muistutuksia. 
     11 *  
     12 * Layerit 
     13 *   3 -  
     14 *   2 -  
     15 *   1 -  
     16 *   0 - 
     17 *  -1 - Näkyvä maanpinta. 
     18 *  -2 - Talot taustalla. 
     19 *   
     20 *  
     21 *  
     22*/ 
     23 
     24 
    1025//Luokka maajussien erikoisuuksille. 
    1126class HillBilly : PlatformCharacter 
     
    3853    private Image[] groundImages = LoadImages("ground");    //Näitä ei tosin kaikkia kenties jaksa tehdä erilaisiksi levelistä riippuen 
    3954    private Image[] groundTopImages = LoadImages("ground_top"); 
    40     private Image[] supportStructureImages = LoadImages(""); 
    41     private Image[] foreGroundDecorations = LoadImages("viljaa"); 
     55    private Image[] foregroundDecorations = LoadImages("viljaa"); 
     56    private Image[] blockImages = LoadImages("box"); 
    4257 
    4358    private Image[] houseImages = LoadImages("house", "houseburned"); 
    4459 
    4560    private Image cartImage = LoadImage("cart"); 
     61    private Image milkImage = LoadImage("tonkka"); 
    4662     
    4763    private Image cartWheelImage = LoadImage("cartwheel"); 
     64 
     65    private Animation crawl; 
    4866    #endregion  
    4967 
     68    private double leftCamLimit; 
     69    private double rightCamLimit; 
     70    private double bottomCamLimit; 
     71 
    5072    private int levelNumber = 0; 
    51  
     73    
    5274    public override void Begin() 
    5375    { 
     
    115137    void StartGame() 
    116138    { 
    117  
     139        Initializing(); 
    118140        CreateLevel(); 
    119141        ScreenSettings(); 
     
    136158    } 
    137159 
     160    void Initializing() 
     161    { 
     162        crawl = LoadAnimation("crawl"); 
     163    } 
     164 
    138165    void ScreenSettings() 
    139166    { 
     
    141168        Window.Height = 900; 
    142169 
    143         Camera.X = cameraTargetX = players[0].X; 
     170        leftCamLimit = Level.Left + Window.Width / 2.0; 
     171        rightCamLimit = Level.Right - Window.Width / 2.0; 
     172        bottomCamLimit = Level.Bottom + Window.Height / 2.0; 
     173 
     174        //Camera.X = cameraTargetX = players[0].X; 
    144175        //Camera.ZoomToLevel(); 
     176        Camera.X = cameraTargetX = leftCamLimit; 
    145177 
    146178        Timer cameraTimer = new Timer(); 
     
    165197        level.SetTileMethod(Color.Rose, CreateDummy, Color.Rose);   //TODO: CreateFlame 
    166198        level.SetTileMethod(Color.Harlequin, CreateCart); 
    167         level.SetTileMethod(Color.White, CreateDummy, Color.White); //TODO: CreateSmoke (optional) 
    168         //level.SetTileMethod(Color.PaintDotNetBlue, CreateDummy, Color.PaintDotNetBlue);  
    169         level.SetTileMethod(Color.DarkGray, CreateDummy, Color.DarkGray);   //TODO: CreateTombStone (optional) 
     199        level.SetTileMethod(Color.White, CreateBlockObject);  
     200        level.SetTileMethod(Color.DarkGray, CreateMilk);    
    170201        level.SetTileMethod(Color.Gray, CreateCrawly);   
    171202        level.SetTileMethod(Color.Red, CreateDummy, Color.Red);    //TODO: CreateWitch 
     
    184215    } 
    185216 
     217    void CreateBlockObject(Vector position, double width, double height) 
     218    { 
     219        PhysicsObject block = PhysicsObject.CreateStaticObject(width, height); 
     220        block.Image = blockImages[levelNumber]; 
     221        block.Position = position; 
     222        Add(block); 
     223    } 
     224 
     225    void CreateMilk(Vector position, double width, double height) 
     226    { 
     227        GameObject milk = new GameObject(milkImage.Width, milkImage.Height); 
     228        milk.Image = milkImage; 
     229        milk.Position = position; 
     230        Add(milk); 
     231    } 
     232 
    186233    void CreateCrawly(Vector position, double width, double height) 
    187234    { 
     
    189236        crawly.Position = position; 
    190237        crawly.Color = Color.Gray; 
     238        crawly.Animation = crawl; 
     239        crawly.Animation.Start(); 
    191240        crawly.CollisionIgnoreGroup = 3; 
    192241        Add(crawly); 
     
    207256        Add(house, -2); 
    208257 
    209         PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width - (TILE_SIZE * 4), 5); 
     258        //Seisottava tasanne 
     259        PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width - (TILE_SIZE * 3.25), 1);     //Tätä kohtaa on nyt vähän hakemalla haettu. 
    210260        platform.IsVisible = false; 
    211         platform.Position = new Vector(house.X + TILE_SIZE, house.Top); 
     261        platform.Position = new Vector(house.X + (TILE_SIZE * 0.5), house.Top); 
    212262        Add(platform); 
    213263    } 
     
    220270        Add(house, -2); 
    221271 
    222         PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width* 0.25, 5); 
     272        PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width* 0.25, 1); 
    223273        platform.IsVisible = false; 
    224274        platform.Position = new Vector(house.X + platform.Width * 0.5, house.Top); 
     
    249299        dummy.Position = position; 
    250300        dummy.Color = color; 
    251         //dummy.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 
    252301        Add(dummy); 
    253302    } 
     
    284333        { 
    285334            GameObject wheatBlock = new GameObject(width * 1.5, height * 3); 
    286             wheatBlock.Image = foreGroundDecorations[0]; 
     335            wheatBlock.Image = foregroundDecorations[0]; 
    287336            wheatBlock.Position = visibleGround.Position; 
    288337            Add(wheatBlock, 2); 
     
    316365    void UpdateCamera() 
    317366    { 
    318  
    319367        double minY = players.Min(p => p.Y); 
    320368        double maxY = players.Max(p => p.Y); 
     
    327375        cameraTarget.X = Math.Max(cameraTargetX, minX);     //Lellllll. 
    328376 
     377        //cameraTarget.Y = Math.Max(cameraTarget.X, Level.Bottom + Window.Height/2.0); 
     378 
    329379        cameraTargetX = Math.Max(cameraTargetX, minX); 
    330380 
     381        cameraTarget.X = Math.Min(cameraTargetX, rightCamLimit); 
     382        cameraTarget.Y = Math.Max(cameraTarget.Y, bottomCamLimit); 
    331383 
    332384        double windowMax = Camera.ScreenToWorld(new Vector(Window.Width / 2.0, 0)).X; 
     
    337389            player.Right = Math.Min(player.Right, windowMax); 
    338390        } 
    339  
    340         //double windowMax = Camera.ScreenToWorld(new Vector(Window.Width / 2.0, 0)).X; 
    341         //double windowMin = Camera.ScreenToWorld(new Vector(-Window.Width / 2.0, 0)).X; 
    342         //foreach (var player in players) 
    343         //{ 
    344         //    player.Left = Math.Max(player.Left, windowMin); 
    345         //    player.Right = Math.Min(player.Right, windowMax); 
    346         //} 
    347391    } 
    348392 
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/HillbillyRunContent.contentproj

    r6202 r6207  
    107107    </Compile> 
    108108  </ItemGroup> 
     109  <ItemGroup> 
     110    <Compile Include="crawl.anim"> 
     111      <Name>crawl</Name> 
     112      <Importer>AnimationImporter</Importer> 
     113      <Processor>AnimationContentProcessor</Processor> 
     114    </Compile> 
     115  </ItemGroup> 
     116  <ItemGroup> 
     117    <Compile Include="tonkka.png"> 
     118      <Name>tonkka</Name> 
     119      <Importer>TextureImporter</Importer> 
     120      <Processor>TextureProcessor</Processor> 
     121    </Compile> 
     122  </ItemGroup> 
     123  <ItemGroup> 
     124    <Compile Include="box.png"> 
     125      <Name>box</Name> 
     126      <Importer>TextureImporter</Importer> 
     127      <Processor>TextureProcessor</Processor> 
     128    </Compile> 
     129  </ItemGroup> 
    109130  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    110131  <!--  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.