forked from rachit3006/CPP-Project-SDL2-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRect.cpp
More file actions
51 lines (42 loc) · 938 Bytes
/
Copy pathRect.cpp
File metadata and controls
51 lines (42 loc) · 938 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
43
44
45
46
47
48
49
50
51
#include "Rect.h"
#include <iostream>
Rect::Rect(SDL_Window *window, SDL_Renderer *renderer, int w, int h, int x, int y, int r, int g, int b, int a, SDL_Texture *Message)
{
this->window = window;
this->renderer = renderer;
this->w = w;
this->h = h;
this->x = x;
this->y = y;
this->r = r;
this->g = g;
this->b = b;
this->a = a;
this->Message = Message;
this->isCollisionDetected = false;
}
void Rect::draw()
{
rect.w = w;
rect.h = h;
rect.x = x;
rect.y = y;
SDL_SetRenderDrawColor(renderer, r, g, b, a);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
SDL_RenderFillRect(renderer, &rect);
SDL_RenderCopy(renderer, Message, NULL, &rect);
SDL_RenderPresent(renderer);
}
void Rect::move()
{
this->x -= 2;
// std::cout << this->x << std::endl;
}
double Rect::getx()
{
return x;
}
SDL_Rect Rect::get_rect()
{
return rect;
}