2D GAMES - PART 3

We can use the method Collision not only for collisions but to define an area of the 2D "vista" where the avatar will go to another level. By example: the avatar going inside/out a house:

The complete code you find at the dowloadable material. A fragment:

...
if (e.Key == Key.I ){ 
  ...
 if(Collision(doeB,inhouse)==1){
   navWindow.Source = new Uri("Window3.xaml", UriKind.RelativeOrAbsolute); 
   myApp.Properties["trans1_3"]="1";
 } 
    
...

TIP: To find the points in the 2D "vista" for the creation of "shadows-for-collision" we can define:

...
private void buttonDownHandler(object Sender, MouseButtonEventArgs e){
  Point p = e.GetPosition(TheCanvas);
  Text1.Text=p.ToString();
}
...

For the demo, create a folder having the name of the .ZIP file and download it - right-clicking the link - and unzip inside the folder :

Dd7.zip

Look our Flash demo using the same tricks. Click to activate. Try to go to the house. Use the arrow keys to move the avatar.:

If you like the creation of 2D games you can read our tutorials serie (using Flash) here.

REMEMBER: The keys to move the avatar at the Avalon demo are "i", "k", "l" and "j".

If you like only to see the application running you don't need to do the above download. Only liberate the firewall and play this web3d application:

We are doing our tests at a: Notebook DELL Latitude D600 - Intel Pentium M755 2.0 GHZ - Memory: 512 MB - VideoCard ATI Radeon 9000 32MB DDR 4xAGP - Resolution 1400x1050 - Communication: ADSL 256 kbps (Download: 45 kBps, Upload: 14 kBps)


PREVIOUS LESSON
T.CONTENTS HOMEPAGE