-
Notifications
You must be signed in to change notification settings - Fork 1
/
ColliderComponent.h
50 lines (42 loc) · 1.25 KB
/
ColliderComponent.h
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
/**
* The ColliderComponent contains essential data for collision checking
*
* Author: Skylar Payne
* Date: 8/5/2013
* File: ColliderComponent.h
**/
#pragma once
#include <SFML/Graphics.hpp>
#include "IComponent.h"
#include <lua.hpp>
class ColliderComponent : public IComponent
{
friend class CollisionSystem;
private:
sf::Vector2f _Offset;
sf::Vector2f _Dimensions;
public:
ColliderComponent(float x = 0, float y = 0, float w = 0, float h = 0) : IComponent("Collider"), _Offset(x, y), _Dimensions(w, h) { }
~ColliderComponent() { }
sf::Vector2f const& GetOffset() const { return _Offset; }
sf::Vector2f const& GetDimensions() const { return _Dimensions; }
void Load(lua_State *L) override
{
lua_pushstring(L, "w");
lua_gettable(L, -2);
_Dimensions.x = lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "h");
lua_gettable(L, -2);
_Dimensions.y = lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "offsetx");
lua_gettable(L, -2);
_Offset.x = lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "offsety");
lua_gettable(L, -2);
_Offset.y = lua_tonumber(L, -1);
lua_pop(L, 1);
}
};