blob: 3407a0c7b643a3e76f0b3bc58447736d255d8a92 (
plain) (
tree)
|
|
#include "smelt.hpp"
#include "player.hpp"
#include "../master/resources.hpp"
SMELT* playerBase::sm=NULL;
playerBase::playerBase(float _x,float _y)
{
sm=smGetInterface(SMELT_APILEVEL);
playerent=new smEntity2D(ssanm.getTextureInfo("player")->tex,ssanm.getTextureInfo("player")->rect);
playerent->setCentre(12,12);
pos.x=_x;pos.y=_y;
plyrctl[0]=SMK_UP;plyrctl[1]=SMK_DOWN;
plyrctl[2]=SMK_LEFT;plyrctl[3]=SMK_RIGHT;
plyrctl[4]=SMK_SHIFT;
rot=0;
}
playerBase::~playerBase()
{
delete playerent;sm->smRelease();
}
void playerBase::update()
{
//player control...
static float realspeed=0;
if(sm->smGetKeyState(plyrctl[4]))
realspeed=0.85;else realspeed=3.5;
if(sm->smGetKeyState(plyrctl[0]))
{if(pos.y>15)pos.y-=realspeed;else pos.y=15;}
if(sm->smGetKeyState(plyrctl[1]))
{if(pos.y<585)pos.y+=realspeed;else pos.y=585;}
if(sm->smGetKeyState(plyrctl[2]))
{if(pos.x>15)pos.x-=realspeed;else pos.x=15;}
if(sm->smGetKeyState(plyrctl[3]))
{if(pos.x<785)pos.x+=realspeed;else pos.x=785;}
rot+=17./1800.*PI;
}
void playerBase::render()
{
playerent->render(pos.x,pos.y,rot,0.7);
}
playerBase* player;
|