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
1
General discussions / Games
« on: January 17, 2014, 05:46:36 am »
Would it be practical to use SFML to write a board game such as chess or checkers for two people to play??????
Thanks
WVT

2
General / error message
« on: October 11, 2013, 07:33:25 pm »
OSX 10.8.5 and xcode 5
I downloaded and installed version 2.1 and the xcode templates.
When I run the sample program it compiles but gives me an error message at the window.clear line.
Thread 1 EXC_BAD_ACCESS (code = 1, address = 0X25800000338.
What did I do wrong please?
Thanks
Warren

3
General / Xcode
« on: October 08, 2013, 09:49:25 pm »
Installed latest version of Xcode.  Compile sample code results in 31 error messages.
Worked great before installation.
Help please?
Warren

4
Graphics / event
« on: August 23, 2013, 11:34:47 pm »
As I understand the event tutorial, the following code should not move the shape when the mouse is moved or a key pressed, but the shape does move?????
 

#include <SFML/Graphics.hpp>

int main()
{
    int x = 50, y = 50;
   
    sf::RenderWindow window(sf::VideoMode(800, 600), "Input data test" );
   
    sf::CircleShape shape(20);
    shape.setFillColor(sf::Color::Color(255,0,0));
   
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            window.clear(sf::Color(128,128,128));
            shape.setPosition(x, y);
            window.draw(shape);
            window.display();
            if(x < 750) x = x + 25;
            else
            {
                x = 50;
                y = y + 25;
            }
        }
    }
    return EXIT_SUCCESS;
}
 

5
General discussions / Frustrations
« on: June 27, 2013, 05:43:32 pm »
 

   I wrote  my first program on a yellow pad just over 61 years ago.  If I remember correctly it was called Fortran 4.  A key punch operator took the sheets and returned shortly with a deck of cards with holes punched in them.  She called the deck a source deck.  I fed them into a card reader connected to an IBM mainframe.  It responded by punching me a new deck called an object deck.  I combined this deck with a bunch of other decks called library decks  and fed them into the same card reader.  This time I received a deck called an executable deck.  Using my yellow pad again I listed all the input data and received another deck called input deck.  Placing this on the front of my executable deck I once again approached the card reader.  After entering this deck, I received a printout of  rows and columns of digits representing the flight performance of the engine and airplane our company was developing for the military, 
   A couple of years ago, I decided to try my hand at programming again.  I purchased a couple of books on C++ and downloaded some stuff called Allegro.
With the list of reserved words (as they were called) and the description of what they did and the examples, I was able to get a program up and running that filled the screen with random colored pixels and then set back and watch as it did a bubble sort, bubbling the lighter colors to the left upper corner and the darker to the lower right corner.  My great grandchildren loved watching this program,  But my computer died of old age  so I replaced it.  The new one had an Intel processor and a new OS so my bubble program would no longer function.
Then I saw on the internet  Simple and Fast Multimedia Library.  The kids liked the Hanoi's Tower game so I decided to give it a shot.   
   I read the tutorials, the documentation, and the forum pages but could not find any indication of reserved words or their function.  So after many weeks of frustrated try and fail I finally arrived at the enclosed.  Not good but is appears to work.

// tower of hanoi
// June 21st, 2013
// Yours truly

#include <SFML/Graphics.hpp>


int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(2200, 1300), "SFML window");
   
    window.clear(sf::Color(128,128,128));
   
    sf::RectangleShape rect1(sf::Vector2f(300,150));
    rect1.setFillColor(sf::Color(255,0,0));
    rect1.setPosition(200,550);
    window.draw(rect1);
    sf::RectangleShape rect2(sf::Vector2f(400,150));
    rect2.setFillColor(sf::Color(255,255,255));
    rect2.setPosition(150,700);
    window.draw(rect2);
    sf::RectangleShape rect3(sf::Vector2f(500,150));
    rect3.setFillColor(sf::Color(0,0,255));
    rect3.setPosition(100,850);
    sf::RectangleShape rect4(sf::Vector2f(50,600));
    rect4.setFillColor(sf::Color(0,0,0));
    rect4.setPosition(325,400);
    sf::RectangleShape rect5(sf::Vector2f(50,600));
    rect5.setFillColor(sf::Color(0,0,0));
    rect5.setPosition(1075,400);
    sf::RectangleShape rect6(sf::Vector2f(50,600));
    rect6.setFillColor(sf::Color(0,0,0));
    rect6.setPosition(1825,400);
    sf::RectangleShape rect7(sf::Vector2f(2200,300));
    rect7.setFillColor(sf::Color(139,68,19));
    rect7.setPosition(0,1000);
   
    window.draw(rect1);
    window.draw(rect2);
    window.draw(rect3);
    window.draw(rect4);
    window.draw(rect5);
    window.draw(rect6);
    window.draw(rect7);
    window.display();
   
    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
           
            // Escape pressed : exit
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
            {
                window.close();
            }
         
            if ((event.type == sf::Event::MouseMoved) &&  (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
                && (sf::Mouse::getPosition(window).x > rect1.getPosition().x - 50)
                && (sf::Mouse::getPosition(window).x < rect1.getPosition().x + 50)
                && (sf::Mouse::getPosition(window).y > rect1.getPosition().y - 50)
                && (sf::Mouse::getPosition(window).y < rect1.getPosition().y + 50))
               
            {
                rect1.setPosition(event.mouseMove.x,event.mouseMove.y);
            }
           
            if ((event.type == sf::Event::MouseMoved) &&  (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
                && (sf::Mouse::getPosition(window).x > rect2.getPosition().x - 50)
                && (sf::Mouse::getPosition(window).x < rect2.getPosition().x + 50)
                && (sf::Mouse::getPosition(window).y > rect2.getPosition().y - 50)
                && (sf::Mouse::getPosition(window).y < rect2.getPosition().y + 50))
               
            {
                rect2.setPosition(event.mouseMove.x,event.mouseMove.y);
            }
           
            if ((event.type == sf::Event::MouseMoved) &&  (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
                && (sf::Mouse::getPosition(window).x > rect3.getPosition().x - 50)
                && (sf::Mouse::getPosition(window).x < rect3.getPosition().x + 50)
                && (sf::Mouse::getPosition(window).y > rect3.getPosition().y - 50)
                && (sf::Mouse::getPosition(window).y < rect3.getPosition().y + 50))
               
            {
                rect3.setPosition(event.mouseMove.x,event.mouseMove.y);
            }
           
        }
     
        window.clear(sf::Color(128,128,128));
        window.draw(rect1);
        window.draw(rect2);
        window.draw(rect3);
        window.draw(rect4);
        window.draw(rect5);
        window.draw(rect6);
        window.draw(rect7);
        window.display();
   
       
       
    }
   
    return EXIT_SUCCESS;
   
}

6
Graphics / Mouse movement
« on: June 20, 2013, 07:05:43 pm »
When I run the following, the buffer0 prints out the movement of the mouse in the Y direction and the buffer1 prints a constant.  When I stop mouse movement and press it's button, buffer0 prints the current X location and buffer1 prints the current Y location.  Can someone please tell me what I am doing incorrectly?  Thanks a million.
Warren Trammell

#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
    char buffer0[25],buffer1[25];

    sf::RenderWindow window(sf::VideoMode(2300, 1300), "SFML window");
   
    sf::Font font;
    if (!font.loadFromFile("/users/warren/programming/projects/impact.ttf"))        return EXIT_FAILURE;
   
    sf::Text text;
    text.setFont(font);
    text.setCharacterSize(50);
    text.setColor(sf::Color::Red);
   
    window.clear(sf::Color(128,128,128));
       
    window.display();

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
           switch (event.type)
            {
                case sf::Event::Closed:
                    window.close();
                    break;
            }
                 
 
        }
       
        window.clear(sf::Color(128,128,128));
       
        sprintf(buffer0,"%i",event.mouseWheel.x);
        sprintf(buffer1,"%i",event.mouseWheel.y);
       
        text.setString(buffer0);
        text.setPosition(500,600);
        window.draw(text);
       
        text.setString(buffer1);
        text.setPosition(1000,600);
        window.draw(text);
       
        window.display();
       }
      return EXIT_SUCCESS;
}

7
Graphics / SFML 2.0 0n MAC
« on: May 26, 2013, 12:04:54 am »
I just installed the latest version.  My old program user 2-dim arrays Array[200][200].  The new version will not accept this so I discovered on line how to use vectors  to define it.
std::vector< std::vector<int> > Array(200, std::vector<int>(200));
However, my source looks like this
ncx = 0; ncy = 0;
for (x = 0; x < 1000; x = x + 100)
    {
    for y = 0; y < 1000; y = y+100))
        {
        Array[ncx][ncy] = variable;
         ncy++;
        }
    ncx++;
    }
It compiles  but gives a run time error.   Bad index
Any suggestions?
Thanks
Warren

8
General / SFML 2.0 0n MAC
« on: May 10, 2013, 05:47:46 pm »
Hi
I  down loaded file SFML 2.0 Clang (OS X 10.5+)
on a machine using OSX 10.8.3 and Xcode 4.6.2.
I followed the instructions in paragraph "Installing SFML" from the tutorial.
In Xcode I chose the options shown in the tutorial for a new project.
The project navigator displays all the files shown in tutorial.
After compile:
Messages shown read:
/Users/Warren/Library/Developer/Xcode/DerivedData/MyFirstSF MLApp etc etc etc.
This directory doesn't exist on my machine.

25 Errors read:
Apple Mach -O Linker (ld) Error etc etc etc.
Any one else having this problem with this configuration?

Thanks
Warren Trammell

9
General / SFML 2.0
« on: May 09, 2013, 02:58:27 am »
I am running OSX  10.8.3 & Xcode 4.6.2 (clang)
I downloaded   SFML 2.0 ((MAC OS X Clang (OS X 10.8+).
I installed the various files in their respective places (FRAMEWORKS etc.)
What else do I need to do?
Specify location of Tutorial or specific instructions for a newbee please.

Warren Trammell

10
Graphics / App.display
« on: December 10, 2012, 07:17:00 pm »
In version 2.0 does the command App.display write to the screen the most recent App.draw item defined or does it re display all previous App.draw items.
Thanks a bunch.
Warren Trammell

11
General / Compiling & Linking
« on: October 13, 2012, 07:35:16 pm »
Hi
The following commands work great to create a file to run on my computer.

g++ -F /Library/Frameworks -c main.cpp
g++ main.o -framework sfml-window -framework sfml-graphics -framework sfml-system -o mark

What commands do I need to get a file to run on my son's MAC?
Thanks a heap.
Warren Trammell

12
General / X code 4.3.1
« on: March 20, 2012, 12:24:19 am »
Hi
Just installed new version of Xcode.  Do I reinstall SFML to get it into the new version of Xcode?
Thanks
Warren

13
Graphics / Sending variables to the screen
« on: March 31, 2011, 12:09:17 am »
I am new at this so I put together a few lines of code to place digits (0 - 9) to the screen sequentially.  However it did not come out that way.  The program cycles continously but only writes to the screen when a key is pressed.  Would some one point out my error in the code please? Thanks
Warren Trammell


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

int main()
{
int x = 0, y = 0, count = -1;
char buffer[10];

    // Create main window
    sf::RenderWindow App(sf::VideoMode(1600, 900), "SFML Fonts");

  // Clear screen
App.Clear(sf::Color(128,128,128));

    // Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("/users/warren/projects/impact.ttf", 50))
        return EXIT_FAILURE;

    // Start game loop
    while (App.IsOpened())
    {
count++;
if(count > 9) count = 0;

    // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
             x = x + 50;
if(x > 1500)
{
x = 0;
y = y + 50;
}

// Create a graphical string
sf::String Text;
sprintf(buffer,"%i",count);
Text.SetText(buffer);
Text.SetFont(MyFont);
Text.SetColor(sf::Color::Black);
Text.SetPosition(x, y);
Text.SetSize(50);

// Draw our strings
App.Draw(Text);

// Finally, display rendered frame on screen
App.Display();
           
  // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

        }
}

    return EXIT_SUCCESS;
}

14
Graphics / pixel color
« on: February 18, 2011, 05:15:05 pm »
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(640, 480), "SFML Graphics");

    // 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();
        }

        // Clear screen
        App.Clear(sf::Color(128,128,255));

        // Draw apredefined shape
        App.Draw(sf::Shape::Circle(200, 200, 100, sf::Color::Yellow, 10, sf::Color::Blue));

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

    return EXIT_SUCCESS;
}

Will someone please add the lines of code required to get the color of the pixel at x = 100, y = 100?
I can not find it in the tutorials.
Thanks a bunch.
Warren

15
General discussions / Graphics vs window based
« on: January 27, 2011, 05:26:13 pm »
I have done some simple C++ on a MAC with an Intel processor and now wish to try SFML.  I down loaded and installed and down loaded the tutorial Getting Started.  It is very good but I have one question.  What determines whether I choose Graphics based or Window based option?
Thanks
Warren Trammell

Pages: [1] 2
anything