#include "Play.h"
void Play::Show(sf::RenderWindow& window3)
{
sf::Event GEvent;
//load background image
sf::Image image4;
image4.LoadFromFile("PlayBack.jpg");
//load grey bar
sf::Image image5;
image5.LoadFromFile("GreyBar.jpg");
//setup grey bar
sf::Sprite GBar(image5);
GBar.Resize(800,50);
//setup background image
sf::Sprite PlayBack(image4);
PlayBack.Resize(800,600);
//load paddle
sf::Image image6;
image6.LoadFromFile("paddle.png");
//setup paddle
sf::Sprite ppaddle(image6);
ppaddle.Rotate(90);
//load ball
sf::Image image7;
image7.LoadFromFile("ball.png");
//setup ball
sf::Sprite ball(image7);
ball.SetPosition(350, 300);
while(window3.GetEvent(GEvent))
{
int x = GEvent.MouseMove.Y;
if(x < 140)
{
x = 140;
}
if(GEvent.MouseMove.Y || GEvent.MouseMove.X)
{
ppaddle.SetPosition(15, x );
}
}
window3.Draw(PlayBack);
window3.Draw(GBar);
window3.Draw(ppaddle);
window3.Draw(ball);
window3.Display();
}
The Paddle moves fine, but if the cursor is in certain spots, the sprite will disappear idk why. Is that the right loop to update the game? Also, I need help with ball movement. I like to have the user click for the ball to start moving. I couldn't get the ball to move and I'm guessing i will need a different loop or maybe even a whole new function.Thanks for any advice you can give me.