So, my next challenge game is called HardBall. I want an 'object' that looks like a ball (currently simply using a shape control). BUT, as shapes are layered below most other
controls, I would like a round (circular object) that when moves around on the screen passes 'over' other controls.
Any suggestions on how to start? Maybe a circular form???? at a loss here.
Just find a PNG transparent image of a nice ball and you can use control’s Rotation property along with Move method to emulate the ball spinning if you’d like.
I think he needs a windowed control to display over other windowed controls.
Mixing windowed controls would be a very short-sighted design. The best would be to use windowless controls only for the “canvas” of the game and manipulate their z-order at will.
Mixing windowed controls would be a very short-sighted design. The best would be to use windowless controls only for the “canvas” of the game and manipulate their z-order at will.
I don't know if he is willing to completely rewrite the UI of the game.
What I have is "fine". Yeah, I would LIKE a 'rolling ball', but, once again, this is not professional grade (none of my games are, but they do provide pretty good entertainment).
As far as 'completely rewrite'...I have just started...starting with the 'screen'....about 30 minutes of effort so far....long way to go.
Tightened it up a little. Got rid of a blitting operation, reversed the order of painting the colored image and shading image, and in the process eliminated a PictureBox.
Created another colored image that might offer a more pleasing demonstration.
You still have to worry about aliasing around the edge to avoid ugly fringing, but creating image resources is always fiddly work for me.
With some work you can also have a drop shadow, but to do that right you will want to use alpha blended rendering and this simple UserControl approach breaks down.
Remember...you are talking (writing) to someone with not a lot of knowledge of what you have done....(Excellent work, tho). So, if I implement, I have to know how to make it smaller in diameter, AND, to know what it's left and top properties are all the time (as I make it go in a pattern somewhat like in Donkey Kong (I knew YOU remember that game, although maybe from watching your Dad play it!!!!!!!!!!!!!)
The Extender object of a UserControl has its .Left and .Top position values.
Making the UserControl smaller (or larger) means resizing the control, the PictureBoxes, and the source images.
The PictureBox controls are just a handy way to get source DCs with bitmaps selected into them, created at design time without runtime code. You could also use memory DCs and get the 100% sized source bitmaps for them from... for example new StdPicture properties you add to the UserControl. Then you wouldn't need the PictureBox controls, and this would let you use CanGetFocus = False as you should.
I was trying to demonstrate the bare bones, focusing on painting a "rolling" ball image with spherical shading hints for a crude 3-D look.
Rolling upward/downward or diagonally is another problem altogether. Animating that takes much more than rotating a flat circular image.
Using that code fails to mask out the white area around the ball. Commenting out the call to AlphaBlend() masks the white out fine, but of course then you get no shading on the ball.
It is substantially the same as earlier versions that work.
The "Size" property hasn't been fully implemented yet (1.0 = 100%, 0.5 = 50%, etc.). But I was trying to make changes in bite sized chunks.
Theory:
Using AlphaBlend() changes the color format of UserControl.Image to 32bpp with &HFF in the alpha subfield, which can never match any valid MaskColor value (an OLE_COLOR).
I was waiting on hold for a while so I decided to fiddle away at the problem. I don't really expect anyone else to use it, but the puzzle is bugging me now.
Using that code fails to mask out the white area around the ball. Commenting out the call to AlphaBlend() masks the white out fine, but of course then you get no shading on the ball.
Hypothesis: AlphaBlend API changes white color ever so slightly because of not completely transparent alpha on the transparent pixels (or possibly something in RENDER_BLENDFUNCTION) so the original &HFFFFFF pixels become &HFEFDFC or similar very close to white.
Probably you can use GetPixel of top-most left-most pixel as key-color instead of hardcoding vbWhite or fix alpha blending if there are param issues with 100% transparency.
Hypothesis: AlphaBlend API changes white color ever so slightly because of not completely transparent alpha on the transparent pixels (or possibly something in RENDER_BLENDFUNCTION) so the original &HFFFFFF pixels become &HFEFDFC or similar very close to white.
Probably you can use GetPixel of top-most left-most pixel as key-color instead of hardcoding vbWhite or fix alpha blending if there are param issues with 100% transparency.
Seems plausible, right? Sadly I find full vbWhite at pixel (0,0) and (4.4) for example. I did cheat, and just call the Point() method which for all I know plays games beyond what GetPixel() does.
The confusing thing is that the blitting calls are the same calls I used with 2 PictureBox controls containing the bitmap images. That works fine. So I think there is something weird happening to the memory DCs and thus the final composited bitmap, or... ?
Coming back to THIS attempt. So, my Hardball game has a UC (from the link Arnoutdv provided). I like how it appears over stuff I want it to, as well as behind stuff I don't (I simply used another copy of the UC (I have one UC as a BALL, others as tunnels). But, I noticed as the ball moves left or right and passes over other objects (mine passes over an array of image control), the speed is not consistent (pretty much, but it seems to 'slow down just a bit' every so often). Now, I am using three 'speeds' for the ball (depending upon which I want (Slow, Medium or Fast). My timer array which controls the movements (left, right, down) will use intervals of 35, 30 or 15 (Slow, Medium, Fast) depending upon a selection. I am not sure if the left and right movements (I increase or decrease the Left property of the UC) are being affected by the inaccuracy of a Timer Control at those low intervals, or by it passing over different Image controls, or something completely different. This is a snapshot only of the ball on a traverse (in a demo mode for players):
I finally figured out why AlphaBlend() interfered with transparent UserControl.BackStyle in my previous attempt.
Turns out that you need the source DC & bitmap to be compatible (color format) with the target, here the UserControl. That meant going through a few gyrations to convert the raw source bitmap to a matching DC & bitmap.
That also helps explain why using a PictureBox as source DC worked fine. Now that I have ripped out all bloated PictureBox controls I can also assign False to CanGetFocus at last.
I implemented scaling via a SizeFactor property. Seems to work fine, but animating it seems to produce a "jello effect" over 100% scale for reasons I haven't analyzed. You have to see it to get my meaning.
I know that it probably won't be useful in answering this thread, but I hated to leave an unsolved issue lying around to frustrate future readers looking for solutions.
Last edited by dilettante; Mar 27th, 2021 at 08:50 AM.
Reason: replaced attachment, eliminated a potential handle leak
Thanks...I know what you mean....once it gets in your craw!!!!!!!!! I'll check this out. Who knows, I may be able to implement.
(BTW--I did 'finish' my game using a UserControl 'shape'---no rolling, but stays in front of what I want it to, and behind those I also want it to.
But, the only issue with what I have right now, is described in post #24.)
Not sure how to show a "rolling" ball that isn't patterned in some way. But here's something thrown together
can it with PixelFormat32bppARGB?
BMP pictures with 32-bit transparent channel can also be used
quickly after a little fiddling:
Photorealistic? No. But cheap and easy.
how to put alpha png to usercontrol,Want to be a real transparent control, support PNG transparent channel
With enough effort many stunts can be performed. How useful they are is another matter.
Here's a windowed UserControl that displays a translucent PNG and implements simple dragging. It requires Windows 8 or newer and a manifest declaring them "supported" OSs... and this means most people won't see the PNG except in the compiled EXE.
You can bash a manifest into VB6.EXE of course, or perform other stunts like changing the activation context during IDE runs.
With enough effort many stunts can be performed. How useful they are is another matter.
Here's a windowed UserControl that displays a translucent PNG and implements simple dragging. It requires Windows 8 or newer and a manifest declaring them "supported" OSs... and this means most people won't see the PNG except in the compiled EXE.
You can bash a manifest into VB6.EXE of course, or perform other stunts like changing the activation context during IDE runs.
Big attachment, mainly due to image data.
If make a half transparent image control. Beneath the blank screen is another control that constantly updates data, such as transaction amount statistics.With this method, you can really update the display in real time, which is perfect.The disadvantage is that he must have a system of Windows 8 or above.If you want to run on win7 system, you may need to take a screenshot of the background image content and set it as the background of the control.If the data is updated 100 times per second. It takes a hundred times a second to disarm.
It is difficult to make a transparent text box control. Vb6 is too old, after all, it is almost 25 years old. Vb.net adds tens of thousands of features.
Last edited by xiaoyao; Mar 28th, 2021 at 09:32 AM.