Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Topics - wvtrammell

Pages: 1 [2]
16
Graphics / Key Pressed
« on: October 28, 2010, 07:10:40 pm »
Hi
Can some one tell me why pressing the up key and moving the cursor has the same effect in the following code:



Code: [Select]
#include <SFML/Graphics.hpp>


int main()
{
    srand((unsigned int)time(NULL));

int x, y;

// Create main window
    sf::RenderWindow App(sf::VideoMode(1200, 800), "SFML Graphics");

// Change color of background
App.Clear(sf::Color(128,128,128));
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();
       

   if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up));
   {
       x = rand() % 1000 + 50;
       y = rand() % 600 + 50;

        // Draw a shape
       App.Draw(sf::Shape::Circle(x, y, 50, sf::Color::Red));

        // Finally, display the on screen
       App.Display();

    }

}

    }

    return EXIT_SUCCESS;
}


Thanks
Warren

17
Graphics / Event
« on: October 28, 2010, 04:47:23 pm »
Which is proper to use in graphics:

If(App.GetInput().IsKeyDown(sf::Key::F1))

or  

if(Event.Type == sf::Event::KeyPressed):: && (Event.Key.Code == sf::Key::F1))

They both appear to function.

Thanks
Warren

18
Graphics / Colors
« on: October 22, 2010, 07:51:38 pm »
Where may I find a list of the colors SFML will accept, Red,Blue, etc.
Thanks
Warren

19
Graphics / determine color
« on: October 16, 2010, 05:14:12 pm »
App.Draw(sf::Shape::Circle(x,y,radius,sf::Color(255,0,0)));
App.Display();

The above code will place a red circle on the screen.
Is there code that I can use to tell me the color the circle?
Thanks
Warren

20
Graphics / Variables as colors
« on: October 12, 2010, 06:42:39 pm »
Is it possible to:
int a = 255, b = 128, c = 37;

sf::Shape::Circle(x,y,radius,Color(a,b,c));

Thanks
Warren

21
SFML projects / Tic Tac Toe
« on: June 09, 2010, 05:36:03 pm »
Could someone point me toward an example of coding for such a game or one like it.
I have googled till I am blue in the face with no luck.
Much appreciate
Warren

22
Graphics / Problem with circles coordinates
« on: June 08, 2010, 03:29:56 pm »
Why does the following code place circles at only one value of X?
Thanks
Warren

Code: [Select]
#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;
}

23
SFML projects / first project
« on: June 07, 2010, 09:41:27 pm »
This code compiles and executes as is.
However I wish to allow the user to select the color in the function.
Using either cin or scanf compiles but does not execute.
Help please?
Warren


Code: [Select]
#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;
}
}

24
Graphics / Variables in App.Draw
« on: June 05, 2010, 05:30:16 pm »
May I use a variablet o define the color instead of the actual Color in the App.Draw Circle command?
Warren

25
SFML projects / graphic.hpp vs window.hpp
« on: June 04, 2010, 04:19:06 pm »
I wish to write some code in C++ where it draws 4 circles on the screen with the program defining the location and color of each.
Then I want to draw an additional four circles with the user defining the location and color of each.
Do I need to use graphic.hpp or window.hpp?
Thanks
Warren

Pages: 1 [2]