-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scroller.cpp
46 lines (33 loc) · 1.06 KB
/
Scroller.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stdafx.h"
#include "Scroller.h"
Scroller::Scroller () {}
Scroller::Scroller (int view_width, int view_height, int scroll_margin)
{
min_scroll_x = view_width;
min_scroll_y = view_height;
max_scroll_x = 0;
max_scroll_y = 0;
game_view_width = view_width;
game_view_height = view_height;
x = 0;
y = 0;
margin = scroll_margin;
}
Scroller::Scroller (int view_width, int view_height, int scroll_margin, HBITMAP background)
{
game_view_width = view_width;
game_view_height = view_height;
// TODO: Change world size to user-defined instead of background-defined
BITMAP temp_bitmap;
GetObject (background, sizeof (temp_bitmap), &temp_bitmap);
game_world_width = temp_bitmap.bmWidth;
game_world_height = temp_bitmap.bmHeight;
min_scroll_x = game_view_width > game_world_width ? 0 : game_view_width - game_world_width;
min_scroll_y = game_view_height > game_world_height ? 0 : game_view_height - game_world_height;
max_scroll_x = 0;
max_scroll_y = 0;
x = 0;
y = 0;
margin = scroll_margin;
}
Scroller::~Scroller () {}