-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPT_object.cpp
More file actions
34 lines (26 loc) · 800 Bytes
/
PT_object.cpp
File metadata and controls
34 lines (26 loc) · 800 Bytes
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
#include <vcl\vcl.h>
#pragma hdrstop
#include "PT_object.h"
PT_object::PT_object(int px, int py , int pv , int pf , int pw, int ph , AnsiString resource_name = "")
: x(px) , y(py) , v(pv) , f(pf) , w(pw) , h(ph) , state(DEAD)
{
if(resource_name != "")
{
art = new Graphics::TBitmap;
art->LoadFromResourceName((int)HInstance , resource_name);
}
}
PT_object::~PT_object()
{
if(art) delete art;
}
bool PT_object::collision(PT_object *other)
{
if(other->state != ALIVE || state != ALIVE) return false;
return (y <= other.y + other.h && y + h >= other.y && x <= other.x + other.w && x + w >= other.x);
}
bool PT_object::collision(int x1 , int y1 , int x2 , int y2)
{
if(state != ALIVE) return false;
return (y <= y2 && y + h >= y1 && x <= x2 && x + w >= x1);
}