1
Graphique / Re : classe balle
« le: Août 14, 2013, 11:53:13 am »
Ah oui merci j'avais pas vu :p
EDIT: J'essaie de faire bouger la balle et je vois pas ou est le probleme, tout compile parfaitement
EDIT: J'essaie de faire bouger la balle et je vois pas ou est le probleme, tout compile parfaitement
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
sf::Event event;
class Ball
{
int CircleR, Redd, Greenn, Bluee;
sf::CircleShape shape;
public:
Ball(int CircleR,int Redd,int Greenn,int Bluee);
Ball();
sf::CircleShape getCircle();
void moveCircle(int x, int y);
};
int main()
{
Ball ball(100.f, 250, 0, 0);
sf::RenderWindow window(sf::VideoMode(800,600), "SFML Test");
while(window.isOpen())
{
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
ball.moveCircle(-50,0);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
ball.moveCircle(50,0);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
ball.moveCircle(0,50);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
ball.moveCircle(0,-50);
}
window.clear(sf::Color::Black);
window.draw(ball.getCircle());
window.display();
}
return 0;
}
Ball::Ball(int CircleR, int Redd, int Greenn, int Bluee)
{
CircleR = CircleR;
Redd = Redd;
Greenn = Greenn;
Bluee = Bluee;
shape.setRadius(CircleR);
shape.setFillColor(sf::Color(Redd,Greenn,Bluee));
shape.setPosition(100,100);
}
Ball::Ball()
{
shape.setRadius(50);
shape.setFillColor(sf::Color(100,100,100));
shape.setPosition(100,100);
}
sf::CircleShape Ball::getCircle()
{
return shape;
}
void Ball::moveCircle(int x, int y)
{
getCircle().move(x, y);
}
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
sf::Event event;
class Ball
{
int CircleR, Redd, Greenn, Bluee;
sf::CircleShape shape;
public:
Ball(int CircleR,int Redd,int Greenn,int Bluee);
Ball();
sf::CircleShape getCircle();
void moveCircle(int x, int y);
};
int main()
{
Ball ball(100.f, 250, 0, 0);
sf::RenderWindow window(sf::VideoMode(800,600), "SFML Test");
while(window.isOpen())
{
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
ball.moveCircle(-50,0);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
ball.moveCircle(50,0);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
ball.moveCircle(0,50);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
ball.moveCircle(0,-50);
}
window.clear(sf::Color::Black);
window.draw(ball.getCircle());
window.display();
}
return 0;
}
Ball::Ball(int CircleR, int Redd, int Greenn, int Bluee)
{
CircleR = CircleR;
Redd = Redd;
Greenn = Greenn;
Bluee = Bluee;
shape.setRadius(CircleR);
shape.setFillColor(sf::Color(Redd,Greenn,Bluee));
shape.setPosition(100,100);
}
Ball::Ball()
{
shape.setRadius(50);
shape.setFillColor(sf::Color(100,100,100));
shape.setPosition(100,100);
}
sf::CircleShape Ball::getCircle()
{
return shape;
}
void Ball::moveCircle(int x, int y)
{
getCircle().move(x, y);
}