I think I've recently come a long way in terms of VB knowledge (particularly in terms of moving sprites), and now I'm revisiting an old project to try and get it up to scratch.
As you can see from the picture, the game consists of:
The interface on the left
The map on the right which the player moves around
The player in the centre of the map (white dot)
I used to have the "house" as an Autoshape object, but now I'm drawing it at run-time using the "Line" function.
My problem is, because of having to use the "Cls" and "Refresh" functions to keep moving the house at run-time, the interface (or at least part of it) flickers. I suspect this is just because of the brown Autoshape and yellow and black labels.
My question is this:
Is there a way around this "flicker", or, if not, will drawing the Autoshape and labels at run-time be good enough - i.e. will the other controls cope ok with the clear screen function (and if not, what can I do about them)?
Also, is all this re-drawing really the best way? It seems like it ought to be a lot of hard work, but then again maybe computers can cope with more than I give them credit for.
Please post the code that you are using! Thank you.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
There's really not a lot to it, other than the 2 functions I mentioned. When you click somewhere, the house "moves" to simulate the player moving, while keeping the player central.
This moves the house just fine, but the interface flickers.
Again, I suspect that the best solution is to draw the interface at run-time, I just wanted a bit of advice / reassurance that this is the best way to do it, and that the other controls won't flicker (since I don't know how to "draw" them at run-time).
The simple way to solve this is not to draw on the form itself, but to create a PictureBox for the playing area and draw on to that (it has .Cls and all of the other methods a form has).
Rather than Drawing the house with Line Statements have a Control represent the house and then use;
MyControl.Move newX,newY
MyControl could be just about any type of Control but a Shape Control with its Shape property set to Rectangle will give very similar results to those you have now.
You will no longer need the Cls which I expect is the cause of your flicker.
Si, you've done it again! That's EXACTLY what I needed, thank you
Rather than Drawing the house with Line Statements have a Control represent the house
I would do that (I used to) but I've always been told that using controls is very inefficient when there are lots of them, so now I always draw things when possible.
You will no longer need the Cls which I expect is the cause of your flicker.
In terms of frequently moved items like this (especially when there is more than one object moving on screen at a time), using controls is a sure fire way to get the worst flicker you can without specifically trying to get flicker.
Having a mixture of controls and drawn items on the same parent object isn't good either (for one moving item it is probably the same as controls, but better for multiple items). Thankfully it is easy to create separate parent objects (using something like a PictureBox or Frame) to avoid the issue.
Originally Posted by Danjb
Si, you've done it again! That's EXACTLY what I needed, thank you
Excellent, nice and easy!!
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?