forked from ManalHasan/OOP-Project-Manal-Moiz-Naaseh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackground.cpp
More file actions
42 lines (38 loc) · 861 Bytes
/
Background.cpp
File metadata and controls
42 lines (38 loc) · 861 Bytes
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
#include "Background.hpp"
//Rendering Background
void Background::Render(SDL_Renderer *ren)
{
SDL_RenderCopy(ren, getTexture(), NULL, NULL);
}
//Rendering the base of the background
void Background::GroundRender(SDL_Renderer *ren)
{
SDL_RenderCopy(ren, getTexture(), &getSrc(), &getDest());
}
//Updating the x and y coordinates of base SDl_Rect, so that the birds appear to be moving forward
void Background::GroundUpdate1()
{
if (distance1 <= -800)
{
distance1 = 800;
}
else
{
distance1 -= 3;
setSource(0, 0, 336, 112);
setDest(distance1, 520, 805, 112);
}
}
void Background::GroundUpdate2()//the base is made up of two grounds rendering back to back
{
if (distance2 <= -800)
{
distance2 = 800;
}
else
{
distance2 -= 3;
setSource(0, 0, 336, 112);
setDest(distance2, 520, 805, 112);
}
}