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.


Messages - Pixel_Outlaw

Pages: 1 2 3 [4]
46
General / Please evaluate my code for correctness + Visual C++ 2010
« on: December 18, 2010, 08:47:56 am »
I've been hard at work trying to learn different functions and such. For some odd reason my computer is running this demonstration at around 45 frames per second according to FRAPs. Now, I'm using Visual C++ 2010 in debug mode. I watched the installation video on Youtube to recompile the 2008 files.

I have several beginners questions.
1. How do I create a release version of a program with SFML? Currently I just use the -s-d extensions as shown in the video.

2. Any ideas why this runs at 45 frames per second when I have locked it to 60? (Windows XP Service pack 3, 2 GB RAM, AMD Athlon 64 processor.)

3. Please let me know any bad habits I have started here while trying to teach myself this library.

Code: [Select]


#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>



class Player
{
public:
//positions
int x;
int y;
// for grabbing parent window events
sf::RenderWindow * parent_window;

Player(int start_x, int start_y, sf::RenderWindow * window)
{
x = start_x;
y = start_y;
parent_window = window;
}

void update()
{
// move the player in the window
const sf::Input& input = parent_window->GetInput();


// use the sums of the key directions to figure out movement
x -= (input.IsKeyDown(sf::Key::Left)-input.IsKeyDown(sf::Key::Right)) * 8;
y -= (input.IsKeyDown(sf::Key::Up)-input.IsKeyDown(sf::Key::Down)) * 8;

sf::Shape my_shape = sf::Shape::Circle(x,y, 16, sf::Color(255,0,255));
parent_window->Draw(my_shape);

}

~Player(){};
};

int main()
{

sf::RenderWindow main_window(sf::VideoMode(800, 600, 32), "Demo");
main_window.SetFramerateLimit(60);
main_window.UseVerticalSync(true);

Player the_player(400,300,&main_window);

while(main_window.IsOpened())
{
main_window.Clear();
sf::Event main_window_event;

// Process events
        while (main_window.GetEvent(main_window_event))
        {
            // Close window : exit
            if (main_window_event.Type == sf::Event::Closed)
{
                main_window.Close();
}
        }

// update the player
the_player.update();

        // Display window contents on screen
        main_window.Display();
}

    return 0;
}


47
General / Is it possible to make a multi monitor game?
« on: December 16, 2010, 10:31:49 pm »
I'm short an extra monitor right now or I would be able to test this. A large window on each screen would be acceptable. I want this to be as immersive as possible and even thought about making little dedicated pvc pipe and black cloth booths for each screen with a chair and joystick inside. Make them feel like they are inside a space tank.  :P

This is all just theory until I can find out if this will work or not.

48
General / Is it possible to make a multi monitor game?
« on: December 16, 2010, 10:12:40 pm »
I was really happy to find that SFML allows for multiple rendering windows.

I've always enjoyed the game Battlezone which is a first person wireframe tank game designed in the 80's. I know that SFML is up to the challenge of rendering some wireframe models (With OpenGL if necessary). My dream for some time is to make a Battlezone game for 3 people. I know it could be done with some networking but I don't have much training in that area. Instead I was wondering if I could use a single machine and output to 3 different monitors at once, each holding the view of a different player. I would plan on using Windows XP as the operating system. I heard that SFML supports 4 joysticks now. This would be great for this project.

Would it be possible to construct a game that dynamically renders 3 different viewports to 3 monitors from a single machine?

49
Graphics / Drawing with shape and color objects.
« on: December 15, 2010, 10:18:44 am »
OK thanks for the great library and help.  Would much be gained from using a single line object and reassigning the x and y values inside each for loop step? I'm just curious...

50
Graphics / Drawing with shape and color objects.
« on: December 15, 2010, 09:35:23 am »
First let me say that SFML will be my first venture into multimedia with C++. I'm a college student and I have toyed with C++ off and on for some time. SMFL presents an exciting way to actually DO something with a programming language.  :D

Now I have looked through the tutorials a bit and have been adding and playing with the different functions. My biggest question is the use of the graphics objects and the color objects. Am I supposed to make a new graphics object and color object every time I want to draw something? Isn't this quite a lot of overhead? I guess I'm used to the state machine approach where the set color affects all following routines untill changed.

Here is my code, please tell me if I am abusing something here.

Code: [Select]


#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>


int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
// use a set framerate
App.UseVerticalSync(true);
App.SetFramerateLimit(60);

// incrimenter
float inc = 0;

// 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 the screen (fill it with blue color)
App.Clear(sf::Color(0,0,64));
inc += .25; // move the counter
if(inc >= 360)
{
inc -= 360;
}

// wavy warp effect
float step = 0;
for(float i = 0; i<360; i += 3)
{
step = i/32;
sf::Color my_color(0,255 - i/360 * 255, i/360 * 255);
sf::Shape my_line = sf::Shape::Line(cos(inc+step)*32+32, i, cos(inc+step)*32+480, i, 1, my_color, false, my_color);
App.Draw(my_line);
}
// Display window contents on screen

App.Display();
}

return EXIT_SUCCESS;
}

Pages: 1 2 3 [4]
anything