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 - Pwndja

Pages: [1] 2
1
Window / Holding down Lots of keys
« on: April 02, 2010, 05:23:17 am »
I am currently using 6 different keys in my app: [W, S, D, A, Left, Right]

Now when I push them all down they should still all work. But the S key does not registar. I changed the S key to be the X key and then all the keys work. It is only when I us the S key that they all do not work... That is all except the S key works. With the X = S key they all Work and when S = S key they all work except the S key. It is like it just skips the S key statement.

Code example:
Code: [Select]

while(1)
{

if (App.GetInput().IsKeyDown(sf::Key::W)) //do something
if (App.GetInput().IsKeyDown(sf::Key::S)) //do something ** this does not execute **
if (App.GetInput().IsKeyDown(sf::Key::D)) //do something
if (App.GetInput().IsKeyDown(sf::Key::A)) //do something
if (App.GetInput().IsKeyDown(sf::Key::Left)) //do something
if (App.GetInput().IsKeyDown(sf::Key::Right)) //do something
}


In the above example when I press all the keys: W, S, D, A, Left, Right everything executes except the S key.

But when I do this:

Code: [Select]
while(1)
{
if (App.GetInput().IsKeyDown(sf::Key::W)) //do something
if (App.GetInput().IsKeyDown(sf::Key::X)) //do something ***X Key Now***
if (App.GetInput().IsKeyDown(sf::Key::D)) //do something
if (App.GetInput().IsKeyDown(sf::Key::A)) //do something
if (App.GetInput().IsKeyDown(sf::Key::Left)) //do something
if (App.GetInput().IsKeyDown(sf::Key::Right)) //do something
}


They all work.

Any Ideas why this might be?

2
Feature requests / XML parsing
« on: November 23, 2009, 03:13:18 pm »
It would be nice to have XML parsing code incorporated into SFML. Especially since most people use SFML to develop games, and most good game developers use a data-driven approach, which helps keep things simpler and modular. it would help promote and facilitate data driven models.

Here is a quick blog about some of the benefits:

http://gameylittlehacker.blogspot.com/2007/01/data-driven-game-architecture.html

3
Feature requests / 3D additions
« on: November 23, 2009, 01:46:31 am »
I think you should dive into making an API for 3D coding much like your have tackled the 2D Image and sprite API. I understand you have created an option for OpenGL commands to be integrated into your SFML code, but it would be nice to see your spin on an C++ encapsulated 3D  API class structure.

4
Feature requests / Can SFML be used in java?
« on: January 16, 2009, 01:56:37 am »
I was wondering if SFML could be used in java? AND if it cannot be I would like to request that to have the ability to adapt it to java applications. I want to program for the new google phone Android and wanted to use the SFML libs if at all possible to port some of my already build code to the phone.

Thanks for any response in advance.

5
Audio / Audio support?
« on: August 22, 2008, 01:04:55 am »
I was wondering if you could fill in the "and a lot more" part in the Features->Audio section of the SFML website. Could you elaborate on what "and a lot more" includes? does this include mp3s?

Quote
Can load and save standard sound formats : ogg, wav, aiff, au, raw, and a lot more

6
Network / Broadcasting a Server
« on: July 24, 2008, 08:28:58 pm »
If I want to have a server broadcast its IP address to my clients how would I go about doing this.
I am using UDP sockets. I want to be able to have a server running and wait for clients to connect to it, but I don't want the client side to have a static server IP address in my code, instead I would like to have the client find the server's address.
Another thing is it only has to find the server on a LAN NOT through the internet or a DNS name.

any advice or help is much appreciated.

Thanks in advance

7
General discussions / Idling a program
« on: July 21, 2008, 09:34:53 pm »
I was wondering how to idle a SFML program (or a C++ program) so that I am not using 100% of my CPU when I run my while loop which displays all my sprites and takes care of my inputs and such. Any help is much appreciated.

I play video games like supreme commander, oblivion and such and i rarely see the CPU continuously running at 100% so I know my simple programs should be able to run with much less CPU processing.

thanks in advance.

8
Feature requests / Network tutorial request
« on: July 01, 2008, 08:22:58 pm »
Could you make a tutorial which shows a UDP server client setup in which the server waits for clients to connect to it and when clients connect to the server they can send requests from a menu like

"Enter 1-3 for options"
"1) server will send you hello"
"2) server will send you goodbye"
"3) server will send you 1234"

"prompt user input:"

And the server would send back either hello, goodbye, or 1234 according to the client's sent input.

if you could do this for me that would be great because it will help me understand what you had in mine when trying to communicate between the client and server sending messages back and forth between them.

I hope to be able to take this tutorial and then change it up a bit so that I will eventually be able to have multiple clients connect to the server and then be able to send to the server up down left right commands so that the server can keep track of sprites on a 2d map, then send the coordinates of all the connect clients back to each client so that everyone can see where everyone is on the map. (hopefully that makes sense.

I really just need to know how to send data to the server and be able to reply to a client's sent data appropriately and at the same time continuously broadcast everyone's coordinates on a 2d map.

Thank you in advance

9
Network / Network linking error
« on: February 15, 2008, 06:53:43 am »
Here is the error I get when I try to use the GetSocketsReady() for a SelectorTCP

error LNK2019: unresolved external symbol ___WSAFDIsSet@8 referenced in function "public: bool __thiscall sf::Selector<class sf::SocketTCP>::GetSocketsReady(class std::vector<class sf::SocketTCP,class std::allocator<class sf::SocketTCP> > &,float)" (?GetSocketsReady@?$Selector@VSocketTCP@sf@@@sf@@QAE_NAAV?$vector@VSocketTCP@sf@@V?$allocator@VSocketTCP@sf@@@std@@@std@@M@Z)

here is the code where it is messing up at:

Code: [Select]
std::vector<sf::SocketTCP> readySockets;
while(1)
{

server.GetSocketsReady( readySockets ); //This line here is what is causing the error.

for (std::vector<sf::SocketTCP>::iterator i = readySockets.begin(); i != readySockets.end(); ++i)
{
}
}


any ideas on how to solve this problem?

10
Network / Networked program runs really SLOW
« on: February 02, 2008, 06:13:08 am »
so i made a quick little pong game and made it networked, and it runs fine when i run the client and the server on one computer but when i run it on another computer on my local network it becomes horribly slow... we are talk about one pixle every five seconds (Thats really really slow lol)
I was wondering if there is some trick code that i am leaving out that makes the networked code run faster... kick of like the OptimizeForNonOpenGL() line with renderedwindow.

Any feed back on why my code runs soo slow over a local network would be great.

I know that IP/TCP is slower than UDP but i didn't think that sending the small packet like i am across would cause things to clog up as much as it does.



Here is my code for the pong game:

Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

#define _CRT_SECURE_NO_WARNINGS

#define paddle_speed 2
#define ballspeed 0.3

struct data
{
float x;
float y;
int message;
};


sf::Packet& operator <<(sf::Packet& Packet, const data& C)
{
    return Packet << C.x << C.y << C.message;
}

sf::Packet& operator >>(sf::Packet& Packet, data& C)
{
return Packet >> C.x >> C.y >> C.message;
}

////////////////////////////////////////////////////////////
/// Create a client and connect it to a running server
///
////////////////////////////////////////////////////////////
void DoClientTCP(unsigned short Port)
{
sf::RenderWindow app( sf::VideoMode( 800, 600 ),"Client", sf::Style::Resize );
app.SetBackgroundColor( sf::Color(0,0,0) );


sf::Image img;
sf::Image ball;
img.LoadFromFile( "left_paddle.png" );
ball.LoadFromFile( "ball.bmp" );

sf::Sprite spr[2];
sf::Sprite sprball;

spr[0].SetImage( img );
spr[0].SetPosition( 10.f , 10.f );

spr[1].SetImage( img );
spr[1].SetPosition( 790.f - spr[1].GetWidth(), 10.f );
spr[1].FlipX( true );

sprball.SetImage( ball );
sprball.SetPosition( 400.f, 300.f );

// Ask for server address
sf::IPAddress ServerAddress;
do
{
std::cout << "Type address or name of the server to connect to : ";
std::cin  >> ServerAddress;
}
while (!ServerAddress.IsValid());

// Create a TCP socket for communicating with server



sf::SocketTCP Client;

// Connect to the specified server
if (!Client.Connect(Port, ServerAddress))
return;
std::cout << "Connected to server " << ServerAddress << std::endl;

// Receive a message from the client
int ToSend = 0;
int Message = 0;
//std::size_t Received;
float ball_x = 400.f, ball_y = 300.f;
float ball_Xdelta = ballspeed, ball_Ydelta = ballspeed;

bool key = false;
bool running = true;
while( running )
{

if( app.GetInput().IsKeyDown( sf::Key::Down ) )
{
ToSend = 1;
spr[1].SetTop( spr[1].GetTop() + paddle_speed );
}

if( app.GetInput().IsKeyDown( sf::Key::Up ) )
{
ToSend = 2;
spr[1].SetTop( spr[1].GetTop() - paddle_speed );
}
if( !app.GetInput().IsKeyDown( sf::Key::Up ) && !app.GetInput().IsKeyDown( sf::Key::Down ) )
{
ToSend = 0;
}
if( app.GetInput().IsKeyDown( sf::Key::Escape ) )
{
running = false;
}
data send;
send.message = ToSend;
send.x = 0.0f;
send.y = 0.0f;
sf::Packet sendPacket;
sendPacket << send;
Client.Send( sendPacket );

//if (Client.Receive(Message, sizeof(Message), Received) != sf::Socket::Done)
//return;
sf::Packet dataPacket;
if( Client.Receive( dataPacket ) != sf::Socket::Done )
return;
data dat;
if( !(dataPacket >> dat) )
{
std::cout << "ERROR" << std::endl;
}
ball_x = dat.x;
ball_y = dat.y;
Message = dat.message;

// move other players paddle
if( Message == 1 )
{
spr[0].SetTop( spr[0].GetTop() + paddle_speed );
}
if( Message == 2 )
{
spr[0].SetTop( spr[0].GetTop() - paddle_speed );
}

ball_x += ball_Xdelta;
ball_y += ball_Ydelta;

sprball.SetPosition( ball_x, ball_y );

app.Draw( sprball );
app.Draw( spr[1] );
app.Draw( spr[0] );

app.Display();
}

// Close the socket when we're done
Client.Close();
}


////////////////////////////////////////////////////////////
/// Launch a server and wait for incoming connections
///
////////////////////////////////////////////////////////////
void DoServerTCP(unsigned short Port)
{
sf::RenderWindow app( sf::VideoMode( 800, 600 ),"Server", sf::Style::Resize );
app.SetBackgroundColor( sf::Color(0,0,0) );


sf::Image img;
sf::Image ball;
img.LoadFromFile( "left_paddle.png" );
ball.LoadFromFile( "ball.bmp" );

sf::Sprite spr[2];
sf::Sprite sprball;

spr[0].SetImage( img );
spr[0].SetPosition( 10.f , 10.f );

spr[1].SetImage( img );
spr[1].SetPosition( 790.f - spr[1].GetWidth(), 10.f );
spr[1].FlipX( true );

sprball.SetImage( ball );
sprball.SetPosition( 400.f, 300.f );

// Create a TCP socket for communicating with clients



sf::SocketTCP Server;

// Listen to a port for incoming connections
if (!Server.Listen(Port))
return;
std::cout << "Server is listening to port " << Port << ", waiting for connections... " << std::endl;

// Wait for a connection
sf::IPAddress ClientAddress;
sf::SocketTCP Client;
if (Server.Accept(Client, &ClientAddress) != sf::Socket::Done)
return;
std::cout << "Client connected : " << ClientAddress << std::endl;

// Send a message to the client
int ToSend = 0;
int Message = 0;
std::size_t Received;
float ball_x = 400.f, ball_y = 300.f;
float ball_Xdelta = ballspeed, ball_Ydelta = ballspeed;

bool key = false;
bool running = true;

while(running)
{
if( app.GetInput().IsKeyDown( sf::Key::S ) )
{
ToSend = 1;
spr[0].SetTop( spr[0].GetTop() + paddle_speed );
}

if( app.GetInput().IsKeyDown( sf::Key::W ) )
{
ToSend = 2;
spr[0].SetTop( spr[0].GetTop() - paddle_speed );
}
if( !app.GetInput().IsKeyDown( sf::Key::W ) && !app.GetInput().IsKeyDown( sf::Key::S ) )
{
ToSend = 0;
}
if( app.GetInput().IsKeyDown( sf::Key::Escape ) )
{
running = false;
}
data dat;
dat.x = ball_x;
dat.y = ball_y;
dat.message = ToSend;
sf::Packet dataPacket;
dataPacket << dat;
Client.Send( dataPacket );
//Client.Send( ToSend, sizeof(ToSend) );

sf::Packet receivePacket;
if (Client.Receive(receivePacket) != sf::Socket::Done)
return;
data rec;
receivePacket >> rec;

Message = rec.message;

//collision statements here
if( sprball.GetTop() < 0 || sprball.GetTop() > 600 )
{
ball_Ydelta = -ball_Ydelta;
}

if( sprball.GetLeft() + (sprball.GetHeight() / 2) < 20 && (spr[0].GetTop() < sprball.GetTop() +(sprball.GetHeight() / 2) && sprball.GetTop()  + (sprball.GetHeight() / 2) < spr[0].GetTop() + spr[0].GetHeight() ) )
{
ball_Xdelta = -ball_Xdelta;
}
if( sprball.GetLeft() + (sprball.GetHeight() / 2) > 780 && ( spr[1].GetTop() < sprball.GetTop() + (sprball.GetHeight() / 2) && sprball.GetTop() + (sprball.GetHeight() / 2) < spr[1].GetTop() + spr[1].GetHeight() ) )
{
ball_Xdelta = -ball_Xdelta;
}
//end collision statements

// move other players paddle
if( Message == 1)
{
spr[1].SetTop( spr[1].GetTop() + paddle_speed );
}
if( Message == 2 )
{
spr[1].SetTop( spr[1].GetTop() - paddle_speed );
}

ball_x += ball_Xdelta;
ball_y += ball_Ydelta;

sprball.SetPosition( ball_x, ball_y );

app.Draw( sprball );
app.Draw( spr[1] );
app.Draw( spr[0] );

app.Display();
}

// Close the sockets when we're done
Client.Close();
Server.Close();
}

11
General discussions / Gving out my exe
« on: February 01, 2008, 02:27:16 am »
What all do i need to have with my exe that i have compiles from my code using SFML in order to run the exe on other computers with out all the sfml dlls and libs and includes?

12
Network / Getting a window and networking to work
« on: January 31, 2008, 10:13:54 am »
Hi I was wondering if you would make a simple program that would display a blank window and would allow you to press the a key to send a message from the server to a client and visa versus.

I have been trying to get a window and some networking working but cant seem to get the input to work correctly. I have basically this:

Code: [Select]
while(1)
{
if( app.GetInput().IsKeyDown( sf::Key::A ) && key != true )
{
ToSend = "a";
key = true;
}
if( !app.GetInput().IsKeyDown( sf::Key::A ) && key != true )
{
key = true;
}

if (Client.Send(ToSend.c_str(), sizeof(ToSend.c_str())) != sf::Socket::Done)
return;
std::cout << "Message sent to the client : \"" << ToSend << "\"" << std::endl;

// Receive a message back from the client

if (Client.Receive((char*)Message.c_str(), sizeof(Message.c_str()), Received) != sf::Socket::Done)
return;

// Show the message
std::cout << "Message received from the client : \"" << Message << "\"" << std::endl;
app.Display();
}



in hopes that pressing the 'a' key would change teh sent data to "a" instead of "test" or "test client".

If you have time and it is not too much of a hassle could you put together a tutorial or some code which sends data across when you hit a key.
Thank you.
[/code]

13
Window / changing the upper right hand corner image?
« on: January 11, 2008, 07:59:03 am »
How do I change the upper right hand corner image?
I have read through all the appropriate docs and tutorials and I can't find what is needed with sfml to do that.

14
Graphics / Better way to draw to the screen
« on: September 22, 2007, 12:19:18 am »
here is the code which i am running in my main loop

        float width = 0.0;
   float height = 0.0;
   //window.Display();
   for( unsigned int i = 0; i < 60; ++i )
   {
      for( int j = 0; j < 80; j++)
      {
         width += 10;
         mapSprites[mapInts[j]].SetLeft( width );
         mapSprites[mapInts[j]].SetTop( height );
         window.Draw( mapSprites[mapInts[j]] );
      }
      height += 10;
      width = 0;
   }


i was wondering if there is a better way to draw to the screen or redraw the screen without drawing every sprite over again. So maybe only drawing one sprite that has changed over again instead of redrawing all the sprites over again.

Is there a function which draws just portions of the screen and keeps everything else on the screen?

And if not could that be a feature added in for the next release?

thanks

happy coding

15
Graphics / Font list
« on: September 18, 2007, 10:59:15 pm »
Hey I was wondering if I could get a list of all the font extensions that SFML uses

the only ones listed on the feature page are these ones

Easy manipulation of graphical text through bitmap fonts ; supports unicode characters and standard font file formats (ttf, cff, pcf, bdf, ...)

thanks

Pages: [1] 2
anything