equal
deleted
inserted
replaced
|
1 |
1 #include "Terrain.hh" |
2 #include "Terrain.hh" |
2 #include "Graphics.hh" |
|
3 #include "Engine.hh" |
3 #include "Engine.hh" |
4 |
4 |
5 #include <cmath> |
5 #include <cmath> |
6 #include <cassert> |
6 #include <cassert> |
7 #include <algorithm> |
7 #include <algorithm> |
18 Vector(-1,-1) |
18 Vector(-1,-1) |
19 }; |
19 }; |
20 |
20 |
21 Terrain::Terrain (const TerrainConfig &config) : |
21 Terrain::Terrain (const TerrainConfig &config) : |
22 terrain_buf(NULL), |
22 terrain_buf(NULL), |
23 width(config.dimensions.x), height(config.dimensions.y) |
23 width(config.dimensions.width), height(config.dimensions.height) |
24 { |
24 { |
25 // allocate terrain_buf |
25 // allocate terrain_buf |
26 terrain_buf = new TerrainPixel[width * height]; |
26 terrain_buf = new TerrainPixel[width * height]; |
27 |
27 |
28 // fill with dirt |
28 // fill with dirt |
408 } |
408 } |
409 |
409 |
410 return normal; |
410 return normal; |
411 } |
411 } |
412 |
412 |
413 void Terrain::draw (Graphics *g, PixelCoordinate camera) { |
413 void Terrain::draw (graphics::Display &display, PixelCoordinate camera) { |
414 // XXX: can we optimize this somehow? |
414 // XXX: can we optimize this somehow? |
415 |
415 |
416 // load the terrain pixbuf as a surface |
416 // load the terrain pixbuf as a surface |
417 CL_Surface surf (pixbuf); |
417 CL_Surface surf (pixbuf); |
418 |
418 |
419 // draw it onto the graphics, offset by camera position |
419 // draw it onto the graphics, offset by camera position |
420 surf.draw(-camera.x, -camera.y, g->get_gc()); |
420 surf.draw(-camera.x, -camera.y, display.get_gc()); |
421 } |
421 } |
422 |
422 |