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

Pages: 1 ... 6 7 [8] 9 10 ... 15
106
Graphics / Re: Afterimages while fast scrolling screen
« on: January 08, 2014, 07:55:48 pm »
I had issues my self similar to theese my gpu was set to force some stuff like motion blur etc...
Thus giving me unclear screen when moving view fast.

107
Graphics / Re: OpenGL application lag
« on: January 06, 2014, 09:00:35 pm »
The code is not compilable without spriteBatch class.
Looking deeper i see sf::Sprite has a line using
"SetColor"
The current version of sfml is using
"sf::Sprite::setColor"
if you are using older version of sfml be sure to note that.

108
Graphics / Re: two questions: "collision-stop-detect" and "random move"
« on: January 06, 2014, 08:45:39 pm »
Its it fine question to ask, i handled my movement and collision this way:

I did the movement like this.

Pseudo code
Code: [Select]
bool inputW, inputS, inputA, inputD;//This user uses to issue commands to the unit

//At unit code for movement
void LoopUnitsLogic()
{
int destinationX = unit.getPosX();
int destinationY = unit.getPosY();

if(inputW)//Check if the user issued for this unit to move up
{
destinationY -= unit.getMovementRate();//Notice the - it is because we are moving upwards
}
else if(inputS)//It is simple finish it!

if( Check_If_Position_Walid(destinationX, destinationY) )
{
unit.moveTo(destinationX, destinationY);
}
}

bool Check_If_Position_Walid(int posX, int posY)
{
//In here i was a cheeky little bas... and i was smart enough to grab the tiles my unit was standing on and check only those so i didn't have to look true the whole map because it was big
}
Do not use real time events, the sprites will look like they are having seizures!
Quote
Sometimes, people try to react to KeyPressed events directly to implement smooth movement. Doing so will not produce the expected effect, because when you hold a key you only get a few events (remember, the repeat delay). To achieve smooth movement with events, you must use a boolean that you set on KeyPressed and clear on KeyReleased; you can then move (independently of events) as long as the boolean is set.
The other (easier) solution to produce smooth movement is to use real-time keyboard input with sf::Keyboard (see the dedicated tutorial).

109
Graphics / Re: OpenGL application lag
« on: January 06, 2014, 08:27:34 pm »
Provide with minimal example code.

60 fps = 16.66... sec per frame so that and everything else seams good.
I do not see the issue you getting "lag" with openGL application, are you using network?

110
SFML projects / Re: Alife - Artificial Life Simulation
« on: January 06, 2014, 04:30:01 pm »
Will upload it to SourceForge soon.
Did i miss the link or is it still not posted?

111
SFML projects / Re: Alife - Artificial Life Simulation
« on: January 04, 2014, 12:42:04 am »
Id compile for 32, but i need to make the whole project i don't have day to spare :P.
I am really interested to see what did you make in action.

112
SFML projects / Re: Alife - Artificial Life Simulation
« on: January 02, 2014, 09:38:59 pm »
I tried running to see it for my self, the executable is non compatible with win7 32bit.
Any help? (trying to start as vista, and server 2008 i had from drop menu didn't help)

113
Graphics / Re: Bad Movement (judder) for Player-image
« on: December 25, 2013, 08:02:22 pm »
You still did it the incorrect way.

Try to spot difference between these two codes.
1 The correct way to achieve smooth
Code: [Select]
int main()
{
sf::RenderWindow win;
win.create(sf::VideoMode(800,600,32), "str");
win.setVerticalSyncEnabled(true);

sf::RectangleShape player;
player.setSize(sf::Vector2f(100,100));
player.setFillColor(sf::Color::Cyan);
player.setPosition(0, 0);

bool WP = false, SP = false, AP = false, DP = false;

while(win.isOpen())
{
win.clear();
sf::Event event;
while(win.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
win.close();
break;

case sf::Event::KeyPressed:
switch(event.key.code)
{
case sf::Keyboard::W:
WP = true;
break;

case sf::Keyboard::S:
SP = true;
break;

case sf::Keyboard::A:
AP = true;
break;

case sf::Keyboard::D:
DP = true;
break;
}
break;

case sf::Event::KeyReleased:
switch(event.key.code)
{
case sf::Keyboard::W:
WP = false;
break;

case sf::Keyboard::S:
SP = false;
break;

case sf::Keyboard::A:
AP = false;
break;

case sf::Keyboard::D:
DP = false;
break;
}
break;
}
}

if(WP)
player.move(0, -10);
else if(SP)
player.move(0, 10);
if(AP)
player.move(-10, 0);
else if(DP)
player.move(10, 0);


win.draw(player);
win.display();
}

return 0;
}

2 The incorrect way the one you used
Code: [Select]
int main()
{
sf::RenderWindow win;
win.create(sf::VideoMode(800,600,32), "str");
win.setVerticalSyncEnabled(true);

sf::RectangleShape player;
player.setSize(sf::Vector2f(100,100));
player.setFillColor(sf::Color::Cyan);
player.setPosition(0, 0);

while(win.isOpen())
{
win.clear();
sf::Event event;
while(win.pollEvent(event))
{
if(event.type == sf::Event::Closed)
win.close();
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
player.move(0, -10);
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
player.move(0, 10);
if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
player.move(-10, 0);
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
player.move(10, 0);

win.draw(player);
win.display();
}

return 0;
}

114
Hello.
I am trying to achieve a system that will handle events at 100 fps while game will run on 1-60 fps.
The issues is that the outer loop is not accurate and i will post my math, pretty sure it sould be working any tips/help?

The logic i am using goes something like this
if DesiredLoopLastTime - LastLoopTime > 0
then pause for DesiredLoopLastTime - LastLoopTime
This produces 67 fps instead of 100  :(

Code: [Select]
//Time.cpp
void Time::LoopTime()
{
//Pause here to make last loop last 10ms or desired amount
int tmpTime = threadClock.getElapsedTime().asMilliseconds();
if(10 - tmpTime > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(10 - tmpTime));

dt = threadClock.restart().asMilliseconds();

if(isPaused)//Dont loop logic if paused
return;

//Thread
threadCounter++;
//Logic
logicAccumulated += dt;
if(logicAccumulated > logicRequired * 2)
logicAccumulated = logicRequired*2;
//Fps
fpsAccumulated += dt;
if(fpsAccumulated > fpsRequired)
{
fpsAccumulated -= fpsRequired;
//Update fps data
txtThread.setString("FPST:"+std::to_string(threadCounter));
threadCounter = 0;
txtLogic.setString("FPSL:"+std::to_string(logicCounter));
logicCounter = 0;
}
}

//Main.cpp
//The main while loop

while(objState.GetAppState() != en::AppState::APExit)
{
objTime.LoopTime();//Once per loop
if(objState.GetAppState() != en::AppState::APPause)
{
//objEvent.HandleEvents(objWin.Win, objState, objTime, en::EventHandleTypes::EHAll);//Once per loop //Of this type

while(objTime.logicAccumulated > objTime.logicRequired)//If logic update
{
objTime.logicAccumulated -= objTime.logicRequired;
objTime.LoopLogicTime();

objEvent.HandleEvents(objWin.Win, objState, objTime, en::EventHandleTypes::EHAll);//Once per loop //Of this type
objWin.Win.clear(sf::Color(0,0,0,255));

if(objState.GetGameState() == en::GameState::GSMainMenu)
{
objMenu.LoopMenu(objEvent, objState);
objMenu.DrawMenu(objWin.Win);
}
else if(objState.GetGameState() == en::GameState::GSGame)
{
objPlayer.LoopPlayer(objEntity, objEvent, objTime.logicRequired);
objMap.LoopMap(objEvent, objState);

objMap.DrawMap(objWin.Win);
objEntity.DrawEntity(objWin.Win);
objInventory.DrawInventory(objWin.Win);
}
else if(objState.GetGameState() == en::GameState::GSEditor)
{
objMap.LoopEditor(objEvent, objState);

objMap.DrawEditor(objWin.Win);
}
objTime.DrawTime(objWin.Win);
objEvent.ClearDataPerLoop();
}
}
else//App state == pause
{
objEvent.HandleEvents(objWin.Win, objState, objTime, en::EventHandleTypes::EHApp);//Once per loop //Of this type
}
objWin.Win.display();//Once per loop
}
This is Time and main while loop.
The inner FPS other called Logic fps is 60-61 but the Thread fps is not stable at all and varies from 60-100 and after 10-15 sec or app running it stops at ~67-70 and does not change.


EDIT::
Minimal example coming soon.

115
Graphics / Re: Bad Movement (judder) for Player-image
« on: December 22, 2013, 07:44:54 pm »
Also i suggest reading the SFML tutorial on real time input
specially this line
Code: [Select]
if(Keyboard::isKeyPressed(Keyboard::Left))
I just copy from the tutorial
Quote
Sometimes, people try to react to KeyPressed events directly to implement smooth movement. Doing so will not produce the expected effect, because when you hold a key you only get a few events (remember, the repeat delay). To achieve smooth movement with events, you must use a boolean that you set on KeyPressed and clear on KeyReleased; you can then move (independently of events) as long as the boolean is set.
The other (easier) solution to produce smooth movement is to use real-time keyboard input with sf::Keyboard (see the dedicated tutorial).


I am gonna be quick:
Some of reasons i had:
Using sf::KeyPressed.

Quote
window.setFramerateLimit(60);
This line is one of things that are horrible on some systems.
Use different way to pause a thread instead using the sfml implemented one.

Code: [Select]
#include <thread>
std::this_thread::x
instead of X see what is available cant remember from top of my head right now but there is something like "sleep" and as parameter use (std::chrono::Y)
instead of Y see what fits yours needs there are allot of different types you can put there,  most likely
Code: [Select]
std::chrono::milliseconds(1);
You can pass there the time you need to pause in order to achieve your desired FPS.

116
Graphics / Re: Sprite disappears when move render window.
« on: December 16, 2013, 02:46:09 pm »
I suggest analysing your post, and try to answer your question, there is lack of information to work with.

One thing that is obvious is that you made a mistake somewhere, if that is what you want to hear well i just wrote it, because it is not behaving as you intended it to behave.

I suggest looking up how to make a post to get help, i would help but there is nothing i have to work with except that you made a mistake.

Quote
Is there any method to capture move window event?, so I can pause the updating collision.
Use your IDE debuging.

117
First id like to thank " eXpl0it3r" for the "Component Systems" link that was very helpful.

After a bit of research on this topic i decided, the approach i was gonna take is suiting with what i want to make.
There where allot of changes i had to make in order for it to be efficient/usable, because at end of the day that is what i want, i will code for a long time so i could add stuff with only few clicks wasting minimal time on that part since i enjoy crafting witty code  ;D.
Thank you on the suggestions.
I procrastinated like crazy last 5 months but its time to go... aint getting younger  ;) again thx.

118
Graphics / Re: Drawing text vs making a render texture once and then draw
« on: November 25, 2013, 01:00:37 pm »
Thanks on help id close the disscusion  ;D.

119
Hello.
Currently i am trying to design a class that would manage all drawing/sprites for each "unit" ingame.
And is that a good way to go if seeking for improved performance? if it is not then what is?

Currently i got idea of something like this
Code: [Select]
class BaseEntity//Each class that wants to be entity has to inherit this
{
int EntityVAPosition;//Vertex array position for destruction or editing
};
class EntityManager
{
public:
void AddEntity(BaseEntity & entity, sf::Vector2f Pos, sf::Vecto2f TexPos);
void RemoveEntity(BaseEntity);
};
The thinking with this is that entities will be added and removed from the VertexArray thus the options are:
1:Reconstruct the whole array each time that is done
2:Have empty holes in VertexArray and keep track of them and when entity is added fill them up.
this will most likely be a vertex array holding first index of empty VertexArray position.
When AddEntity is gonna be called, instead of appending at end its gonna check if(Vector.size > 0) and use the vertexFrom the list instead of expending the VertexArray, i think this will be efficient.

Each entity is gonna be 4Verices and the primitive type used is Quads

That being said, id like to get ideas from a tutorial on Entity manager using sfml.
I went digging but i think the name of what i am looking for is not called "Entity manager".

120
Graphics / Re: Drawing text vs making a render texture once and then draw
« on: November 20, 2013, 01:26:36 pm »
So i see there is no going easy.

Text drawing vs Render Texture drawing
Quote
there's no way around writing a test.
Done testing, drawing 150 characters 1000 times vs drawing a renderTexture 1000 times(that holds the 150char txt drawn onto it)
Results: the renderTexture is faster by at least double speed, but its requirement makes it unusable in many cases unless the text is really a wall of text witch in my case is true and is pretty good speed improvement that i required.

To explain what is happening, i have small font size text that explain events and is somewhat like list of stuff that has recently happened, instead of looking last few stuff that happened picking what to draw etc.
I just draw stuff to Render Texture and use that for drawing i only redraw it when it is required and it is better cpu wise witch i was trying to achieve since my game is hauling allot for its BADLY made AI.

Pages: 1 ... 6 7 [8] 9 10 ... 15