Powerup update
This commit is contained in:
parent
94a8df620d
commit
61730209be
8
main.cpp
8
main.cpp
|
@ -18,15 +18,8 @@ SDL_Renderer* gRenderer = NULL;
|
|||
const int sz = SCREEN_WIDTH/16;
|
||||
|
||||
void init();
|
||||
bool loadMedia();
|
||||
void close();
|
||||
|
||||
bool loadMedia(){
|
||||
bool success = true;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void init(){
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
gWindow = SDL_CreateWindow("Platform Test!",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
|
||||
|
@ -45,7 +38,6 @@ void close(){
|
|||
|
||||
int main(int argc, char* args[]){
|
||||
init();
|
||||
loadMedia();
|
||||
|
||||
bool quit = false;
|
||||
SDL_Event e;
|
||||
|
|
26
player.cpp
26
player.cpp
|
@ -7,15 +7,19 @@ void Player::print(int cameraX){
|
|||
SDL_Rect cameraFix = rect;
|
||||
cameraFix.x -= cameraX;
|
||||
|
||||
if(power > 0){
|
||||
if(false){
|
||||
std::cout << power << "ye" << std::endl;
|
||||
power--;
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(*renderer,0xFF,0,0,0xFF);
|
||||
ply.render(&cameraFix,&plyFrame[0]);
|
||||
if(power == 0)ply.render(&cameraFix,&plyFrame[0]);
|
||||
else{
|
||||
ply.render(&cameraFix,&plyRun);
|
||||
power--;
|
||||
}
|
||||
//ply.render(currentFrame);
|
||||
if(ifRunning)ply.render(&cameraFix,&plyFrame[1]);
|
||||
if(ifRunning or power > 0)ply.render(&cameraFix,&plyFrame[1]);
|
||||
|
||||
|
||||
oldPosX = posX;
|
||||
|
@ -37,8 +41,6 @@ Player::Player(int x,int y, int w, int h, SDL_Renderer** render){
|
|||
|
||||
ply.setRenderer(renderer);
|
||||
loadMedia();
|
||||
|
||||
currentFrame = &plyFrame[0];
|
||||
};
|
||||
|
||||
void Player::loadMedia(){
|
||||
|
@ -51,9 +53,13 @@ void Player::loadMedia(){
|
|||
|
||||
plyFrame[1].w = szW;
|
||||
plyFrame[1].h = szH;
|
||||
plyFrame[1].x = 2*szW;
|
||||
plyFrame[1].y = szH;
|
||||
plyFrame[1].x = szW;
|
||||
plyFrame[1].y = 0;
|
||||
|
||||
plyRun.w = szW;
|
||||
plyRun.h = szH;
|
||||
plyRun.x = szW*2;
|
||||
plyRun.y = 0;
|
||||
};
|
||||
|
||||
int Player::intVelX(){
|
||||
|
@ -76,6 +82,10 @@ void Player::move(){
|
|||
|
||||
int gravity = 800; //Gravity force
|
||||
int jump = 500; //Jump force
|
||||
if(power > 0){
|
||||
jump = 700;
|
||||
speed = 250;
|
||||
}
|
||||
|
||||
//Check keyboard current state
|
||||
if(currentKeyStates[SDL_SCANCODE_LEFT]) direction += -1;
|
||||
|
@ -231,7 +241,7 @@ int Player::check(SDL_Rect rectA, int type){
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(type == 2){
|
||||
else if(type == 2 and power == 0){
|
||||
if(((movX >= bX and movX < b2X)
|
||||
or (movX + szW > bX and movX + szW <= b2X)
|
||||
or (movX < bX and movX + szW > b2X))
|
||||
|
|
4
player.h
4
player.h
|
@ -34,8 +34,8 @@ class Player: public Entity{
|
|||
int power = 0;
|
||||
|
||||
PosuTexture ply;
|
||||
SDL_Rect* currentFrame;
|
||||
SDL_Rect plyFrame[2];
|
||||
SDL_Rect plyFrame[3];
|
||||
SDL_Rect plyRun;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 412 B |
Loading…
Reference in New Issue