normalize
This commit is contained in:
parent
b499575b61
commit
681f5a529d
@ -42,11 +42,10 @@ ewol::GameElement::GameElement(SceneElement & sceneElement, etk::UString& tmpNam
|
||||
m_visible = true;
|
||||
m_position.x = 0.0;
|
||||
m_position.y = 0.0;
|
||||
m_speed.x = 0.0;
|
||||
m_speed.y = 0.0;
|
||||
m_speed = 0.0;
|
||||
m_size = 64.0;
|
||||
m_angle = 0.0;
|
||||
m_gravity = 0.0;
|
||||
m_mass = 0.0;
|
||||
m_fileNameConfig = tmpName;
|
||||
m_canBeCibled = false;
|
||||
m_canHaveImpact = true;
|
||||
@ -117,18 +116,6 @@ float quadDist(Vector2D<float> pos1, Vector2D<float> pos2)
|
||||
}
|
||||
|
||||
|
||||
void ewol::GameElement::GetElementProperty(gameElementGenericProperty_ts &element)
|
||||
{
|
||||
element.type = m_type;
|
||||
element.position = m_position;
|
||||
element.speed.x = m_speed.x;
|
||||
element.speed.y = m_speed.y;
|
||||
element.size.x = m_size;
|
||||
element.size.y = m_size;
|
||||
element.angle = m_angle;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::GameElement::HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size)
|
||||
{
|
||||
if (true != m_canHaveImpact) {
|
||||
|
@ -41,20 +41,20 @@ namespace ewol {
|
||||
private:
|
||||
etk::UString m_fileNameConfig;
|
||||
protected:
|
||||
SceneElement & m_sceneElement; //!< all element neede in the scene
|
||||
uint16_t m_uniqueId;
|
||||
uint16_t m_group;
|
||||
int32_t m_type;
|
||||
int32_t m_power;
|
||||
bool m_visible;
|
||||
Vector2D<float> m_position;
|
||||
Vector2D<float> m_speed;
|
||||
float m_size;
|
||||
float m_angle;
|
||||
float m_gravity;
|
||||
bool m_canBeCibled;
|
||||
bool m_canHaveImpact;
|
||||
float m_life;
|
||||
SceneElement & m_sceneElement; //!< All element neede in the scene
|
||||
uint16_t m_uniqueId; //!< General element ID (uint16_t, because all is reference with the groupId like this only a uint32_t reference an element)
|
||||
uint16_t m_group; //!< General group Id More than 65000 group can be really interesting to create supid game ...
|
||||
float m_life; //!< Current life of the element
|
||||
int32_t m_type; //!<
|
||||
float m_power; //!< Current power of the element
|
||||
bool m_visible; //!< This is to know if the element is displayed or not ==> TODO : check if usefull ...
|
||||
Vector2D<float> m_position; //!< Current position of the element
|
||||
float m_speed; //!< Speed of the element (only one value, the angle is generated by the m_angle
|
||||
float m_angle; //!< Angle of the speed
|
||||
float m_mass; //!< Current element Mass ==> for the physical calculation
|
||||
float m_size; //!< Current size of the element more specific size can be done in the under class => this is for simplify calculation ==> all is consider like sphere...
|
||||
bool m_canBeCibled; //!< This is for automatic finding on an ennemy
|
||||
bool m_canHaveImpact; //!< detection of impact is done with this ...
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor : here are requested all the needed sprite and effect that can be used in the game
|
||||
@ -80,9 +80,10 @@ namespace ewol {
|
||||
Vector2D<float> PositionGet(void) { return m_position; };
|
||||
void PositionSet(Vector2D<float> state) { m_position = state; };
|
||||
void PositionSet(float xxx, float yyy) { m_position.x = xxx; m_position.y = yyy; };
|
||||
Vector2D<float> SpeedGet(void) { return m_speed; };
|
||||
void SpeedSet(Vector2D<float> state) { m_speed = state; };
|
||||
void SpeedSet(float xxx, float yyy) { m_speed.x = xxx; m_speed.y = yyy; };
|
||||
float SpeedGet(void) { return m_speed; };
|
||||
void SpeedSet(float state) { m_speed = state; };
|
||||
float MassGet(void) { return m_mass; };
|
||||
void MassSet(float state) { m_mass = state; };
|
||||
float SizeGet(void) { return m_size; };
|
||||
void SizeSet(float state) { m_size = state; };
|
||||
float AngleGet(void) { return m_angle; };
|
||||
@ -96,10 +97,8 @@ namespace ewol {
|
||||
m_angle += 2.0*M_PI;
|
||||
}
|
||||
};
|
||||
float GravityGet(void) { return m_gravity; };
|
||||
void GravitySet(float state) { m_gravity = state; };
|
||||
int32_t PowerGet(void) { return m_power; };
|
||||
void PowerSet(int32_t state) { m_power = state; };
|
||||
float PowerGet(void) { return m_power; };
|
||||
void PowerSet(float state) { m_power = state; };
|
||||
bool CanBeCibledGet(void) { return m_canBeCibled; };
|
||||
void CanBeCibledSet(bool state) { m_canBeCibled = state; };
|
||||
bool CanHaveImpactGet(void) { return m_canHaveImpact; };
|
||||
@ -110,7 +109,6 @@ namespace ewol {
|
||||
uint16_t GroupGet(void) { return m_group; };
|
||||
void GroupSet(uint16_t state) { m_group = state; };
|
||||
|
||||
void GetElementProperty(gameElementGenericProperty_ts &element);
|
||||
/**
|
||||
* @brief Periodicly this fuction will be call tu change property of all the dynamic obbjects
|
||||
* @param[in] time Current game time (start at 0)
|
||||
|
@ -169,14 +169,12 @@ LUAMOD_API int lua_GetSpeed(lua_State *L)
|
||||
if (NULL==tmpObj) {
|
||||
EWOL_ERROR("NULL obj...");
|
||||
lua_pushnumber(L, (lua_Number)0 );
|
||||
lua_pushnumber(L, (lua_Number)0 );
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
Vector2D<float> tmpPos = tmpObj->SpeedGet();
|
||||
lua_pushnumber(L, (lua_Number)tmpPos.x );
|
||||
lua_pushnumber(L, (lua_Number)tmpPos.y );
|
||||
float tmpPos = tmpObj->SpeedGet();
|
||||
lua_pushnumber(L, (lua_Number)tmpPos );
|
||||
// return number of parameters
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
LUAMOD_API int lua_SetSpeed(lua_State *L)
|
||||
@ -186,11 +184,7 @@ LUAMOD_API int lua_SetSpeed(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
float x = luaL_checknumber(L, 1);
|
||||
float y = luaL_checknumber(L, 2);
|
||||
Vector2D<float> tmpPos;
|
||||
tmpPos.x = x;
|
||||
tmpPos.y = y;
|
||||
tmpObj->SpeedSet(tmpPos);
|
||||
tmpObj->SpeedSet(x);
|
||||
// return number of parameters
|
||||
return 0;
|
||||
}
|
||||
@ -202,8 +196,8 @@ LUAMOD_API int lua_GetPower(lua_State *L)
|
||||
lua_pushnumber(L, 0 );
|
||||
return 1;
|
||||
}
|
||||
int32_t value = tmpObj->PowerGet();
|
||||
lua_pushinteger(L, value );
|
||||
float value = tmpObj->PowerGet();
|
||||
lua_pushnumber(L, (lua_Number)value );
|
||||
// return number of parameters
|
||||
return 1;
|
||||
}
|
||||
@ -215,7 +209,7 @@ LUAMOD_API int lua_SetPower(lua_State *L)
|
||||
lua_pushnumber(L, 0 );
|
||||
return 1;
|
||||
}
|
||||
int32_t value = luaL_checkint(L, 1);
|
||||
float value = luaL_checknumber(L, 1);
|
||||
tmpObj->PowerSet(value);
|
||||
// return number of parameters
|
||||
return 1;
|
||||
|
@ -33,16 +33,6 @@ namespace ewol {
|
||||
class GameElement;
|
||||
class SceneElement;
|
||||
|
||||
typedef struct {
|
||||
uint32_t id; //!< unique id of the element
|
||||
int32_t group; //!< element group
|
||||
int32_t type; //!< element type
|
||||
Vector2D<float> position; //!< current position
|
||||
Vector2D<float> speed; //!< current speed
|
||||
Vector2D<float> size; //!< curent size of the element
|
||||
float angle; //!< element angle
|
||||
} gameElementGenericProperty_ts;
|
||||
|
||||
typedef ewol::GameElement* (creatorElement_tf)(SceneElement & sceneElement, etk::UString& tmpName, etk::UString& userString);
|
||||
|
||||
class listRegisteElement {
|
||||
|
Loading…
x
Reference in New Issue
Block a user