- Timestamp:
- 2015-06-23 19:26:59 (8 years ago)
- Location:
- 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs
r6199 r6202 30 30 31 31 private double cameraTargetX; // Sijainti jossa kameran pitäisi olla. 32 private double cameraOffset = 400; // Tämän voisi ehkä laskea jostain (esim. ikkunan leveydestä kolmasosa tai jotain). 32 private Vector cameraTarget; 33 34 private double cameraOffset = 400; // TODO: Tämän voisi ehkä laskea jostain (esim. ikkunan leveydestä kolmasosa tai jotain). 33 35 private double cameraSpeed = 2.0; // Kameran liikkumisnopeus. 34 36 … … 37 39 private Image[] groundTopImages = LoadImages("ground_top"); 38 40 private Image[] supportStructureImages = LoadImages(""); 41 private Image[] foreGroundDecorations = LoadImages("viljaa"); 39 42 40 43 private Image[] houseImages = LoadImages("house", "houseburned"); … … 138 141 Window.Height = 900; 139 142 140 //Camera.X = cameraTargetX = players[0].X; 141 Camera.ZoomToLevel(); 143 Camera.X = cameraTargetX = players[0].X; 144 Camera.Y = cameraTargetY = players[0].Y; 145 //Camera.ZoomToLevel(); 142 146 143 147 Timer cameraTimer = new Timer(); … … 155 159 level.SetTileMethod(Color.Black, CreateGroundTop); 156 160 level.SetTileMethod(Color.Brown, CreateGround); 161 157 162 level.SetTileMethod(Color.Cyan, CreateHouse); 158 163 level.SetTileMethod(Color.PaintDotNetBlue, CreateBurnedHouse); 164 159 165 level.SetTileMethod(Color.Gold, CreatePlayer); 160 166 level.SetTileMethod(Color.Rose, CreateDummy, Color.Rose); //TODO: CreateFlame 161 167 level.SetTileMethod(Color.Harlequin, CreateCart); 162 level.SetTileMethod(Color.White, CreateDummy, Color.White); //TODO: CreateSmoke 168 level.SetTileMethod(Color.White, CreateDummy, Color.White); //TODO: CreateSmoke (optional) 163 169 //level.SetTileMethod(Color.PaintDotNetBlue, CreateDummy, Color.PaintDotNetBlue); 164 level.SetTileMethod(Color.DarkGray, CreateDummy, Color.DarkGray); //TODO: CreateTombStone 170 level.SetTileMethod(Color.DarkGray, CreateDummy, Color.DarkGray); //TODO: CreateTombStone (optional) 165 171 level.SetTileMethod(Color.Gray, CreateCrawly); 166 172 level.SetTileMethod(Color.Red, CreateDummy, Color.Red); //TODO: CreateWitch … … 272 278 visibleGround.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 273 279 Add(visibleGround, -1); 280 281 int probability = RandomGen.NextInt(100); 282 bool wheat = probability < 20; 283 284 if(wheat) 285 { 286 GameObject wheatBlock = new GameObject(width * 1.5, height * 3); 287 wheatBlock.Image = foreGroundDecorations[0]; 288 wheatBlock.Position = visibleGround.Position; 289 Add(wheatBlock, 2); 290 } 274 291 } 275 292 … … 300 317 void UpdateCamera() 301 318 { 319 320 double minY = players.Min(p => p.Y); 321 double maxY = players.Max(p => p.Y); 302 322 double minX = players.Min(p => p.X) + cameraOffset; 323 324 Vector minPosition = new Vector(Math.Max(minX, cameraTargetX), minY); 325 Vector maxPosition = new Vector(minX, maxY); 326 327 cameraTarget = (minPosition + maxPosition) * 0.5; 328 cameraTarget.X = Math.Max(cameraTargetX, minX); //Lellllll. 329 303 330 cameraTargetX = Math.Max(cameraTargetX, minX); 331 304 332 305 333 double windowMax = Camera.ScreenToWorld(new Vector(Window.Width / 2.0, 0)).X; … … 310 338 player.Right = Math.Min(player.Right, windowMax); 311 339 } 340 341 //double windowMax = Camera.ScreenToWorld(new Vector(Window.Width / 2.0, 0)).X; 342 //double windowMin = Camera.ScreenToWorld(new Vector(-Window.Width / 2.0, 0)).X; 343 //foreach (var player in players) 344 //{ 345 // player.Left = Math.Max(player.Left, windowMin); 346 // player.Right = Math.Min(player.Right, windowMax); 347 //} 312 348 } 313 349 314 350 protected override void Update(Time time) 315 351 { 316 Camera.X += (cameraTargetX - Camera.X) * time.SinceLastUpdate.TotalSeconds * cameraSpeed; 352 Camera.Position += (cameraTarget - Camera.Position) * time.SinceLastUpdate.TotalSeconds * cameraSpeed; 353 //Camera.X += (cameraTargetX - Camera.X) * time.SinceLastUpdate.TotalSeconds * cameraSpeed; 354 317 355 318 356 base.Update(time); -
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/HillbillyRunContent.contentproj
r6198 r6202 100 100 </Compile> 101 101 </ItemGroup> 102 <ItemGroup> 103 <Compile Include="viljaa.png"> 104 <Name>viljaa</Name> 105 <Importer>TextureImporter</Importer> 106 <Processor>TextureProcessor</Processor> 107 </Compile> 108 </ItemGroup> 102 109 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 103 110 <!-- 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.