Questions for VB Programmers with Graphics/Input Experience - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Questions for VB Programmers with Graphics/Input Experience

QQProQQPro Posts: 3Member
Hello, and in advance, thank you for helping with these questions.

But to the point:

In my game that I am making (and no, it's not one of those games people say they "are making", this one is actually towards the end of its preliminary development), I am using the Form_KeyDown for my input device. However, I can't figure out how to make it so that when a key is pressed, it doesn't stop for a while before it starts repeating. In the game, the character moves one tile, stops for a half a second, and only then proceeds to move rapidly. How can I eliminate this delay?

Also, I have a question about graphics. Sometime in the near future, when the game is finished, I will need to completely revamp the graphics. But I can't figure out how to make Visual Basic display images or pictureboxes, even ones that have gifs in them, transparently. There is always a white square in the background. Is there some special trick in the creation of the graphic to make it transparent in VB?

Thank you,

Thankful VB programmer

Comments

  • KDivad LeahcimKDivad Leahcim Posts: 3,948Member
    : Hello, and in advance, thank you for helping with these questions.
    :
    : But to the point:
    :
    : In my game that I am making (and no, it's not one of those games people say they "are making", this one is actually towards the end of its preliminary development), I am using the Form_KeyDown for my input device. However, I can't figure out how to make it so that when a key is pressed, it doesn't stop for a while before it starts repeating. In the game, the character moves one tile, stops for a half a second, and only then proceeds to move rapidly. How can I eliminate this delay?
    :
    : Also, I have a question about graphics. Sometime in the near future, when the game is finished, I will need to completely revamp the graphics. But I can't figure out how to make Visual Basic display images or pictureboxes, even ones that have gifs in them, transparently. There is always a white square in the background. Is there some special trick in the creation of the graphic to make it transparent in VB?
    :
    : Thank you,
    :
    : Thankful VB programmer
    :

    Your first question simply can't be done using your current method. This is due to the way Windows (and pretty much any other system) processes keys. When the key is pressed, it is immediately sent to the app. A delay is then used to help prevent accidental repeats. Next comes the series of repeats. What most games most likely do is start a loop (or timer) when the key is pressed and stop it when the key is released. This lets the timer set the delay speed and seperates it from the keyboard delay (which may or may not be set to a good speed to play a game).

    Will the graphic be displayed on top of another graphic? VB does not support transparency, but masks are easy enough to make and use and will remove that white background.
  • QQProQQPro Posts: 3Member
    : Your first question simply can't be done using your current method. This is due to the way Windows (and pretty much any other system) processes keys. When the key is pressed, it is immediately sent to the app. A delay is then used to help prevent accidental repeats. Next comes the series of repeats. What most games most likely do is start a loop (or timer) when the key is pressed and stop it when the key is released. This lets the timer set the delay speed and seperates it from the keyboard delay (which may or may not be set to a good speed to play a game).
    :
    : Will the graphic be displayed on top of another graphic? VB does not support transparency, but masks are easy enough to make and use and will remove that white background.

    ------------------------------------------------------------------------
    Thank you for your help. I just have one more question: how do you make masks?
  • KDivad LeahcimKDivad Leahcim Posts: 3,948Member
    : Thank you for your help. I just have one more question: how do you make masks?
    :

    It's really not that hard. Take a copy of the image you wish to make transparent. Make every part of the image that should be transparent black. Make the rest of the image white; this is your mask. Make sure your original is white where it should be transparent (though it can also be white elsewhere). Use .PaintPicture to draw the mask onto the background using the vbSrcPaint opcode. Finally, use .PaintPicture again to draw the image onto the same spot using the vbSrcAnd opcode.

    Hope this helps!
  • QQProQQPro Posts: 3Member
    Once again thank you, but, if you'll excuse my noviceness, could you please explain the syntax of the .PaintPicture method? I've never used it before, and can't quite figure out how it works.
  • KDivad LeahcimKDivad Leahcim Posts: 3,948Member
    : Once again thank you, but, if you'll excuse my noviceness, could you please explain the syntax of the .PaintPicture method? I've never used it before, and can't quite figure out how it works.
    :

    Let's say you want to paint the graphic into the background at 150x300. You would do this:

    'Picture1 has background, Picture2 has mask, Picture3 has graphic
    Picture1.PaintPicture Picture2.Picture, 150, 300, , , , , , , vbSrcPaint
    Picture1.PaintPicture Picture3.Picture, 150, 300, , , , , , , vbSrcAnd

    The 6 skipped parameters are used for clipping and stretching the graphic.

    If you would like a simple sample form showing this, post your email address and I'll send you one. It really is very simple once you know what to do.
  • fjwinitfjwinit Posts: 8Member
    i'm undergoing the same problem as the person who posted the original thread, as well as several others. in order to solve them, it would be greately appreciated if i could please get the example that you were talking about. i tried to do what you suggested, but i think i made some kind of mistake, and it doesn't work for some reason.

    my email address is [email protected], and i'd also appreciate it if i could send you the program i'm working on now so that possibly you could give me some beneficial suggestions.
    thank you in advance,
    alex
Sign In or Register to comment.