aboutsummaryrefslogtreecommitdiff
path: root/src/core/player.cpp
blob: d461b52312894e4f879ea23dae3d341995b70522 (plain) (blame)
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
#include "smelt.hpp"
#include "player.hpp"
#include "../master/resources.hpp"
SMELT* playerBase::sm=NULL;
playerBase::playerBase(double _x,double _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;scoll=coll=0;vel=3.5;velp=1.5;
}
playerBase::~playerBase()
{
	delete playerent;sm->smRelease();
}
void playerBase::update()
{
	//player control...
	static double realspeed=0;
	if(sm->smGetKeyState(plyrctl[4]))
	realspeed=velp;else realspeed=vel;
	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+8.4,pos.y+8.4,rot,0.7);
}
playerBase* player;