Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Go Back  Xtreme Visual Basic Talk > > > Lag/Delay after Key Press Problem.


Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2009, 04:30 PM
hoopsjake2009 hoopsjake2009 is offline
Newcomer
 
Join Date: May 2009
Posts: 2
Default Lag/Delay after Key Press Problem.


I am trying to make a video game for a programing class and I have most of it working, but I am using keydown and keyup to control character movement. The problem is that the keys are lagging. Ever 3 or 4 seconds, the picture box (I had some problems just using the form background for some reason) I am using for the background flashes and the keys register, then 3 or 4 seconds later the screen flashes and whatever keys I have down register. I have moving picture boxes for characters and they are moving just fine, and I am using the paint sub to update and redraw the objects and the background and it is repainting about 50 times a minute, and the processor still has a lot of unused power so I don't think that it is just lagging. Do any of you have any idea what might be making the keydown and keyup work so wierd?

Sorry I didn't do a very good job of explaining it. If you need more info I can tell you but i have the code at my school, and I am at home.
Reply With Quote
  #2  
Old 05-12-2009, 08:10 PM
vb5prgrmrLag/Delay after Key Press Problem. vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

Without looking at your code it sounds like you are doing either quite a lot in the background or you have either a lot of images or some very large images in memory. If large images, try to cut their size, but it really sounds like you have a lot of images and you are keeping them in a lot of picture boxes. So this tells me that you have a lot of overhead. What is your memory usage compared to how much memory you have when you run the program? I ask this because it sounds like you are encountering swap file delays or if you are reloading a large image as in your background then that may be a problem also. A possible way to get around this is to swap out picture boxes for image controls or perhaps no controls at all and use the API's like BitBlt to draw your sprites on your background. Then again, keeping a single pristine background image in memory and using it for when you repaint/redraw might also improve performance. Another possible factor is the speed of machine.

Good Luck
Reply With Quote
  #3  
Old 05-13-2009, 03:40 PM
throttleman throttleman is offline
Newcomer
 
Join Date: May 2009
Posts: 3
Default

i was trying to make the spacebar = faster acceleration for my program and i could never get it to work, so if you could post how you do that alone it would be very helpful, thx
Reply With Quote
  #4  
Old 05-13-2009, 04:53 PM
hoopsjake2009 hoopsjake2009 is offline
Newcomer
 
Join Date: May 2009
Posts: 2
Default

Just so you know, the problem resulted becuase I was using transparency in the images, images without transparency work well, but the transparency messed something up.
Reply With Quote
  #5  
Old 05-13-2009, 08:37 PM
vb5prgrmrLag/Delay after Key Press Problem. vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

So, still not knowing your code, you say that you are using images with transparency. I take it these are your sprites that you move around via your lagging keypresses...

Okay, its been a long time since I played around with graphics in such a manner but this is the basics of how I used to do it...

Loaded background image into a stdPicture variable. (Image was larger than screen and thus allowed for scrolling)

Prepared Sprites with transparency and also kept them in memory. (Several views of each sprite as viewed from different angles.)

Then to redraw the screen I would do it in layers, starting with the background (the terrain), terrain features (non moving sprites but with several views for viewing angle), and finally npc/pc sprites. I would do all this in memory before repainting the screen (Search on double buffer vb6).

Via this double buffering method I was able to get higher than needed refresh rates. Beyond this, without seeing your code, I don't know what to suggest.

Good Luck
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem. Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
 
Lag/Delay after Key Press Problem.
Lag/Delay after Key Press Problem.
 
-->