<< Chapter < Page
  Xna game studio     Page 2 / 9
Chapter >> Page >

Listings

  • Listing 1 . Beginning of the class named Game1.
  • Listing 2 . The constructor for the class named Game1.
  • Listing 3 . Beginning of the overridden LoadContent method.
  • Listing 4 . Compute the position of the UFO relative to the game window.
  • Listing 5 . Compute the base scale factor for the background image.
  • Listing 6 . Beginning of the overridden Update method.
  • Listing 7 . Apply dynamic scaling to the background image.
  • Listing 8 . Adjust the origin for the background image.
  • Listing 9 . Beginning of the overridden Game.Draw method.
  • Listing 10 . Draw the UFO.
  • Listing 11 . The class named Game1 for the project named XNA0124Proj.

General background information

Layer depth

When you draw two or more sprites using the SpriteBatch.Draw method, you can specify the z-order as the last ( layerDepth ) parameter to the Draw method. By default, a non-transparent sprite that is drawn with a layerDepth value of 0.0 will hide sprites drawn with greater layerDepth values. The greater the layerDepth value, the further back will be the sprite in the z-order, up to a maximum value of 1.0, which represents the extreme back of thez-order.

Color key transparency

During the design phase of project development, you can cause the program to interpret one specific color as being transparent by setting the Color Key Color property to that color and setting the Color Key Enabled property to true as shown in Figure 1 . Although I have never tried to do it, you can also apparently accomplish this at runtime by settingproperties of the TextureProcessor class.

Figure 1 . Property settings for green transparency.

missing image

Transparent green

Figure 1 shows the property settings required to cause every pixel having a color of pure green (0,255,0) to be replaced with transparent black, regardlessof the actual alpha value of the green pixel.

Store your image in a lossless image file

If you use this capability, you must be careful not to store your image in a file that uses lossy compression, such as a JPEG file. If you do, the pure colorthat went into the file is not likely to be pure when you later extract the image from the file. Instead, you should store your image in a lossless filesuch as a BMP file or a PNG file.

Be aware of the default values

Even if you don't plan to use this capability, you need to be aware of it. It seems that any time you add an existing image file to the content folder, the Color Key Enabled property will be true by default and the Color Key Color property value will be magenta (255,0,255). If you fail to disable the Color Key Enabled property, all of your pure magenta pixels will be replaced by transparent black pixels.

In the early days of computer graphics, magenta was the defacto standard transparency color. It was referred to as "magic pink."

Preview

In this module, I will present and explain an animated sequence in which a UFO flies over an alien planet. You will view the action as if the camerais trained on the UFO while maintaining a constant position relative to the UFO.

As the program runs, the planet gets larger and larger creating the illusion that the UFO is getting closer and closer to the surface of the planet. Finally,the program resets and the sequence repeats.

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Xna game studio. OpenStax CNX. Feb 28, 2014 Download for free at https://legacy.cnx.org/content/col11634/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Xna game studio' conversation and receive update notifications?

Ask