-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPickup.cpp
More file actions
executable file
·51 lines (43 loc) · 1021 Bytes
/
Pickup.cpp
File metadata and controls
executable file
·51 lines (43 loc) · 1021 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 "include/Pickup.hpp"
#include "include/Animation.hpp"
#include "include/globals.hpp"
Pickup::Pickup(Texture *texture) : texture(texture)
{
GameObject::Init(100, 100, 24, 24);
state = Falling;
velY = 0;
objectType = PlayerId;
}
void Pickup::Update()
{
if (state == Falling)
{
velY += 0.1;
}
GameObject::Update();
if (posY > SCREEN_HEIGHT)
{
velY = 0;
posX = rand() % 530;
posY = -300;
state = Falling;
}
}
void Pickup::Render(sf::RenderWindow &window)
{
// GameObject::Render(window);
// sf::RectangleShape tile;
// tile.setSize(sf::Vector2f(sizeX, sizeY));
// tile.setFillColor(sf::Color(255, 0, 255));
// tile.setPosition(posX, posY);
// window.draw(tile);
sf::Sprite sprite;
sprite.setTexture(*texture);
sprite.setTextureRect(sf::IntRect(48, 637, 16, 16));
sprite.setPosition(posX + 2, posY + 2);
sprite.setScale(1.5f, 1.5f);
window.draw(sprite);
}
Pickup::~Pickup()
{
}