GDI+: How do I refresh the screen efficiently?

I was told that I could update/refresh certain "dirty" areas

Page 1 of 1

3 Replies - 6605 Views - Last Post: 30 January 2010 - 05:50 PM Rate Topic: -----

#1 Alexnader  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-January 10

GDI+: How do I refresh the screen efficiently?

Posted 30 January 2010 - 01:14 AM

Hi, I'm making a game using vb.net and GDI+. I've been encountering frame rate problems and one solution that was suggested to me was to only refresh certain parts of the screen. I was also told one way to make this happen was to use rectangle or region structures and since I already have these as hitboxes it seems like a perfect way to efficiently reduce the drop in frame rate.
The only problem is that I have no idea how this would work and so far my google searches have been fruitless. Yet again I turn to this very helpful forum, can anyone help me?
By the way I've set doublebuffered to true on my form to get rid of the annoying flicker.

Questions
How do I update or refresh only certain parts of the screen?

I'm using a timer set to tick every millisecond to run everything and it refreshes the screen every 2 milliseconds simply using me.invalidate; each time it ticks things move a little bit and stuff happens that triggers other events etc. The problem is that when the framerate supposedly "drops" things start to change. "Bullets" and projectiles appear to travel many times faster and much less smoothly than they do when there a less objects moving on the screen, it's almost as if the timer runs faster... What's the reason for this? Is there a way I can change this? I remember hearing about a "stopwatch" or something that someone used in their game that was more consistent or something.


Also I'm aware that vb.net with GDI+ isn't exactly the best language to make a video game in but it's for a school project and I have no choice in the matter.

This post has been edited by Alexnader: 30 January 2010 - 03:16 AM


Is This A Good Question/Topic? 0
  • +

Replies To: GDI+: How do I refresh the screen efficiently?

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: GDI+: How do I refresh the screen efficiently?

Posted 30 January 2010 - 04:37 AM

The form has an event called Invalidated in which is called when invalidated. It e parameter has e.InvalidRect
Was This Post Helpful? 0
  • +
  • -

#3 T.Jackson  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 97
  • Joined: 27-January 10

Re: GDI+: How do I refresh the screen efficiently?

Posted 30 January 2010 - 06:23 AM

View PostAlexnader, on 30 Jan, 2010 - 12:14 AM, said:

Questions
How do I update or refresh only certain parts of the screen?


What Adam is trying to say is this:

Me.Invalidate(New Rectangle(0, 0, 500, 600))



500 being width while 600 being height.

the first two parameters are X & Y starting points

I do wish that Adam would give straight answers.

Quote

Also I'm aware that vb.net with GDI+ isn't exactly the best language to make a video game in.


What a load of crap. You can get full frame rate from a perfect Pacman clone on a low spec P4.

Trent Jackson
Was This Post Helpful? 1
  • +
  • -

#4 Alexnader  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-January 10

Re: GDI+: How do I refresh the screen efficiently?

Posted 30 January 2010 - 05:50 PM

Quote

Quote

Also I'm aware that vb.net with GDI+ isn't exactly the best language to make a video game in.


What a load of crap. You can get full frame rate from a perfect Pacman clone on a low spec P4.

Trent Jackson


Sorry, guess I was misinformed by someone in a previous topic I made here. Anyway thanks for the clarification.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1