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

Pages: 1 [2] 3 4
16
Network / SFML UDP packet fragmentation
« on: February 08, 2013, 04:56:23 pm »
Does the sf::UdpSocket and sf::Packet handle packet fragmentation?

Couldn't find any data on this in the documents.

17
General discussions / The new time API
« on: January 14, 2012, 02:32:33 am »
I don't see any pause? :- (

And a interval with a callback like C# timers would be nice, but I guess I could just convert my old class.

18
Graphics / Using View instead of translating all Box2d coordinates
« on: January 13, 2012, 09:45:40 pm »
Yea, changed to that method now. First I did it so the server would get less load but then I tought about the sending int vs. float to the client.

But I still got a problem.. I don't want to replicate static objects.

So on the server I got this
Code: [Select]

b2BodyDef bodydef;
bodydef.type = b2_dynamicBody;
//bodydef.type = b2_staticBody;
bodydef.position.Set(0,0);
b2Body* body = world.CreateBody(&bodydef);
b2PolygonShape box;
box.SetAsBox(184.0f * METERS_PER_PIXEL, 230.0f * METERS_PER_PIXEL);
b2FixtureDef fixdef;
fixdef.shape = &box;
fixdef.density = 1.0f;
fixdef.friction = 0.3f;
body->CreateFixture(&fixdef);

// this will not be sent to the client
b2BodyDef gdef;
gdef.type = b2_staticBody;
gdef.position.Set(0,(230.f * 2.f) * METERS_PER_PIXEL);
b2Body* ground = world.CreateBody(&gdef);
b2PolygonShape gbox;
gbox.SetAsBox(3.f, 0.1f);
ground->CreateFixture(&gbox, 0.0f);


and this is how I set the position on the client for the static body

Code: [Select]

// static body
sf::RectangleShape rs;
rs.SetSize(sf::Vector2f(3.f*64.f, 1.f * 64.f));
rs.SetOrigin((3.f * 64.f) / 2.f, (1.f * 64.f) / 2.f);
rs.SetPosition(0.f, 230.f * 2.f);
rs.SetFillColor(sf::Color::Blue);

// dynamic body - gets updated behind the scenes
sf::Texture img;
img.LoadFromFile("C:\\MyGameEngine\\Assets\\test.jpg");

sf::Sprite spr(img);
spr.SetOrigin(92, 115);


But when they collide serverside and the client paints them there is still something like 30-40 pixels between them.. Soo there have to be something wrong in my converting of the positions. Anyone care to help me out here?  :)

edit:
forgot to mention that I'm going with 64pixels = 1meter in box2d

Edit: Found out why.. Find my typo and see how retarded I am. Then range my retardness 1 - 10.

19
Graphics / Using View instead of translating all Box2d coordinates
« on: January 13, 2012, 04:28:07 pm »
Quote from: "Haikarainen"
I honestly think something else than views would work better. How is the code looking so far, from the point where you receive data in your client to the point where you position your objects?


Right now the server just sends the position of a b2Body(a box2d body) to the clients. Now rendering yet. But I don't want to always have in mind that the position needs to be converted.

[1] So I either want to use some kinda view that automagically does the converting for me, [2] or I need to implent a "interceptor" for the packets recvied from the server which converts the positions before they are passed on.

[1] Would have a little delay on the drawing, but not much. And would be much "nicer" that option 2.

[2] Not sure if I even wanna go down this road.

20
General / Mini-framework AppState rendering problem
« on: January 12, 2012, 05:39:05 pm »
Pretty sure you have to make your own..
But, atleast in XNA world, it was pretty easy..

Something like this, pseudo code.
Code: [Select]

class GameState
{
public:
virtual Update();
virtual Draw();
virtual Start();
virtual End();
};

class GameStateManager
{
public:
std::stack<GameState*> m_GameStatss;
void pushState(GameState* gs) { m_GameStates.push_back(gs); gs->Start(); }
void popState() { m_GameStates.last()->End(); m_GameStates.pop_back(); }
GameState* getCurrentState() { return m_GameStates.peek(); }
}

int main()
{
while(mainLoop)
{
 GameStateManager.getCurrentState()->Draw();
 GameStateManager.getCurrentState()->Update();
}


Then you could implent like "bool blockDrawing", "bool blockUpdate" so that if theMenuState is pushed over theGameState you can still update, but not draw, the theGameState in the background(Like multiplayer games).

21
Graphics / Using View instead of translating all Box2d coordinates
« on: January 12, 2012, 05:31:12 pm »
Hi

I'm implenting a client-server platformer I decided to use box2d for physics.
So the server calculates the physics then sends the positions to the client which are interpolated to reduce lag, blah blah,.. But my problem is that I decided that having something like 50pixels or 64pixels = 1m i box2d. The problem then is that the client have to convert all the positions..

Soo then I tought of the sf::View. Can I use this in some way to "magically convert" all the positions getting drawn.

Code: [Select]

sf::View view(MagicGoesHere);
App.SetView(view);
while(true)
{
//rendering by just drawing the position recived from the server which
//is box2d body positions
}

22
Feature requests / Link List for multi-frame (image) sprites
« on: January 12, 2012, 05:12:05 am »
This is old.. and if you want it, code it your self.. A linked list is easy to do.
And then you just need to add the data like, frame size, time per frame, and define where each animation is.

23
Graphics / Can't figure out 'undefined reference'
« on: October 05, 2011, 07:28:09 pm »
Dynamic linking. Debug.

"Project Build Options"
Linker settings
sfml-graphics-d
sfml-window-d
sfml-system-d
sfml-audio-d
sfml-network-d

"Compiler and debugger" -> "Global compiler settings" -> "Search Directories"
[Compiler]
D:\SFML2\sfml\sfml2\include\

[Linker]
D:\SFML2\my_build\lib\

24
Graphics / Can't figure out 'undefined reference'
« on: October 05, 2011, 07:15:44 pm »
I have told it where the libs are and where the header files are.. I'm already using sf::Shape and sf::Vector and some other SFML classes without any problem

?_?

25
Graphics / Can't figure out 'undefined reference'
« on: October 05, 2011, 06:59:34 pm »
Hi

Here is my code
Code: [Select]

sf::Image treeImage;
if(!treeImage.LoadFromFile("D:\\sfml\\textures\\tree_large.png"))
{
    std::cout << "[Image] Could not load 'tree_large.png'" << std::endl;
}


The problem is that CodeBlocks just spits out;

Code: [Select]

obj\Debug\main.o||In function `main':|
D:\sfml\YetAnotherTest\main.cpp|60|undefined reference to `_imp___ZN2sf5ImageD1Ev'|
D:\sfml\YetAnotherTest\main.cpp|60|undefined reference to `_imp___ZN2sf5ImageD1Ev'|
||=== Build finished: 2 errors, 0 warnings ===|


And for the life of me I can't figure out why it ain't linking  :(  :oops:

26
Feature requests / sf::Vector2 Empty value
« on: October 05, 2011, 04:18:46 pm »
Hi

I think SFML should have something like XNA vectors. A empty value. Like this(or similar):

Code: [Select]

sf::Vector2f emptyVector = sf::Vector2f::Empty;


Since it is not possible to return NULL from e, ex., search function that didn't find any result.

27
General / Help with CB and SFML2
« on: October 04, 2011, 04:25:21 pm »
**** dat shit, im building mah own

28
General / Help with CB and SFML2
« on: October 04, 2011, 04:18:52 pm »
Can't find it there either.. However there is a 'libgcc_s_sjlj-1.dll'.. What now? Swap IDE, again?  :lol:

29
General / Help with CB and SFML2
« on: October 04, 2011, 04:09:45 pm »
Forgot to link in the files in the project settings.

But now I'm getting "The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem."

Re-installing CodeBlocks didnt help..

30
General / Help with CB and SFML2
« on: October 04, 2011, 02:43:35 pm »
Soo I downloaded the pre-built bins from this blog;
http://sfmlcoder.wordpress.com/2011/05/18/creating-a-first-sfml-project/

But when I try to compile I just get this error;
Code: [Select]
obj\Debug\main.o||In function `main':|
d:\PEngine\TestProject_SFML\main.cpp|5|undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
d:\PEngine\TestProject_SFML\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsmRKNS_15ContextSettingsE'|
d:\PEngine\TestProject_SFML\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
d:\PEngine\TestProject_SFML\main.cpp|15|undefined reference to `_imp___ZN2sf6Window5CloseEv'|
d:\PEngine\TestProject_SFML\main.cpp|10|undefined reference to `_imp___ZN2sf6Window9PollEventERNS_5EventE'|
d:\PEngine\TestProject_SFML\main.cpp|22|undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
d:\PEngine\TestProject_SFML\main.cpp|22|undefined reference to `_imp___ZN2sf12RenderTarget5ClearERKNS_5ColorE'|
d:\PEngine\TestProject_SFML\main.cpp|23|undefined reference to `_imp___ZN2sf6Window7DisplayEv'|
d:\PEngine\TestProject_SFML\main.cpp|7|undefined reference to `_imp___ZNK2sf6Window8IsOpenedEv'|
d:\PEngine\TestProject_SFML\main.cpp|26|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
d:\PEngine\TestProject_SFML\main.cpp|26|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
||=== Build finished: 11 errors, 0 warnings ===|


Helpz?

Pages: 1 [2] 3 4