-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.cpp
43 lines (41 loc) · 918 Bytes
/
player.cpp
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
#include "player.h"
player::player(int num)
{
int iW, iH;
character=loadTexture("images/character.png");
SDL_QueryTexture(character, NULL, NULL, &iW, &iH);
PlayeR.x = 200;
PlayeR.y = 200;
PlayeR.w = iW;
PlayeR.h = iH;
cout << "setting mVel to 0" << endl;
int geoffTest = 420;
int mVel = num;
int jVel = num;
cout << "mVel is now: " << mVel << endl;
bool playerFlip = false;
}
player::~player()
{
SDL_DestroyTexture(character);
character = NULL;
}
void player::draw()
{
if (playerFlip == false)
{
SDL_RenderCopy(renderer, character, NULL, &PlayeR);
}
else if (playerFlip == true)
{
SDL_RenderCopyEx(renderer, character, NULL, &PlayeR, 0, 0, SDL_FLIP_HORIZONTAL);
}
}
void player::move()
{
PlayeR.x += mVel;
if ((PlayeR.x < 0) || ( PlayeR.x + PlayeR.w > SCREEN_WIDTH))
{
PlayeR.x -= mVel;
}
}