Smooth Movement?
Moderator: PC Supremacists
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Smooth Movement?
I'm already working on my next gaming project, but I finally want to tackle a problem I've had since the beginning.
When anything on the screen moves for extended periods of time, they tend to move very jumpily.
I am wondering if anyone knows how to alleviate this problem. Thank you.
When anything on the screen moves for extended periods of time, they tend to move very jumpily.
I am wondering if anyone knows how to alleviate this problem. Thank you.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- lalacomun
- VS Setup Wizard
- Posts: 114
- Joined: Wed Dec 28, 2011 10:18 pm
- Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
- Programming Language of Choice: C++
- Location: Argentina
- Contact:
Re: Smooth Movement?
Smooth Movement = OpenGL render , are you using SDL, or OpenGL for rendering??, it can be a memory lake as said before,(open your taskmanager and you can see your memory and cpu usage), or it can just be that each time you press a key you render a new image, i use to have that problem before for example:RandomDever wrote:I'm already working on my next gaming project, but I finally want to tackle a problem I've had since the beginning.
When anything on the screen moves for extended periods of time, they tend to move very jumpily.
I am wondering if anyone knows how to alleviate this problem. Thank you.
Code: Select all
switch( event.key.keysym.sym )
{
case SDLK_UP:
SDL_BlitSurface(playerUP,NULL,screen,&player);
break;
case SDLK_DOWN:
SDL_BlitSurface(playerDOWN,NULL,screen,&player);
break;
case SDLK_LEFT:
SDL_BlitSurface(playerLEFT,NULL,screen,&player);
break;
case SDLK_RIGHT:
SDL_BlitSurface(playerRIGHT,NULL,screen,&player);
break;
}
http://www.youtube.com/watch?v=IXejVlRX ... MC8m7dkwc=
or
http://lazyfoo.net/SDL_tutorials/lesson14/index.php
-
- Chaos Rift Junior
- Posts: 204
- Joined: Mon Nov 21, 2011 3:01 pm
- Current Project: Web browser from scratch
- Favorite Gaming Platforms: SNES, PSP, PS1 and 3
- Programming Language of Choice: C#
- Location: A house near me
- Contact:
Re: Smooth Movement?
Make sure your disposing of every bitmap you are rendering after you finished using them. If your using c#, then you don't need to do this since it has a garbage collector. But otherwise, if your getting memory leaks, personal experience suggests that your not disposing of the bitmaps that are being used per frame.
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: Smooth Movement?
There is no memory leak. Unless memory leak means something other than a constant increase in allocated memory.
CPU usage stays around 10 and memory around 7,500k.
And I am using SDL for rendering because OpenGL is not supported by my engine. Yet.
CPU usage stays around 10 and memory around 7,500k.
And I am using SDL for rendering because OpenGL is not supported by my engine. Yet.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Smooth Movement?
A memory leak is any memory which is allocated but not deallocated. This doesn't necessarily have to happen at any certain speed, as it depends where in your code the allocation is occurring.RandomDever wrote:There is no memory leak. Unless memory leak means something other than a constant increase in allocated memory.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: Smooth Movement?
Well that's possible. But how the hell would I find that in the 20,000 lines of code?dandymcgee wrote:A memory leak is any memory which is allocated but not deallocated. This doesn't necessarily have to happen at any certain speed, as it depends where in your code the allocation is occurring.RandomDever wrote:There is no memory leak. Unless memory leak means something other than a constant increase in allocated memory.
I have a fairly substantial engine and finding such a leak seems virtually impossible (assuming there is one).
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
Re: Smooth Movement?
You need to narrow down your engine to the point where you can eliminate things causing it.
Start by removing textures, remove all characters, remove lighting, remove AI, slow down the game loop, use more debugging, etc. Keep going until you find the thing causing it, then drill down into that
Start by removing textures, remove all characters, remove lighting, remove AI, slow down the game loop, use more debugging, etc. Keep going until you find the thing causing it, then drill down into that
-
- Chaos Rift Junior
- Posts: 204
- Joined: Mon Nov 21, 2011 3:01 pm
- Current Project: Web browser from scratch
- Favorite Gaming Platforms: SNES, PSP, PS1 and 3
- Programming Language of Choice: C#
- Location: A house near me
- Contact:
Re: Smooth Movement?
If it is leaking, why not try making some sort of tester to force the engine to re-render everything every 1ms, then see if the memory it uses increases.
E.g
E.g
Code: Select all
while(true) { engine.Draw(); }
- superLED
- Chaos Rift Junior
- Posts: 303
- Joined: Sun Nov 21, 2010 10:56 am
- Current Project: Engine
- Favorite Gaming Platforms: N64
- Programming Language of Choice: C++, PHP
- Location: Norway
Re: Smooth Movement?
Are you regulating your frame rate? Like, keep it at a constant 60 fps? If not, it may be that the CPU works faster sometimes, and make it 'jump in speed', because the game loops is running faster/slower.
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: Smooth Movement?
Couldn't find any memory leaks, I don't have lighting or AI, and my FPS is capped at 60.
Any more suggestions?
Any more suggestions?
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- thejahooli
- Chaos Rift Junior
- Posts: 265
- Joined: Fri Feb 20, 2009 7:45 pm
- Location: London, England
Re: Smooth Movement?
Could you post more detail as to what the 'jumpy' movement is. If we have a less ambiguous description of what's happening, it might be easier to isolate a cause.
I'll make your software hardware.
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: Smooth Movement?
Let's say I have a square moving at a rate of 2 pixels per second.
It will move 2 pixels one frame and the next frame it will move like 4 pixels for no reason.
It will move 2 pixels one frame and the next frame it will move like 4 pixels for no reason.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- lalacomun
- VS Setup Wizard
- Posts: 114
- Joined: Wed Dec 28, 2011 10:18 pm
- Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
- Programming Language of Choice: C++
- Location: Argentina
- Contact:
Re: Smooth Movement?
Cap it at 100 frames i know it sound ridiculous but belive me its not the same, i think its because you are using SDL for graphics, and its not that powerfull, i recomend you learn OpenGL belive me you will see the diference since its hardware accelerated, my SDL(for render and input) programs always lag, not because any memory lakes just because its not powerfull enought for my needs
Re: Smooth Movement?
Sounds like a maths/timing/calculation error rather than a performance thing. If it is a performance thing, there must be some reason for it.RandomDever wrote:Let's say I have a square moving at a rate of 2 pixels per second.
It will move 2 pixels one frame and the next frame it will move like 4 pixels for no reason.
Can you benchmark the performance in any way, eg. what FPS, how much CPU is being used etc ?
Can you narrow down your code to a few lines which reproduce the problem ? Maybe then someone can help you