61
Graphics / Variables in App.Draw
« on: June 10, 2010, 05:49:49 pm »
When I finally defined the variable properly it works great,
Thanks for your help.
Thanks for your help.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#include <SFML/Graphics.hpp>
int main()
{
int x, y, radius = 20;
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(1400, 900, 32), "Warren Graphics");
// Clear screen
App.Clear(sf::Color(128, 128, 128));
for(x = 0; x < 1400; x = x + 25);
{
for(y = 0; y < 900; y = y + 25)
{
App.Draw(sf::Shape::Circle(x, y,radius,sf::Color(255,0,0)));
// Display window contents on screen
App.Display();
}
}
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
//Escape key exit
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
}
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
int main()
{
int x, y, radius = 20;
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(1400, 900, 32), "Warren Graphics");
// Clear screen
App.Clear(sf::Color(128, 128, 128));
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
for(x = 0; x < 1400; x = x + 25);
{
for(y = 0; y < 900; y = y + 25)
{
App.Draw(sf::Shape::Circle(x, y,radius,sf::Color(255,0,0)));
// Display window contents on screen
App.Display();
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
//Escape key exit
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
}
}
}
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
void NameColor();
int rd, gr, bl;
int main()
{
int j, radius = 25;
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(1400, 900, 32), "Warren Graphics");
// Clear screen
App.Clear(sf::Color(128, 128, 128));
for(j = 1; j < 5; j++)
{
NameColor();
// Draw circle
App.Draw(sf::Shape::Circle(250,j*100+5,radius,sf::Color(rd,gr,bl)));
// Display window contents on screen
App.Display();
}
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
//Escape key exit
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
}
return EXIT_SUCCESS;
}
void NameColor()
{
int value;
// Get color from Random
value = sf::Randomizer::Random(1,6);
// Get color from key press
// scanf("%d",&value);
// cin >> value;
// Define color
if(value == 1)
{
rd = 0;
gr = 0;
bl = 255;
}
if(value == 2)
{
rd = 255;
gr = 0;
bl = 0;
}
if(value == 3)
{
rd = 255;
gr = 255;
bl = 255;
}
if(value == 4)
{
rd = 0;
gr = 255;
bl = 0;
}
if(value == 5)
{
rd = 255;
gr = 255;
bl = 0;
}
if(value == 6)
{
rd = 0;
gr = 0;
bl = 0;
}
}