equal
deleted
inserted
replaced
|
1 |
|
2 #include "GameView.hh" |
|
3 |
|
4 namespace graphics |
|
5 { |
|
6 |
|
7 |
|
8 void GameView::draw (Display *display) { |
|
9 CL_GraphicContext *gc = display->get_gc(); |
|
10 |
|
11 // calculate camera |
|
12 PixelCoordinate camera(0, 0); |
|
13 |
|
14 // ...to track our local player |
|
15 if (player != NULL) { |
|
16 // display resolution |
|
17 PixelCoordinate resolution = display->getResolution(); |
|
18 |
|
19 // try and center the screen on the player |
|
20 PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2); |
|
21 |
|
22 // ...but keep the world in view |
|
23 PixelCoordinate max = state.terrain.getDimensions() - resolution + PixelCoordinate(0, 100); |
|
24 |
|
25 // ...by limiting the value to 0...max |
|
26 camera = PixelCoordinate( |
|
27 value_between(0, target.x, max.x), |
|
28 value_between(0, target.y, max.y) |
|
29 ); |
|
30 } |
|
31 |
|
32 // Black background |
|
33 gc->clear(CL_Color::black); |
|
34 |
|
35 // Draw the game |
|
36 state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON); |
|
37 |
|
38 // draw player info box |
|
39 if (player != NULL) { |
|
40 draw_player_info(gc, player); |
|
41 } |
|
42 |
|
43 // draw messages |
|
44 message_view.draw(this); |
|
45 } |
|
46 |
|
47 |
|
48 }; |