Changeset 6151


Ignore:
Timestamp:
2015-06-22 22:19:49 (4 years ago)
Author:
sieerinn
Message:
 
Location:
2015/26/ohjaajat/HillbillyRun/HillbillyRun
Files:
1 added
4 edited

Legend:

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

    r6148 r6151  
    1414        : base(leveys, korkeus) 
    1515    { 
    16          
     16 
    1717    } 
    1818} 
     
    3434 
    3535    private Image groundImage = LoadImage("ground"); 
     36    private Image groundTopImage = LoadImage("ground_top"); 
    3637 
    3738    public override void Begin() 
     
    4142 
    4243        Camera.X = cameraTargetX = players[0].X; 
     44 
     45        Timer cameraTimer = new Timer(); 
     46        cameraTimer.Interval = 1 / 30.0; 
     47        cameraTimer.Timeout += UpdateCamera; 
     48        cameraTimer.Start(); 
    4349    } 
    4450 
     
    5460        TileMap level = TileMap.FromLevelAsset("level1"); 
    5561        level.SetTileMethod('P', CreatePlayer); 
    56         level.SetTileMethod('#', CreateGround); 
    57         level.Optimize('#'); 
     62        level.SetTileMethod('#', CreateGroundTop); 
     63        level.SetTileMethod('%', CreateGround); 
     64        level.Optimize('#', '%'); 
    5865        level.Execute(TILE_SIZE, TILE_SIZE); 
    59         Level.CreateBorders(true); 
     66        //Level.CreateBorders(true); 
    6067 
    6168        SetControls(); 
     
    7279    } 
    7380 
     81    void CreateGroundTop(Vector position, double width, double height) 
     82    { 
     83        // Puolet pienempi näkymätön palikka alla johon törmää. 
     84        PhysicsObject ground = PhysicsObject.CreateStaticObject(width, height / 2.0); 
     85        ground.IsVisible = false; 
     86        ground.Position = position - new Vector(0.0, TILE_SIZE / 4.0); 
     87        Add(ground); 
     88 
     89        // Maanpinnan näkyvä osa. 
     90        GameObject visibleGround = new GameObject(width, height); 
     91        visibleGround.Image = groundImage; 
     92        visibleGround.Position = position; 
     93        visibleGround.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 
     94        Add(visibleGround, -1); 
     95    } 
     96 
    7497    void CreateGround(Vector position, double width, double height) 
    7598    { 
    76         PhysicsObject ground = PhysicsObject.CreateStaticObject(width, height); 
    77         ground.Image = groundImage; 
     99        GameObject ground = new GameObject(width, height); 
     100        ground.Image = groundTopImage; 
    78101        ground.Position = position; 
    79102        ground.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 
     
    100123    } 
    101124 
    102     protected override void Update(Time time) 
     125    void UpdateCamera() 
    103126    { 
    104127        double minX = players.Min(p => p.X) + cameraOffset; 
    105128        cameraTargetX = Math.Max(cameraTargetX, minX); 
    106         Camera.X += (cameraTargetX - Camera.X) * time.SinceLastUpdate.TotalSeconds * cameraSpeed; 
    107129 
    108130        double windowMax = Camera.ScreenToWorld(new Vector(Window.Width / 2.0, 0)).X; 
     
    113135            player.Right = Math.Min(player.Right, windowMax); 
    114136        } 
     137    } 
     138 
     139    protected override void Update(Time time) 
     140    { 
     141        Camera.X += (cameraTargetX - Camera.X) * time.SinceLastUpdate.TotalSeconds * cameraSpeed; 
    115142 
    116143        base.Update(time); 
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/HillbillyRunContent.contentproj

    r6148 r6151  
    6060    </Compile> 
    6161  </ItemGroup> 
     62  <ItemGroup> 
     63    <Compile Include="ground_top.png"> 
     64      <Name>ground_top</Name> 
     65      <Importer>TextureImporter</Importer> 
     66      <Processor>TextureProcessor</Processor> 
     67    </Compile> 
     68  </ItemGroup> 
    6269  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    6370  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/level1.txt

    r6147 r6151  
    33                                                  
    44                P       P                                                                                
    5 ######################################################################################################### 
     5############################### 
     6%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     7%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%########################## 
     8%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
Note: See TracChangeset for help on using the changeset viewer.