forked from Breeze-del/C-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameObject.cpp
85 lines (69 loc) · 1.77 KB
/
GameObject.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// GameObject.cpp: implementation of the CGameObject class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "stdio.h"
#include "GameObject.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGameObject::CGameObject()
{
}
CGameObject::~CGameObject()
{
}
void CGameObject::SetPos(int i, int j)
{
}
void CGameObject::Draw(IplImage *bg)
{
for (int i = 0; i < m_img->height; i++) {
for (int j = 0; j < m_img->width; j++) {
if (i + m_Position.y >= bg->height ||
j + m_Position.x >= bg->width ||
i + m_Position.y < 0 ||
j + m_Position.x < 0
)continue; //超过边界的不打印.
if (CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 0) <= 10 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1) >= 135 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1) <= 155 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 2) <= 10
)continue;//纯色控制
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y, (j + m_Position.x) * 3 + 0)
= CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 0);
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y, (j + m_Position.x) * 3 + 1)
= CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1);
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y, (j + m_Position.x) * 3 + 2)
= CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 2);
}
}
}
void CGameObject::Time()
{
if (m_timer < m_timerate) {
m_timer++;
if (m_timer == m_timerate) {
Timething();
}
}
}
void CGameObject::Timething()
{
}
void CGameObject::SetTimer(int time)
{
m_timer = m_timerate = time;
}
void CGameObject::Changem_timer(int timer)
{
m_timer = timer;
}
int CGameObject::Getm_timer()
{
return m_timer;
}
int CGameObject::Getm_timerate()
{
return m_timerate;
}