forked from ManalHasan/OOP-Project-Manal-Moiz-Naaseh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBirdB.cpp
48 lines (41 loc) · 1.33 KB
/
BirdB.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
44
45
46
47
48
#include "BirdB.hpp"
#include "TextureManager.hpp"
//constructor
BirdB::BirdB():Tex1(nullptr),Tex2(nullptr),frate(0){}
BirdB::~BirdB(){
Tex1=nullptr;
Tex2=nullptr;
std::cout<<"Blue bird destructed"<<std::endl;
}
//copy constructor
BirdB::BirdB(const BirdB& other):Tex1(other.Tex1),Tex2(other.Tex2),frate(other.frate){}
//rendering between 3 frames of blue birds to make its wings flap
void BirdB::Render(SDL_Renderer* ren){
frate++;
if (frate < 16)//switch to next frame
{
SDL_RenderCopyEx(ren, getTexture(), &getSrc(), &getDest(), 0, NULL, SDL_FLIP_NONE);
}
else if (frate >= 16 && frate <= 32)//other frame in between these intervals of time
{
SDL_RenderCopyEx(ren, Tex1, &getSrc(), &getDest(), 0, NULL, SDL_FLIP_NONE);
}
else if (frate > 32)
{
SDL_RenderCopyEx(ren, Tex2, &getSrc(), &getDest(), 0, NULL, SDL_FLIP_NONE);
}
if (frate > 48)
{
frate = 0;//start over from first frame
}
}
//For the seconf and third frame of the blue bird
void BirdB::createTexture1(const char* address, SDL_Renderer* ren){
Tex1=TextureManager::Texture(address, ren);
}
void BirdB::createTexture2(const char* address, SDL_Renderer* ren){
Tex2=TextureManager::Texture(address, ren);
}
void BirdB::createTexture3(const char* address, SDL_Renderer* ren){
std::cout<<"No need"<<std::endl;
}