I am creating a custom drawn Windows 10 style child frame class (derived from CMDIChildWndEx) for MDI applications. I've got everything drawing and working well (I have one residual drawing problem, but I'll ask that separately), however I can't figure out how to get a transparent, but clickable, region outside the drawn window border.
The problem is, Windows 10 style frames are only a single pixel wide, and this is really too narrow to be practical for sizing the frame. As such, what I am trying to do, is to have a 3 pixel wide transparent region outside the border which is part of the non-client area of the window, and thus clickable. The window region is set up properly, however the 3 pixel wide region is never redrawn by the main frame, so it gets parts of other child frames "stuck" and looks a horrible mess. I assume that Windows is assuming that my window is responsible for drawing everything within its declared region, and therefore won't redraw anything in that area.
If I make the window region only extend to the 1 pixel visible border, I don't get messages (i.e. OnNcLButtonDown, OnNcLButtonDblClk and OnNcMouseMovewhen the user moves the mouse outside that region, obviously.
I've tried invalidating the region I want the main frame to redraw (by calling InvalidateRect and RedrawWindow from my CMainFrame class), both just the region I want redrawn, and the whole child frame region, both without success. Forcing the main frame to redraw itself and all its child frames "works", but of course results in a horrible, slow, flickering mess, so that's not a practical solution.
I've not been able to find anything online that helps, and have tried just about everything I can think of, so I'd really appreciate any suggestions!
I'm happy to show code, but hopefully the above describes the problem sufficiently.
The screenshot below shows the effect, with the borders of each child frame having been corrupted by the other as it was dragged over.
Related
I am trying to check if a KinematicBody2D enters an Area2D. There is a signal for that(on_body_entered), but it only emits when the body is completely inside the area. Is there a way to constantly get if a body is just overlaping?
but it only emits when the body is completely inside the area
This is not correct. A more accurate description of the "body_entered" would be that it triggers on contact. The body could be partially or totally overlapping.
I suggest you enable "Visible Collision Shapes" from the debug menu. Perhaps your collider are not set the way you expect them to be.
We do not have a signal for when the body is completely inside.
What you can do is set up a smaller area (or a larger one depending on your need)…
The idea is to have two areas that are one larger than the other, in such way that there is a margin for just the size of the player character, then when the outer one triggers, it means the character is only overlapping the larger one, and when the inner one triggers the character is fully inside the larger one.
For example, if you have a 500 by 500 area, and your player is 100 by 100, then set an area with the size 300 by 300 centered at the larger area… When the player enters in contact with the smaller area, it will trigger the "body_entered" signal, which will also mean it is entirely inside the larger one. If you only got "body_entered" from the outer area but the inner area, then the player character is overlapping the outer area, but not fully inside it.
After playing the animation several times, the object resets all movements and rotations(3d mode) each time and remains in one place. How do I make sure that all changes are not discarded after the animation?
Changes are not discarded after the animation. Period.
However, changes are reset when the animation starts again.
If you don't want the animation to change a property, don't include it in the animation. Or, put another way, if you don't want to reset a property, don't play an animation that includes it.
If you want the motion of the animation to be relative, you can animate a child node. For instance, you can have a physics body player character (e.g. RigidBody or KinematicBody), and then as a child have the model that represents it… And animate with AnimationPlayer the model, no the physics body. That way, the animation will reset the model to its parent (the physics body), but will not reset the physics body itself.
If you need finer granularity over what you track, consider using sub-properties. I have an explanation in another answer. It could be that animation is not the right tool for what you are doing. Consider using Tween, for example.
By the way, if you want to smoothly interpolate between animation, you can increase the animation blend time (which is 0 by default). I talk about that in yet a different answer.
I got feeling retro and decided to write my favorite 8-bit computer game (Williams' Defender) on my first computer (Commodore PET 4032). All the code is being done in 6502 Assembly language. For those not familiar with the PET, all the graphics are character-based and to build games you move different characters around a 40 column x 25-row screen. This is very old tech - there are no sprites, no graphics layers, no ability to AND at the screen level, etc that we would be used to today.
I want the game to have multiple "laser beams" to be fired at the same time, and those laser beams might go on top of one another as they traverse the screen. Right now, as the beams move along the screen they store in memory what was underneath themselves and then replace what was underneath themselves as they move along to restore the background to its original state. The problem comes when a second laser goes on top of the first .. the first moves along and replaces the original background rather than leaving the second laser on top, then that second laser moves along and leaves artifacts of the first behind.
Is there a classic "light" algorithm or rule-set that allows multiple objects to move across one another such that the original proper things underneath are retained? I've tried different approaches (swapping backgrounds as things traverse, etc) but nothing seems to give me the correct result that I want.
It's certain an option to have each sprite keep a copy of whatever it overwrote, and have them erase themselves in the opposite order to that in which you drew them. That can't fail, but it assumes you have time for a full sprite draw and erase each frame.
You can also use a screen-sized buffer of 'is background' and 'is sprite' flags. Each time a sprite is drawn, mark its character locations as 'is sprite'. To erase all sprites iterate through the screen-sized buffer repainting the background anywhere that isn't marked 'is background'. You can keep upper and lower bounds of updated positions if iterating the whole 2000 potential slots is too great a cost.
You can also compare the differences between two such buffers to reduce flicker substantially supposing you have only one video buffer: paint the new sprites first, wherever they should go, noting them in the new buffer. Once all sprites are drawn, fill in background anywhere that the new buffer isn't marked 'is sprite' but the old is.
I would suggest:
Maintain a model of the game state that would allow you to redraw the entire screen at any time. This would include the positions and other state of all movable elements
As you update the game state between frames, accumulate a mask of all the cells that will need to be redrawn, because something in them changed or moved.
Iterate through the game elements in depth order from top to bottom, redrawing the parts of each element that are in the changed-cell mask
Remove any cell you draw from the changed-cell mask so it won't be rewritten by deeper elements.
The background will be last, and will redraw all remaining cells, leaving you with an empty mask ready for the next frame.
This procedure avoids any flicker that would be caused by undrawing anything you draw in a single frame.
Various indexing structures can be added to the changed cell mask to avoid unnecessary drawing work. What kinds of optimizations are appropriate here depend on your game. If the background is mostly static, for example, then it would be useful to add the coordinates of each changed cell to a list during the update, and then only check those cells during the background redraw. Or you could do this based on the previous positions of all movable elements... up 2 you.
If the majority of the scene changes in every frame, then you can skip the mask accumulation and just start with a full screen mask... although I think a PET might not be fast enough for such games.
Having never programmed for the Pet, I can't offer any specific advice about what you might try, but I can recommend keeping a copy of the current on-screen background in about 1k of RAM. That way, you can use that data to restore your background when removing the last "sprite" written to that tile. Unfortunately, that also requires you to keep your code and object data combined under 31k, unless you are programming this as a cartridge. Just a few thoughts, for what they're worth.
I have 3 KML's that do not draw at all and 2-3 that act sporadically depending on what zoom level they are at. I checked the file limitations and I don't seem to be violating any of the limits. I went back to my original shapefiles to check for geometry errors. One of the files had geometry errors and I fixed them yet it didn't seem to fix the problem of the KML not rendering. I've also implemented zoom functionality with Googles Visualization API and geoxml3 processor. Here are some interesting things that happen with my application:
One of the KML files that does not draw will actually respond to the
zoom functionality by zooming to its extent but still won't draw the
polygon; evidence that the KML is being parsed but not drawing.
One of the KML files that does not draw will eventually draw if I
click on the polygon next to it and am zoomed in close enough. It
will not initially.
I have two KML files that draw when zoomed out but 'disappear' when
I zoom in.
My application is here and my fusion table is here. If anyone has had similar problems and was able to fix them I would really appreciate to know how it was accomplished because I'm stumped at this point.
Thanks
first of all: Fusion Tables are still experimental
some issues:
South Nelson Elementary is missing in varID
JV Humphries Secondary Polygons needs to be fixed
I thought I would post an update.
It turns out some of my data did have geometry errors; those were fixed and converted to KML.
The problem is my actual coding. The code was orginally written to simply display polygons from an array and to be turned on/off via a checkbox. The reason for this was to be able to view adjacent boundaries of the other polygons. I achieved this in my initial coding and the user had to zoom into the area of interest via Google's map functionality.
Then I was asked to have a zoom function when the checkbox was clicked to have the application zoom to the polygon in question. This of course works but it depends on which order the checkboxes are clicked on. I'm fairly certain it has to do with how the empty array is populated as checkboxes are clicked on/off.
I don't fully understand the logic of how the code decides which polygon to zoom or not zoom to. All I know is that if all checkboxes are unchecked then each checkbox is checked on/off one at a time the zoom functionality works.
If anyone has a suggestion on how to have each checkbox act 'independently' to zoom regardless of order clicked I would appreciate it.
I'm wondering about how the NES displays its graphical muscle. I've researched stuff online and read through it, but I'm wondering about one last thing: Nametables.
Basically, from what I've read, each 8x8 block in a NES nametable points to a location in the pattern table, which holds graphic memory. In addition, the nametable also has an attribute table which sets a certain color palette for each 16x16 block. They're linked up together like this:
(assuming 16 8x8 blocks)
Nametable, with A B C D = pointers to sprite data:
ABBB
CDCC
DDDD
DDDD
Attribute table, with 1 2 3 = pointers to color palette data, with < referencing value to the left, ^ above, and ' to the left and above:
1<2<
^'^'
3<3<
^'^'
So, in the example above, the blocks would be colored as so
1A 1B 2B 2B
1C 1D 2C 2C
3D 3D 3D 3D
3D 3D 3D 3D
Now, if I have this on a fixed screen - it works great! Because the NES resolution is 256x240 pixels. Now, how do these tables get adjusted for scrolling?
Because Nametable 0 can scroll into Nametable 1, and if you keep scrolling Nametable 0 will wrap around again. That I get. But what I don't get is how to scroll the attribute table wraps around as well. From what I've read online, the 16x16 blocks it assigns attributes for will cause color distortions on the edge tiles of the screen (as seen when you scroll left to right and vice-versa in SMB3).
The concern I have is that I understand how to scroll the nametables, but how do you scroll the attribute table? For intsance, if I have a green block on the left side of the screen, moving the screen to right should in theory cause the tiles to the right to be green as well until they move more into frame, to which they'll revert to their normal colors.
~~~~EDIT:
I do want to point out that I know about the scanlines, X and Y. This thought just ran through my mind.
Let's say I'm at scanline Y of 10. That means I'm reading 10 values into my nametables, horizontally. That would mean my first column is off of the screen, as it only has pixel width of 8. However, the color attribute stays, since it has width of 16.
Assuming the color attribute for the entire column is green, would I be correct in assuming that to the user, the first 6 pixels on the left of the screen would be colored green, and the rightmost 10 on the screen should be green as well?
So, would I be correct in my assumption that according to the screen, the left?
This site I'm sure you are already very, very familiar with. I will preface this by saying I never got to program for the NES, but I am very experienced with all the Gameboy hardware that was ever released and the NES shares many, ahh quirks with the GB/DMG. I going to bet that you either need to do one of a few things:
Don't scroll the attribute table. Make sure that your levels all have similiar color blocks along the direction you are moving. I'd guess that many first generation games did this.
Go ahead and allow limited attribute scrolling - just make sure that the areas where the changes are occuring are either partially color shared or sparce enough that the change isn't going to be noticable.
Get out your old skool atari 2600 timer and time a write to register $2006 in the end of HBlank update to get the color swap you need done, wait a few tics, then revert during the HBlank return period so that the left edge of the next line isn't affected. I have a feeling this is the solution used most often, but without a really good emulator and patience, it will be a pain in the butt. It will also eat a bit into your overall CPU usage as you have to wait around in interrupts on multiple scan lines to get your effect done.
I wish I had a more concrete answer for you, but this hopefully helps a bit. Thanks goodness the GB/DMG had a slightly more advanced scrolling system. :)
Both Super Mario Bros. 3 and Kirby's Adventure display coloring artifacts on the edge of the screen when you scroll. I believe both games set the bit that blanks the left 8 pixels of the screen, so 0-8 pixels will be affected on any one frame.
If I remember correctly, Kirby's Adventure always tries to put the color-glitched columns on the side of the screen that is scrolling off to make it less noticeable. I don't think these artifacts are preventable without switching to vertical mirroring, which introduces difficulties of its own.
Disclaimer: it's been like five years since I wrote any NES code.
Each nametable has its own attribute table, so there should be no graphical artifacts when scrolling from one nametable to another. The type of color glitching you are referring to is really only an issue if your game scrolls both vertically and horizontally. You only have two nametables, so scrolling both ways requires you to cannibalize the visible screen. There are various solutions to this problem, a great summary of which can be found in this nesdev post:
http://nesdev.parodius.com/bbs/viewtopic.php?p=58509#58509
This site may be of some help.
http://www.games4nintendo.com/nes/faq.php#4
(Search for "What's up with $2005/2006?" and begin reading around that area.)
It basically looks like its impossible to get it pixel perfect, however those are going to be the bits you're probably going to need to look into.
Wish I could be more help.
Each nametable has its own attribute table. If you limit your game world to just two screens, you'll only need to write the nametables and attribute tables once. The hard part comes when you try to make worlds larger than two screens. Super Mario Bros. 1 did this by scrolling to the right, wrapping around as necessary, and rendering the level one column of blocks at a time (16 pixels) just before that column came into view. I don't know how one would code this efficiently (keep in mind you only have a millisecond of vblank time).