Meaning of parent of a window - parent

In 12th Std. computer textbook, gseb (Page no. 28) it is mentioned "If the current window doesn't have a parent, it is treated as a target="self". What is meant by parent of a window? I tried searching on Google but didn't get a satisfactory result. I think the answer to this question would be helpful to not only me, but many students studying in std. 12 gseb.

What is meant by parent of window is window.parent. So the text says if window is not encapsulated in a set of frames then window.parent is strictly equal to window.

Related

Godot debug window not triggering area2d signals

Video of what's happening exactly
Specs are:
Display being recorded 2560x1080#60hz
Display that the window goes offscreen 3840x2160#24hz (tested with 60hz too)
Windows 10
GPU Nvidia 970 GTX
Just started learning godot this week and lost hours to this strange behavior.
Godot specifics:
Scale of shapes and bodies are not modified (not to mess with physics)
Starting out trying to create an Entity class, that extends KinematicBody2D, to create instances of enemies within my game. Just using the dummy block for now to test if collisions are indeed working (stopped here due to what happened on the video)
The big dummy square that has one square texture is said Entity, with a collision with huge Y size just to test things out.
The area2d I want to trigger the signal is the small rectangle in front of the character.
Is there something I should know that is causing the signal to only fire while the debug window is on the other display? Should I just move the debug window to the other display and trust the game will work?
Code snippets
Creation of Area2D inside my animation controller
func _create_shape_with_collision(s : Shape2D, parentNode : Node) -> Node:
var ret = Area2D.new()
ret.connect('body_entered', self, '_check_body_entered')
var c = CollisionShape2D.new()
c.shape = s
parentNode.add_child(ret)
c.disabled = true
c.name = 'collision_shape'
ret.add_child(c)
return ret
signal function
func _check_body_entered(body : Node):
print(body.name)
PS: Attempted to type some stuff to help with autocomplete within Godot's interface, but my created classes were not working properly.
PS2: posted this same message on godot's reddit page, in hopes of better visibility
Make sure you have a matching Collision layer and mask in the Area2D node.
Shape2D is a resource, meaning if you don't create .new() then all CollisionShape2D are using the same instance of the shape. If anyone sets explicitly it free it's gone for everyone (so try printing if you accidentally are assigning a null shape). There's some weirdness on resizing after assigning not happening when CollisionShape2D is ready.
But also you have c.disabled = true that probably shouldn't be there.
Because #Theraot laid a path towards writing an issue on Godot's Github page, I was able to determine the cause of the above bug, while creating a minimal project.
In fact, it does not relate at all with the code, but on project settings. The physics FPS was set at 60, while my secondary screen was able to capture the event, as VSYNC was also on by default (caps FPS at refresh rate, secondary screen is 24hz).
Increasing the physics FPS to 120 (empyrical at this point) made the signal work on all displays.
Will gladly accept a better answer, explaining what are the impacts of changing such number (the strain on devices etc), if it is a bad practice or if there is another way to configure individual faster ticks for Area2Ds or PhysicsBody2Ds. Could not write such answer due to my current lack of knowledge/research. Trying to write it at this point would be a sophism.
Since i'm just coding some basic game elements while writing a Game Design Document, it's so far so good for me.
Edit:
After an insight from user #Theraot, I overlooked how different _process and _physics_process worked; For my use case, most of what I was doing should be inside _physics_process, so I could revert the engine's physics FPS back to default value.

Which inertial reference frame's ECI coordinates does `poliastro` return out of `Orbit.from_vectors` when Earth is the attractor?

This is cross-posted from a Physics SE question in case people there do not use poliastro very often/much. Please check there prior to answering here in case it has already been overcome by events.
The Python poliastro package documentation states that, when propagating from position and velocity vectors, the orbit's reference frame will be "one pseudo-inertial frame around the attractor," which means a form of ECI when Earth is the attractor. However, I want to make sure its epoch is the same as that specified by the IERS.
I have already checked answers to a similar post and found the clarity to be lacking. I want a specific answer in this case from someone who has used poliastro in the following form:
from astropy import units
from poliastro.bodies import Earth
from poliastro.twobody import Orbit
from poliastro.twobody.propagation import kepler
ephemerisPosition = (ephemerisPosition * units.earthRad).to(units.meter)
ephemerisVelocity = (ephemerisVelocity *units.earthRad / units.day).to(units.meter / units/second)
seconds = ephememerisStart + secondsOffset
for i, time in enumerate(seconds):
ss = Orbit.from_vectors(Earth, ephemerisPosition, ephemerisVelocity).propagate(time * units.second, method=kepler)
There are several open issues at GitHub/poliastro related to how poliastro treated reference frames. It appears that poliastro is trying to use a Geocentric Celestial Reference System (GCRS) as its Earth Centered Inertial frame of reference. From looking at the code in the poliastro master branch and from looking at the many open issues related to reference frames, I would call what they use is pseudo-GCRS frame.
GCRS is, by definition, a relativistically correct frame of reference. Poliastro is fully Newtonian. It ignores speed of light issues. It ignores the difference between Terrestrial Time (TT) and Barycentric Dynamical Time (TDB). It ignores geodesic precession. It ignores lots of things. The combination of the above is why I wrote that poliastro uses a pseudo-GCRS frame for its Earth Centered Inertial frame.

Threading In a WinForm [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Everything in my app is working like I want but I don't really understand how exactly? I setup a couple of threads to monitor some resources the app will need from time to time. The threads update a couple of labels saying "all good" or "uh oh"(not really but you get the idea). I setup the test of InvokeRequired to make sure it executes on the thread that created the labels and everything works great.
What I don't understand is... If i'm typing into a a textbox while the labels are being updated shouldn't i see some kind of lag in my typing since it's on the same thread or at least have to implement some code so i can continue typing where i left off? My guess is that the Invoke method takes care of things so i can continue typeing where i left off.
It's working so I shouldn't complain but I don't want some bug to popup a month from now that I really don't understand.
Short answer: there is nothing to worry about.
Explanation: Pretty much every GUI system in existence, including WinForms, is single-threaded, so nothing happens simultaneously, but also consider that most operations are lightning quick too (even painting).
A better explanation would explain how the GUI message loop works, but I'm too lazy to explain it, but I will explain the part you say you don't understand. This is the sequence of events when you type into a textbox:
Keypress message received by the root window (by its message loop)
Keypress message is dispatched to the textbox from the root window
Keypress message received by textbox. Textbox updates its internal state by appending the new character to its internal Value string.
The textbox informs the parent window that the texbox needs to be repainted at the next nearest opportunity because its text value has changed.
The root window gets the next message: which is a request to perform a method invokation (because Invoke or BeginInvoke was called from another thread).
The root window executes this invoke method.
In this case, your Invoke'd code, as far as I can tell, just sets the Text property of a label, this operation is quick as it just sets the internal state of the label, it does not cause it to be painted directly, instead (as in step 4), it marks the label as "invalidated" and must be repainted at the next best opportunity (see step 8).
The root window gets the next message: a request to repaint the textbox
The root window instructs the textbox to repaint itself
The root window gets the next message, or sits idle waiting for the next message to be received
So yes, there is the possibility for lag or a delay in the message cycle, for example, if your Invoke'd code takes more than a few miliseconds to execute. If you add Thread.Sleep(10*1000) in your Invoke'd code, you'll see.

working sprite collision [duplicate]

This question already has answers here:
How do I detect collision in pygame?
(5 answers)
Closed last month.
I am having two problems with my code:
I don't know how to make my character check that it's colliding with the blocks
How do I blit to a new screen every time she completes a level? So when the character reaches the stair then a new screen should appear showing the new level
Here is all my code :
http://pastebin.com/u/bluesplay106
I am pretty new to pygame so my style may not be good and I kind of hard coded this game.
If you could tell me how to fix my problem that would be really great!!
for the collision detection you need to make your character and your blocks into sprites and do a collision detection that way.
As for the new screen when you get to the stairs, you can use a statement like this:
if heroSprite_x >= 200 and heroSprite_x <= 300:
if heroSprite_y >= 300 and heroSprite_y <= 400:
#go to new screen using either a new level from a list or a new class or whatever method you want.
Your question was a bit vague but I hope that's what you were looking for :)
I just realized I didnt answer your first question, here's a snippet from one of my games:
unit_enemy = pygame.sprite.groupcollide(unitgroup, enemygroup, True, pygame.sprite.collide_mask)
for hit in unit_enemy:
#do something
This checks if any enemies hit my unit. So in you case it would be your hero, and the enemies would be blocks.
Here's the documentation on collision detection.
http://pygame.org/docs/ref/sprite.html

NES Programming - Nametables?

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).

Resources