0 Members and 1 Guest are viewing this topic.
#pragma once#include <vector>#include <SFML\Graphics.hpp>class TBlocks:public sf::Drawable{public: TBlocks(float t_Y); TBlocks()=delete; virtual ~TBlocks() = default; void update_block(); void draw(sf::RenderTarget& target, sf::RenderStates states) const override; sf::Texture block_texture; sf::Sprite blockSprite; sf::Texture *bTexture = &block_texture;private: std::string blocks[3];};
#ifndef TPLAYER_H#define TPLAYER_H#include <SFML/Graphics.hpp>class TPlayer : public sf::Drawable{public: TPlayer(float t_X, float t_Y); TPlayer() = delete; virtual ~TPlayer() = default; void update(); float moveRight(); float moveLeft(); void draw(sf::RenderTarget& target, sf::RenderStates states) const override; sf::Texture playerTexture; sf::Sprite playerSprite; sf::Texture *pTexture = &playerTexture;private: const double playerVelocity{4}; sf::Vector2f velocity{ playerVelocity, 0.f };};#endif // TPLAYER_H
bool TGame::checkCollision(){ if (SPRITE.getGlobalBounds().intersects(SPRITE2.getGlobalBounds())}
sf::FloatRect TBlocks::blockBound(){ return blockSprite.getGlobalBounds();}
sf::FloatRect TPlayer::playerBound(){ return playerSprite.getGlobalBounds();}
bool TGame::checkCollision(){ if (player->playerBound().instersects(block->blockBound())) { return true; }}}}
error C2039: 'instersects': is not a member of 'sf::Rect<float>'