| further reading | more topics » |
| mjbWorld program | 3D theory |
3D physics |
3D maths |
3D programming | technology |
about site |
sitemap A-Z |
| index | language | dev tools | games | structure | platforms | OOAD | information |
| index | setup | 2d | 3d |
| index | dx9vb | dx9C# | OpenGL C++ |
| index | introduction | installation | basics | restoring | images | animation | transpancy |
| background | sound |
|
This toturial was written for me by Imran Khan (imranahmedkhan82@hotmail.com,
iak1982@yahoo.com). |
||||
|
Background: In this section we will learn how to show Background. You may think that the mechanism to show background must be same to show a bitmap. Yes it is, but with some changes, because the background scroll with the movement of the character. First we declare some instances
As we define rectangle for a character , here we also define a instance of Rectangle class for background to make frames. So that background will move with the movement of the character. Next we define a surface for background. Next we define a integer , we will show the use later. First we create a method name Background( ).
Call the Background method from constructor of form1( "public Form1(): base()" ) , by writing " Background( )" at the last of the method. First line create a new surfacedescription instance for background surface. Next we declare that the surface is simple not a backbuffer. 3rd line we create new surface as we done before. The only new line is last one.4th line set the size of the rectangle, this assumes the part of bitmap you want to display is 800x600 ( size of the screen ). Means it will show that size of frame every time when character moves. Now we will see how to show the picture.
backrect.X = xaxis , it tells to start drawin from
the beginning of the bitmap.We take a variable so that every time the
character moves the xaxis value will be changed and the backrect.X value
will be change so that we will see the background scrolling. Now When the user hit the right arrow the character move(we have done this ) and the xaxis value will also change.
xaxis += 10,whenever user press right key , 10 will be added to this variable so when we call ' ShowSurface( ) ' this value will be copied to backrect.X = xaxis. and the image will be shown from that postion. the next thing we added is : if (xaxis > 1600) it is the limit of the background here, because I have made only 2 scenes so the total lenght of the image will be '1600'. Now if you execute your program you will see a complete game features ( except sound ... ).
|
|
metadata block
|
|
| see also: | |
| Correspondence about this page | |
|
Book Shop - Further reading. Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them. |
|
|
Commercial Software Shop Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them. |
|
|
Can this page be improved? Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page. |
|
|
progam I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here: |
for kdgame programming: http://sourceforge.net/projects/kdgame/ |
This site may have errors. Don't use for critical systems.
Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.