Monday, April 2, 2012

what is firewall and how it works new method

A firewall is a set of related programs, located at a network gateway server, that protects the resources of a private network from users from other networks. (The term also implies the security policy that is used with the programs.) An enterprise with an intranet that allows its workers access to the wider Internet installs a firewall to prevent outsiders from accessing its own private data resources and for controlling what outside resources its own users have access to.


Basically, a firewall, working closely with a router program, examines each network packet to determine whether to forward it toward its destination. A firewall also includes or works with a proxy server that makes network requests on behalf of workstation users. A firewall is often installed in a specially designated computer separate from the rest of the network so that no incoming request can get directly at private network resources.
There are a number of firewall screening methods. A simple one is to screen requests to make sure they come from acceptable (previously identified) domain name and Internet Protocol addresses. For mobile users, firewalls allow remote access in to the private network by the use of secure logon procedures and authentication certificates.
A number of companies make firewall products. Features include logging and reporting, automatic alarms at given thresholds of attack, and a graphical user interface for controlling the firewall.
Computer security borrows this term from firefighting, where it originated. In firefighting, a firewall is a barrier established to prevent the spread of fire.
Related glossary terms: virus, Firewall Builder (Fwbuilder), screened subnet (triple-homed firewall), bastion host
This was last updated in October 2000

Dig Deeper

  • Next-generation firewalls: Marketing hype or real value?
    Next-gen firewalls have some features that can be of value to large enterprises, particularly visualization and improved levels of granular control.
  • Black Hat 2011: Dan Kaminsky reveals network security research topics
    Noted researcher Dan Kaminsky presented his latest network security research topics, including vulnerabilities in P2P networks, UPNP and home routers.
  • Firewall deployment scenarios for new types of security threats
    Is the firewall still an effective defense against new types of security threats? Network security expert Anand Sastry offers up contemporary firewall deployment scenarios for improving security.

what is new in .net 4.0

ASP.NET 4 and Visual Studio 2010 Web Development Overview

 

Core Services

ASP.NET 4 introduces a number of features that improve core ASP.NET services such as output caching and session-state storage.

Web.config File Refactoring

The Web.config file that contains the configuration for a Web application has grown considerably over the past few releases of the .NET Framework as new features have been added, such as Ajax, routing, and integration with IIS 7. This has made it harder to configure or start new Web applications without a tool like Visual Studio. In .the NET Framework 4, the major configuration elements have been moved to the machine.config file, and applications now inherit these settings. This allows the Web.config file in ASP.NET 4 applications either to be empty or to contain just the following lines, which specify for Visual Studio what version of the framework the application is targeting:
<?xml version="1.0"?>
  <configuration>
   <system.web>
    <compilation targetFramework="4.0" /> 
   </system.web>
  </configuration>

Extensible Output Caching

Since the time that ASP.NET 1.0 was released, output caching has enabled developers to store the generated output of pages, controls, and HTTP responses in memory. On subsequent Web requests, ASP.NET can serve content more quickly by retrieving the generated output from memory instead of regenerating the output from scratch. However, this approach has a limitation — generated content always has to be stored in memory, and on servers that are experiencing heavy traffic, the memory consumed by output caching can compete with memory demands from other portions of a Web application.
ASP.NET 4 adds an extensibility point to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content. This makes it possible to create custom output-cache providers for diverse persistence mechanisms, which can include local or remote disks, cloud storage, and distributed cache engines.
You create a custom output-cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider type. You can then configure the provider in the Web.config file by using the new providers subsection of the outputCache element, as shown in the following example:
<caching>
  <outputCache defaultProvider="AspNetInternalProvider">
    <providers>
      <add name="DiskCache"
          type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/>
    </providers>
  </outputCache>
</caching>
By default in ASP.NET 4, all HTTP responses, rendered pages, and controls use the in-memory output cache, as shown in the previous example, where the defaultProvider attribute is set to AspNetInternalProvider. You can change the default output-cache provider used for a Web application by specifying a different provider name for defaultProvider.
In addition, you can select different output-cache providers per control and per request. The easiest way to choose a different output-cache provider for different Web user controls is to do so declaratively by using the new providerName attribute in a control directive, as shown in the following example:
<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>
Specifying a different output cache provider for an HTTP request requires a little more work. Instead of declaratively specifying the provider, you override the new GetOuputCacheProviderName method in the Global.asax file to programmatically specify which provider to use for a specific request. The following example shows how to do this.
public override string GetOutputCacheProviderName(HttpContext context)
{
    if (context.Request.Path.EndsWith("Advanced.aspx"))
       return "DiskCache";
    else
        return base.GetOutputCacheProviderName(context);
}
With the addition of output-cache provider extensibility to ASP.NET 4, you can now pursue more aggressive and more intelligent output-caching strategies for your Web sites. For example, it is now possible to cache the "Top 10" pages of a site in memory, while caching pages that get lower traffic on disk. Alternatively, you can cache every vary-by combination for a rendered page, but use a distributed cache so that the memory consumption is offloaded from front-end Web servers.


 n the following folder:
    \Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers
    After you define the browser capability, you run the following command from the Visual Studio Command Prompt in order to rebuild the browser capabilities assembly and add it to the GAC:
    aspnet_regbrowsers.exe -I c 
  • For an individual application, you create a .browser file in the application’s App_Browsers folder.
These approaches require you to change XML files, and for computer-level changes, you must restart the application after you run the aspnet_regbrowsers.exe process.
ASP.NET 4 includes a feature referred to as browser capabilities providers. As the name suggests, this lets you build a provider that in turn lets you use your own code to determine browser capabilities.
In practice, developers often do not define custom browser capabilities. Browser files are hard to update, the process for updating them is fairly complicated, and the XML syntax for .browser files can be complex to use and define. What would make this process much easier is if there were a common browser definition syntax, or a database that contained up-to-date browser definitions, or even a Web service for such a database. The new browser capabilities providers feature makes these scenarios possible and practical for third-party developers.
There are two main approaches for using the new ASP.NET 4 browser capabilities provider feature: extending the ASP.NET browser capabilities definition functionality, or totally replacing it. The following sections describe first how to replace the functionality, and then how to extend it.

Replacing the ASP.NET Browser Capabilities Functionality

to know more click blew link or image

what is network security definition

     what is network security

A specialized field in computer networking that involves securing a computer network infrastructure. Network security is typically handled by a network administrator or system administrator who implements the security policy, network software and hardware needed to protect a network and the resources accessed through the network from unauthorized access and also ensure that employees have adequate access to the network and resources to work.


A network security system typically relies on layers of protection and consists of multiple components including networking monitoring and security software in addition to hardware and appliances. All components work together to increase the overall security of the computer network.

what is network -flan-han-wan-can

A network is a group of two or more computer systems linked together. There are many types of computer networks, including:
  • local-area networks (LANs) : The computers are geographically close together (that is, in the same building).
  • wide-area networks (WANs) : The computers are farther apart and are connected by telephone lines or radio waves.
  • campus-area networks (CANs): The computers are within a limited geographic area, such as a campus or military base.
  • metropolitan-area networks MANs): A data network designed for a town or city.
  • home-area networks (HANs): A network contained within a user's home that connects a person's digital devices.
  • In addition to these types, the following characteristics are also used to categorize different types of networks:



    what is host

    You can begin blocking ads and help keep yourself from being tracked by using the Hosts file with Windows and other operating systems.
    What is the Hosts file, and how does it stop ads and tracking?
    The Short Answer:
    The short answer is that the Hosts file is like an address book. When you type an address like www.yahoo.com into your browser, the Hosts file is consulted to see if you have the IP address, or "telephone number," for that site. If you do, then your computer will "call it" and the site will open. If not, your computer will ask your ISP's (internet service provider) computer for the phone number before it can "call" that site. Most of the time, you do not have addresses in your "address book," because you have not put any there. Therefore, most of the time your computer asks for the IP address from your ISP to find sites.
    If you put ad server names into your Hosts file with your own computer's IP address, your computer will never be able to contact the ad server. It will try to, but it will be simply calling itself and get a "busy signal" of sorts. Your computer will then give up calling the ad server and no ads will be loaded, nor will any tracking take place. Your choices for blocking sites are not just limited to blocking ad servers. You may block sites that serve advertisements, sites that serve objectionable content, or any other site that you choose to block.

    The Longer, More Technically Oriented Answer:
    The "Hosts" file in Windows and other operating systems is used to associate host names with IP addresses. Host names are the www.yahoo.com addresses that you see every day. IP addresses are numbers that mean the same thing as the www words - the computers use the numbers to actually find the sites, but we have words like www.yahoo.com so humans do not need to remember the long strings of numbers when they want to visit a site.
    For instance, the host name for Yahoo! is www.yahoo.com, while its IP address is 204.71.200.67 Either address will take you to Yahoo!'s site, but the www address will first have to be translated into the IP address. If you type in the IP address directly, your computer will not have to look it up.
    A series of steps are used when searching for IP addresses that go with these host names. The first step, and the one that concerns us here, is the hosts file on your local computer. The Hosts file tells your computer what the name is in numbers so the computer can go find it. If the IP address is found in your Hosts file, the computer will stop looking and go to that site, but if it is not it will ask a DNS computer (domain name server) for the information. Since the search ends once a match is found, that provides us with a mechanism to block sites we have no interest in. You may block sites that serve advertisements, sites that serve objectionable content, or any other site that you choose to block.
    We can put names and addresses into the Hosts file so your computer does not have to ask a DNS server to translate the domain name into an IP number. This speeds up access to the host site you want to see because your computer no longer has to query other systems on the Internet for the address translation. When you type in a web address like www.yahoo.com, the host name portion of the web address is translated into an IP address before the site is accessed. If you put Yahoo!'s host and IP settings into your Hosts file, it would load a little quicker because your computer doesn't have to ask another to translate where to look for Yahoo!
    Computers have a host address of their own - it is known as the "localhost" address, with an IP address of 127.0.0.1 which it uses to refer to itself. If you associate another computer's host name with your localhost IP address, you have effectively blocked that host since all attempts to access it will lead back to you. That is how we will block sites using the Hosts file. We will tell our computer that the IP address of the site we want to block is our own address. That way, our computer will not ever leave and go looking for the site we are blocking - which keeps that site from appearing because the computer thinks it has found the site and displayed it already.
    Many web sites have links to other servers for the retrieval of advertisements. In the case of those web servers, the browser will quickly fail to locate the requested data (scripts, images, etc.) from the advertising server because we told our computer to look for the information on itself - of course it won't find any of it and will quit looking for it - and will continue loading the pertinent portions of the page you want to see. This will keep your computer from even talking to the ad servers, and thus you won't see the ads, they can't put cookies on your hard drive, and you can't be profiled by them

    what is html

    What is HTML?

    HTML is a language for describing web pages.
    • HTML stands for Hyper Text Markup Language
    • HTML is not a programming language, it is a markup language
    • A markup language is a set of markup tags
    • HTML uses markup tags to describe web pages

    HTML Tags

    HTML markup tags are usually called HTML tags
    • HTML tags are keywords surrounded by angle brackets like <html>
    • HTML tags normally come in pairs like <b> and </b>
    • The first tag in a pair is the start tag, the second tag is the end tag
    • Start and end tags are also called opening tags and closing tags

    HTML Documents = Web Pages

    • HTML documents describe web pages
    • HTML documents contain HTML tags and plain text
    • HTML documents are also called web pages
    The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page:
    <html>
    <body>

    <h1>My First Heading</h1>

    <p>My first paragraph.</p>

    </body>
    </html>

    Example Explained

    • The text between <html> and </html> describes the web page
    • The text between <body> and </body> is the visible page content
    • The text between <h1> and </h1> is displayed as a heading
    • The text between <p> and </p> is displayed as a paragraph

    what is php - Introduction-

    What is PHP?

    • PHP stands for PHP: Hypertext Preprocessor
    • PHP is a server-side scripting language, like ASP
    • PHP scripts are executed on the server
    • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
    • PHP is an open source software
    • PHP is free to download and use

    What is a PHP File?

    • PHP files can contain text, HTML tags and scripts
    • PHP files are returned to the browser as plain HTML 
    • PHP files have a file extension of ".php", ".php3", or ".phtml"

    What is MySQL?

    • MySQL is a database server
    • MySQL is ideal for both small and large applications
    • MySQL supports standard SQL
    • MySQL compiles on a number of platforms
    • MySQL is free to download and use

    PHP + MySQL

    • PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

    Why PHP?

    • PHP runs on different platforms (Windows, Linux, Unix, etc.)
    • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
    • PHP is FREE to download from the official PHP resource: www.php.net
    • PHP is easy to learn and runs efficiently on the server side

    Where to Start?

    To get access to a web server with PHP support, you can:
    • Install Apache (or IIS) on your own server, install PHP, and MySQL
    • Or find a web hosting plan with PHP and MySQL support

    how to regenerate encryption key on blackberry

    In order to generate a new encryption key on your BlackBerry® device, you need to have version 4.0 of the software (or newer) installed on the device.
    To generate a new encryption key:
    1. From the Home screen, click Options, or click Settings > Options (depending on the theme you have running on your device).
    2. Click Security Options, then General Settings.(If your device is running version 4.0 of the software, click Security.)
    3. Scroll down to the Service section and click the trackwheel.
    4. Select Regenerate Encryption Key.
    5. When you see the message "The key for service has been updated," click OK.

    how to check graphic card in laptop or pc

    How can I find out which graphics card I have in my PC?

    SketchUp is a graphics-heavy program. Knowing your graphics card can help you troubleshoot odd visual behaviors or recommend a good-performing card to other users. The easiest way to find your graphics card is to run the DirectX Diagnostic Tool:
    1. Click Start.
    2. On the Start menu, click Run.
    3. In the Open box, type "dxdiag" (without the quotation marks), and then click OK.
    4. The DirectX Diagnostic Tool opens. Click the Display tab.
    5. On the Display tab, information about your graphics card is shown in the Device section. You can see the name of your card, as well as how much video memory it has.

    how to check pnr status -top 10 way

    1. PNR Status - Welcome to Indian Railway Passenger reservation ...

      www.indianrail.gov.in/pnr_Enq.html
      Passenger Current Status. Enter the PNR for your booking below to get the current status. You will find it on the top left corner of the ticket.
    2. Welcome to Indian Railway Passenger reservation Enquiry

      www.indianrail.gov.in/
      Plan you trip on Indian Railways Trains, Check Availability, Seats Availability, Reservation, Enquiry, PNR, Passenger Status, Travel by Indian Railways in India ...
    3. PNR Status : Check PNR Status | Indian Railway Passenger ...

      www.pnrstatuscheck.in/
      Online PNR status check from South Central Railways(Indian railways) for complete rail pnr status.
    4. PNR Status

      www.pnrstatus.info/
      Check PNR (Passenger Name Record) status of your Indian Railways reservations in one single click using an easy and clean interface. IRCTC (Indian Railway ...
    5. Irctc pnr status - Indian Railway reservation - Find pnr - India rail site

      www.irctc-pnrstatus.com/
      Find Indian rail booking site for ticket booking and berth PNR status check. IRCTC PNR website provides instant reservation information from IR India.
    6. PNR Status, Irctc PNR Status, Indian Railways PNR Status

      www.pnrstatus.org/
      27 Jan 2012 – PNR Status, IRCTC PNR Status, Check Indian Railways PNR Status, ... Online Indian Railway PNR Status or IRCTC PNR Status check was ...

    how to check internet speed {Top 10 way}

    1. Speedtest.net - The Global Broadband Speed Test

      www.speedtest.net/
      When you select one of the servers, this speed test quickly checks the bandwidth and latency of your broadband Internet connection to that location. The history ...
    2. Check My Internet Connection Speed | Internet Connection ...

      us.mcafee.com/root/speedometer/
      What is my internet connection speed? McAfee Internet Connection Speedometer tells you how fast or slow your internet connection speed is. Find my internet ...
    3. TestMySpeed.com modem speed tests. Test internet connection ...

      www.testmyspeed.com/
      Internet connection speed test sites to test the connection speed of your ISDN, DSL, Cable modem and more. Bandwidth speed tester.
    4. Test Internet Speed - Check The Performance Of Your Connection

      testinternetspeed.org/
      Perform an internet speed test for free! Check out our online tester and verify your modem, dsl, cable, broadband or high speed internet connection now.
    5. Internet speed Test india - check download speed

      www.internetspeedtest.in/
      Speed check tool for internet or broad band speed test. Please use this internet speed test to test your internet speed.
    6. Speed Test | Bandwidth | Broadband Internet Services

      www.bandwidthplace.com/
      Check your Internet connection with Bandwidth Place, the #1 interactive broadband Speed Test. Get real-time prices, and compare services.

    how is create email id

    How to create an email id?


    There are quite a few things to be kept in mind while choosing an email id. It is tough to change the id after 2-3 years when you have distributed it to everyone. So, one should choose it carefully.


    1. Which email provider should I use?
    One should create at least one yahoo OR one hotmail id so that it can be used to chat on messenger as well.


    2. What should the email id contain?
    Choose a name which looks professional. It should contain letters only from your first name and last name. And it may contain few numbers. A few good examples are - ashishk, akumar, ashish_kumar, ashish79, kumar_ashish, kumar, a_kumar, ashish_k, etc.


    3. What shouldn't the email id contain?
    It shouldn't have any affiliations like company name, college name, nationality, etc. Refrain from using any affiliations. You never know if someone hates something about the affiliation and may not reply to your mails for that very reason. A few bad examples are – cute_ashish, kumar_love, ashish_reck, ashish_tcs, etc.


    4. What rules should it follow?
    • It should be easy to remember.
    • It shouldn't be very long.
    • Don't create email ids which are very generic like simple_girl, lazybones, etc. Most people create weird email ids(like rocky123, lazyboy, etc) to hide their identity and mostly use those ids for criminal purposes or to access pornographic sites. If you plan to use your email id for legitimate purposes, please choose it properly so that people don't get a wrong impression.
    • Include your name in it so that it is easy for your friends to recall.


    5. How many email ids should I create?
    One shouldn't create too many email ids. It is easier to create an id but it is difficult to maintain. Create an id and then stick to it forever.


    If you have already chosen an email id which doesn't conform to the above rules, change it today. It is easier to do it now than to do it 2 years hence.

    how to configured ip address

    How to configure TCP/IP

    To configure TCP/IP, follow these steps:
    1. Click Start, click Control Panel, click Network and Internet Connections, and then click Network Connections.
    2. Right-click the network connection that you want to configure, and then click Properties.
    3. On the General tab (for a local area connection), or the Networking tab (for all other connections), click Internet Protocol (TCP/IP), and then click Properties.
    4. If you want to obtain DNS server addresses from a DHCP server, click Obtain DNS server address automatically.
    5. If you want to manually configure DNS server addresses, click Use the following DNS server addresses, and then type the preferred DNS server and alternate DNS server IP addresses in the Preferred DNS server and Alternate DNS server boxes.

    How to configure the advanced DNS properties

    To configure the advanced DNS properties, follow these steps:
    1. Click Advanced, and then click the DNS tab.
    2. Configure the DNS properties by following the steps that are described in the following sections:
      • How to configure an additional DNS server IP address
      • How to modify the resolution behavior for unqualified DNS names
      • How to modify DNS dynamic update behavior

    How to configure an additional DNS server IP address

    To configure an additional DNS server IP address, follow these steps:
    1. Under DNS server addresses, click Add in order of use.
    2. In the TCP/IP DNS server box, type the IP address of the DNS server, and then click Add.

    How to modify the resolution behavior for unqualified DNS names

    To modify the resolution behavior for unqualified DNS names, follow these steps:
    1. To resolve an unqualified name by appending the primary DNS suffix and the DNS suffix of each connection, click Append primary and connection specific DNS suffixes. To do this, each connection must be configured. If you also want to search the parent suffixes of the primary DNS suffix up to the second-level domain, click to select the Append parent suffixes of the primary DNS suffix check box.
    2. To resolve an unqualified name by appending the suffixes from a list of configured suffixes, click Append these DNS suffixes (in order), and then click Add to add suffixes to the list.
    3. To configure a connection-specific DNS suffix, type the DNS suffix in the DNS suffix for this connection box.

    How to modify DNS dynamic update behavior

    To modify DNS dynamic update behavior, use any of the following methods:
    • To use a DNS dynamic update to register the IP addresses of this connection and the primary domain name of the computer, select the Register this connection's addresses in DNS check box. By default, this check box is not selected. The primary domain name of the computer is the primary DNS suffix appended to the computer name. To view this domain name and DNS suffix together as the full computer name, click Start, click Control Panel, click Performance and Maintenance, click System, and then click the Computer Name tab.
    • To use a DNS dynamic update to register the IP addresses and the connection-specific domain name of this connection, select the Use this connection's DNS suffix in DNS registration check box. By default, this check box is not selected. The connection-specific domain name of this connection is the DNS suffix for this connection appended to the computer name.

    how is ip address assigned



    How to Assign a Static IP Address in XP, Vista, or Windows 7

    When organizing your home network it’s easier to assign each computer it’s own IP address than using DHCP. Here we will take a look at doing it in XP, Vista, and Windows 7.
    If you have a home network with several computes and devices, it’s a good idea to assign each of them a specific address. If you use DHCP (Dynamic Host Configuration Protocol), each computer will request and be assigned an address every time it’s booted up. When you have to do troubleshooting on your network, it’s annoying going to each machine to figure out what IP they have.
    Using Static IPs prevents address conflicts between devices and allows you to manage them more easily. Assigning IPs to Windows is essentially the same process, but getting to where you need to be varies between each version.
    Windows 7
    To change the computer’s IP address in Windows 7, type network and sharing into the Search box in the Start Menu and select Network and Sharing Center when it comes up.
    1start menu
    Then when the Network and Sharing Center opens, click on Change adapter settings.

    Right-click on your local adapter and select Properties.

    In the Local Area Connection Properties window highlight Internet Protocol Version 4 (TCP/IPv4) then click the Properties button.

    Now select the radio button Use the following IP address and enter in the correct IP, Subnet mask, and Default gateway that corresponds with your network setup. Then enter your Preferred and Alternate DNS server addresses. Here we’re on a home network and using a simple Class C network configuration and Google DNS.
    Check Validate settings upon exit so Windows can find any problems with the addresses you entered. When you’re finished click OK.

    Now close out of the Local Area Connections Properties window.

    Windows 7 will run network diagnostics and verify the connection is good. Here we had no problems with it, but if you did, you could run the network troubleshooting wizard.

    Now you can open the command prompt and do an ipconfig  to see the network adapter settings have been successfully changed.

    Windows Vista
    Changing your IP from DHCP to a Static address in Vista is similar to Windows 7, but getting to the correct location is a bit different. Open the Start Menu, right-click on Network, and select Properties.

    The Network and Sharing Center opens…click on Manage network connections.

    Right-click on the network adapter you want to assign an IP address and click Properties.

    Highlight Internet Protocol Version 4 (TCP/IPv4) then click the Properties button.

    Now change the IP, Subnet mask, Default Gateway, and DNS Server Addresses. When you’re finished click OK.

    You’ll need to close out of Local Area Connection Properties for the settings to go into effect.

    Open the Command Prompt and do an ipconfig to verify the changes were successful.

    Windows XP
    In this example we’re using XP SP3 Media Center Edition and changing the IP address of the Wireless adapter.
    To set a Static IP in XP right-click on My Network Places and select Properties.

    Right-click on the adapter you want to set the IP for and select Properties.

    Highlight Internet Protocol (TCP/IP) and click the Properties button.

    Now change the IP, Subnet mask, Default Gateway, and DNS Server Addresses. When you’re finished click OK.

    You will need to close out of the Network Connection Properties screen before the changes go into effect.
     
    Again you can verify the settings by doing an ipconfig in the command prompt. In case you’re not sure how to do this, click on Start then Run.
     
    In the Run box type in cmd and click OK.

    Then at the prompt type in ipconfig and hit Enter. This will show the IP address for the network adapter you changed.

    If you have a small office or home network, assigning each computer a specific IP address makes it a lot easier to manage and troubleshoot network connection problems.

    how to share internet connection-vedio help

    how to share internet connection

    To use Internet Connection Sharing to share your Internet connection, the host computer must have one network adapter that is configured to connect to the internal network, and one network adapter or modem that is configured to connect to the Internet.

    On the host computer

    On the host computer, follow these steps to share the Internet connection:
    1. Log on to the host computer as Administrator or as Owner.
    2. Click Start, and then click Control Panel.
    3. Click Network and Internet Connections.
    4. Click Network Connections.
    5. Right-click the connection that you use to connect to the Internet. For example, if you connect to the Internet by using a modem, right-click the connection that you want under Dial-up.
    6. Click Properties.
    7. Click the Advanced tab.
    8. Under Internet Connection Sharing, select the Allow other network users to connect through this computer's Internet connection check box.
    9. If you are sharing a dial-up Internet connection, select the Establish a dial-up connection whenever a computer on my network attempts to access the Internet check box if you want to permit your computer to automatically connect to the Internet.
    10. Click OK. You receive the following message:
      When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP
      address 192.168.0.1. Your computer may lose connectivity with other computers on
      your network. If these other computers have static IP addresses, it is a good idea to set them
      to obtain their IP addresses automatically. Are you sure you want to enable Internet
      Connection Sharing?
    11. Click Yes.
    The connection to the Internet is shared to other computers on the local area network (LAN). The network adapter that is connected to the LAN is configured with a static IP address of 192.168.0.1 and a subnet mask of 255.255.255.0

    To view a video about how to configure the host computer for Internet Connection Sharing, click the Play button (
    Play

    button
    ) on the following Windows Media Player viewer:

    http://support.microsoft.com/servicedesks/ShowMeHow/3061261.asx



    Note To view this video, you must use Windows Media Player 7.0 or later.

    For additional information about how to obtain Windows Media Player version 7.1, click the following article number to view the article in the Microsoft Knowledge Base:
    299321  Description and availability of Windows Media Player 7.1

    On the client computer

    To connect to the Internet by using the shared connection, you must confirm the LAN adapter IP configuration, and then configure the client computer. To confirm the LAN adapter IP configuration, follow these steps:
    1. Log on to the client computer as Administrator or as Owner.
    2. Click Start, and then click Control Panel.
    3. Click Network and Internet Connections.
    4. Click Network Connections.
    5. Right-click Local Area Connection, and then click Properties.
    6. Click the General tab, click Internet Protocol (TCP/IP) in the This connection uses the following items list, and then click Properties.
    7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an IP address automatically (if it is not already selected), and then click OK.

      Note You can also assign a unique static IP address in the range of 192.168.0.2 to 192.168.0.254. For example, you can assign the following static IP address, subnet mask, and default gateway:
         IP Address      192.168.0.2
         Subnet mask     255.255.255.0
         Default gateway 192.168.0.1
           
    8. In the Local Area Connection Properties dialog box, click OK.
    9. Quit Control Panel.
    To view a video about how to confirm the LAN adapter IP configuration, click the Play button (
    Play button
    ) on the following Windows Media Player viewer:




    Note To view this video, you must use Windows Media Player 7.0 or later.

    For additional information about how to obtain Windows Media Player version 7.1, click the following article number to view the article in the Microsoft Knowledge Base:
    299321  Description and availability of Windows Media Player 7.1
    To configure the client computer to use the shared Internet connection, follow these steps:
    1. Click Start, and then click Control Panel.
    2. Click Network and Internet Connections.
    3. Click Internet Options.
    4. In the Internet Properties dialog box, click the Connections tab.
    5. Click the Setup button.

      The New Connection Wizard starts.
    6. On the Welcome to the New Connection Wizard page, click Next.
    7. Click Connect to the Internet, and then click Next.
    8. Click Set up my connection manually, and then click Next.
    9. Click Connect using a broadband connection that is always on, and then click Next.
    10. On the Completing the New Connection Wizard page, click Finish.
    11. Quit Control Panel.
    When you now start Microsoft Internet Explorer, the client computer will try to connect to the Internet by using the host computer's shared Internet connection.

    To view a video of how to configure the client computer to use the shared Internet connection, click the Play button (

    ) on the following Windows Media Player viewer:




    Note To view this video, you must use Windows Media Player 7.0 or later.

    For additional information about how to obtain Windows Media Player version 7.1, click the following article number to view the article in the Microsoft Knowledge Base:
    299321  Description and availability of Windows Media Player 7.1

    Troubleshooting

    When you turn on Internet Connection Sharing on the host computer, the host computer's LAN adapter is automatically assigned the IP address of 192.168.0.1. Therefore, one of the following situations may occur:
    • IP address conflict
      Each computer on the LAN must have a unique IP address. If more than one computer has the same IP address, an IP conflict occurs, and one of the network adapters turns off until the conflict is resolved. To resolve this conflict, configure the client computer to automatically obtain an IP address, or assign it a unique IP address.
    • Loss of network connectivity
      If your network is configured with a different IP address range than Internet Connection Sharing uses, you will lose network connectivity with the host computer. To resolve this issue, configure the client computers to automatically obtain an IP address, or assign each client computer a unique IP address in the range of 192.168.0.2 to 192.168.0.254.

    how to share a folder in- windows 7-windows xp

    how to share a folder in windows 

    his step-by-step guide describes the process of sharing folders on a computer that is part of a workgroup, configuring security for the shared folders and the subfolders and files they contain, and connecting over the network to shared folders on other computers that are members of the workgroup.

    For example, assume that you have been asked to set up file sharing on a Windows-based computer that is part of a workgroup. You need to create a share contains Accounts Receivable files that are to be used by the Accounting and Sales staff at the company you work for, and to configure security to ensure that only appropriate users get access to the data stored in the share. You need the Accounting staff to be able to read, edit, delete, and create files in the share, while the Sales staff should only be able to read files in the share. The manager of the accounting department (Jane Smith) should be the only user who can change permissions on the contents of the share.

    The computer you are working with has a drives C and D, and you have decided to create the folder that will contain the data on drive D.

    Setting Security on a Folder Before You Share It

    1. Log on to your computer as a user who is a member of the Power Users group or the Administrators group. Click Start, point to Programs, point to Accessories, and then click Windows Explorer.
    2. Click the drive or folder in which you want to create a new folder.
    3. On the File menu, point to New, and then click Folder. Type a name for the new folder (for example, Accounts Receivable), and then press ENTER.
    4. Right-click the new folder, and then click Properties. Click the Security tab.
    5. Click to clear the Allow inheritable permissions from parent to propagate to this object check box. In the Security dialog box, click Copy.

      NOTE: The inherited permissions are copied directly to this folder.
    6. To add a set of permissions, in the Properties dialog box, on the Security tab, click Add. In the Select Users, Computers, or Groups dialog box, double-click the appropriate user accounts or groups (for example, Accounting, Sales, and Jane Smith). When you have selected all the users and groups you want to assign permissions to, click OK.
    The groups and users you added, along with the Everyone group, are displayed in the top half of the Security tab. Follow the next steps to complete the process:
    1. In the Name list, click each user or group one at a time, and then apply the correct permissions in the Permissions list. For example, for the Accountants group, for the Modify permission, click Allow. For the Sales group, for the Read & Execute permission, click Allow. For the user Jane Smith, for the Full Control permission, click Allow.
    2. After you have set the appropriate permissions, click the Everyone group, and then click Remove.

    Sharing a Folder

    1. Click Start, point to Programs, point to Accessories, and then click Windows Explorer.
    2. Right-click the appropriate folder (for example, Accounts Receivable), and then click Sharing.
    3. In the folder's properties, click Share this folder. Use the default name for the share. Click Permissions.
    4. In the Permissions for dialog box, click Add.
    5. In the Select Users, Computers, or Groups dialog box, double-click the Authenticated Users group, and then click OK.
    6. In the Permissions for dialog box, click the Authenticated Users group.
    7. In the Permissions list, for the Full Control permission, click Allow. After you have set the appropriate permissions, click the Everyone group, and then click Remove.

    Connecting to a Shared Folder

    When you share a folder, users from other computers can connect to the folder over the network. When users connect to a shared folder, they can open files; save files; delete files; create, modify, and delete folders; and perform other tasks, depending on the level of permission you grant them. There are several ways of opening shares on another computer:
    • My Network Places
    • Universal Naming Convention (UNC)
    • Mapped network drive

    To Connect to a Shared Folder by Using My Network Places

    1. On the desktop, double-click My Network Places.
    2. Double-click Computers Near Me.
    3. Double-click the appropriate computer in your workgroup. If you are prompted to do so, type the user name and password that is required to gain access to the computer to which you are connecting. After you type the appropriate credentials, a window opens that displays all of the shared folders and printers on the computer to which you are connecting.
    4. Double-click the shared folder to which you want to gain access. You then see all of the subfolders and files in that shared folder. What you can do with those subfolders and files depends on the level of permission you have been granted.

    To Connect to a Shared Folder by Using Universal Naming Convention (UNC) Format

    1. Click Start, click Run, and then type the name using UNC format, where computername is the name of the computer to which you are attempting to connect and sharename is the name of the shared folder on that computer:
      \\computername\sharename
      For example, if you want to connect to a share that is named Data on a computer that is named Fileserver, type \\Fileserver\Data.
    2. If you are to do so, type the user name and password that is required to gain access to the computer. After you type the appropriate credentials, a window opens that displays the contents of the share.

    To Connect to a Shared Folder by Using a Mapped Drive

    1. Click Start, point to Programs, point to Accessories, and then click Windows Explorer.
    2. On the Tools menu, click Map Network Drive.
    3. In the Drive box, click the drive letter that you want to use for this mapped drive. You cannot use any of the drive letters that are currently used by your computer.
    4. In the Folder box, type the name of the share to which you want to connect by using Universal Naming Convention (UNC) format:
      \\computername\sharename
      You can also map drives to subfolders of the shared folder. Therefore, you can map the drive to a subfolder by including that information. For example:
      \\computername\sharename\subfolder
      Or, you can click Browse and then locate the computer to which you want to connect, the share on that computer, and optionally the subfolder in that share.

    Notes

    • By default, Windows attempts to reconnect any mapped drives the next time you log on. If you do not want this to happen, click to clear the Reconnect at Logon check box.
    • By default, you are connected to the other computer with the logon credentials that you are currently using. If you want to use other credentials, click Connect using a different user name, and then type the appropriate user name and password to connect to this network resource.
    • The mapped drive that you create is visible in the Folders pane in Windows Explorer, along with all the other drives on your computer. You can gain access to the files in the shared folder with any program on your computer by using the mapped drive letter.

    Troubleshooting

    Users Cannot Access Files and Folders That They Should Be Able to When Logged On Locally

    Access permissions are combined from any permissions that are assigned directly to the user and those that are assigned to any groups of which the user is a member.

    The exception to this rule is if there is an explicit Deny permission on the folder or file. This occurs because Deny permissions are enumerated first when Windows is determining whether or not a particular user can perform a particular task. Therefore, you should avoid using explicit Deny permissions (that is, avoid clicking to select a check box in the Deny column) unless there is no other way to achieve the permissions mix that you need.

    Users Can Access Files and Folders with Incorrect Permissions When Logged on Locally

    For example, users can write instead of just read when they are logged on locally. Permissions, by default, are inherited from the folder that contains the object. If you are experiencing inappropriate permission levels, check for both inherited permissions that are incorrect for this object and for group memberships that may grant different levels of permissions than you want to have.

    Users Cannot Access Files and Folders That They Should Be Able to Access Over the Network

    When you access data over the network, both share permissions and file and folder permissions apply. Share access permissions are combined from any permissions that are assigned directly to the user and those assigned to any groups of which the user is a member. The exception to this is if there is an explicit Deny permission on the folder or file. This occurs because Deny permissions are enumerated first when Windows is determining whether or not a particular user can perform a particular task. Therefore, if Frank, for example, is a member of a group that has the Deny check box selected for Read in the Deny column, he is unable to read the file or folder, even if other permissions should allow him to do so.

    You should avoid using explicit Deny permissions (that is, avoid clicking to select a check box in the Deny column) unless there is no other way to achieve the permissions mix that you need. Check both the share permissions and the file and folder permissions for the user and any groups of which he or she is a member.

    There Is No Security Tab in the Folder Properties Dialog Box

    If you do not see the Security tab in the folder properties, it is likely that you are using the FAT or FAT32 file system. Windows includes a utility that can safely convert your drive to from the FAT or FAT32 file system to the NTFS file system.

    WARNING: Do not convert your drive if you are running both Windows and another operating system on the computer (that is, if it is a dual-boot computer) and the other operating system cannot read NTFS drives.

    To convert a partition to NTFS:
    1. Click Start, point to Programs, point to Accessories, and then click Command Prompt.
    2. Type convert drive: /FS:NTFS, where drive is the drive that you want to convert.

      For example, to convert drive D to NTFS, type the following line:
      convert D: /FS:NTFS
    3. If you attempt to convert a drive while it is being accessed by Windows, Windows displays a message that prompts you to convert the drive when the computer is restarted. Click Yes, quit any running programs, and then restart your computer.

    how to make a game in java

    how to make a game in java




    The Game

    Most of you are probably familiar with the popular game of Pong. For those of you who aren’t, the game consists of two paddles and a puck which is hit back and forth until someone misses it. A miss by a player equals a point for their opponent and after a predetermined number of points one player will win. The one change that we will make is that we will make our game into an air hockey game which I’m sure many of you are familiar with. The only real difference between our game and a game of Pong will be that our air hockey game could have smaller goal areas, but we will discuss this in more detail later on. Now, this may seem rather simple, but it can be an extremely fun little game to play and is an excellent place for us to start our journey into the world of java games.

    Before we get into the topics of this article we should first examine what we will need for the game so we know what we will need to focus on. There are four important phases that we will need to look for in most games: input, processing, output, and loop.

    The input phase consists of getting the intended actions from the players by looking at the states of the keyboard and mouse. We can then interpret the states of these input devices and have the game respond appropriately to them. For our game of air hockey the main action that the user is going to want to perform is moving their paddle up and down. While it is not found in standard pong like games we may want to also allow for the paddle to moved left and right. It is not immediately apparent that we may want to use the mouse, but we will find a possible use for it later on.

    The processing phase consists of moving the paddles based on the input, moving the puck, and checking for collisions. The types of collisions that we are looking at are puck to paddle, puck to goal area, and paddle to edge of board. If we allow for the user to move the paddles left and right we also have to check for paddle to paddle collisions. Another item that we should keep track of in the processing phase is the current state of the game. There are three main states that we will probably want to have for our game: puck moving, puck set to go after goal or at beginning of game, and game over.

    The third phase is to display the appropriate output on the screen. The means that we are going to have to display the two paddles, the puck, and the scores for each player. We might also want to display some additional information, but for now we will stick with the basics.

    The fourth and final phase is what I loop. The purpose of loop is to perform the previous three phases over and over. How much fun would our air hockey game be if we only accepted input once, only calculated puck and paddle movement once, and only drew the paddles and puck once? The answer of course is not very much fun at all. In order to ensure that the input, processing, and output occurs again and again until the game is over we will end up using threads which I will talk about in a moment.

    Before we get our hands dirty with some coding I want to say that it is important to roughly sketch out what you want to do in your game before you start to code. It is natural for programmers to want to jump right in and code , but it is important to at least spend a little time going over what you want to do and how you are going to go about doing it. This time spent planning will ensure that you have a clear and focused goal, that your idea is feasible, and that you go about your programming in an organized manner.

    Threads

    As I mentioned before in our initial discussion about the game we need to have a loop capability that will allow us repeat the input, processing, and output phases over and over again. In order to do this in our java applet we are going to use a concept called threads. By creating a thread and starting that thread we gain access to a new method called run. Inside this new method we will create a loop that will enable our game to run properly (ie. allowing for a repeat of input, processing, and output).

    Let’s now work through a simple example applet in order to get familiar with the basics of threaded applets. This applet should be in a file called SampleThread.java. The first lines to appear in any of our applets are the imports. In this particular example because we aren’t doing anything fancy all we need is the following import.

    import java.applet.*;

    This allows us to create our basic applet and use the methods necessary to get an applet up and running. The next line in our code is where we actually create our class that represents our java applet. What name do we give to our class? If you said SampleThread then you are absolutely right. The reason we name our class SampleThread is that we have named our code file SampleThread.java and the name of the class must always match up with that filename.

    public class SampleThread extends Applet implements Runnable
    {

    You will notice that after we stated that the class would extend the Applet class we add on the fact that the class will implement Runnable. By implementing Runnable we allow our applet to be threaded and gain access to the method run which we will talk about in a minute. Next we must declare a couple of variables which will allow our thread demonstration to produce something to show what is happening.

      Thread t;
      int i;

    The first variable is going to be our thread that will be created in our applet. The second variable is simply an integer counter that is used to demonstrate that we now have the capability to loop which was the fourth phase that I discussed before.

    Now it is time to write the code for the methods that our class will contain. In the past we have used two main methods: init and paint. We will be using these again, but this time we will also be including a new method, run, which will become a key portion of our applets in the future.

      public void init()
      {
            t = new Thread(this);
            t.start();
    
            i = 0;
      }

    The init method contains a couple of lines that get our thread up and running. The first line is responsible for creating a new thread for the applet. The reason we type this inside the brackets is that when our applet is actually running we have an instance of our SampleThread class. The init method is then run for this instance and the thread is created for this instance. It is possible to have multiple instances of a class so each instance will have a thread setup for that particular instance. If that still isn’t 100% clear don’t worry about it for the time being and hopefully with a little time it will become clearer. After we create our new thread we need to make sure that we start the thread so that our run method, which we will discuss next, is called. I also initialize my counter, i, to zero so that I know the exact value that it begins with. I know that you will find many programmers who just assume that their variables are going to be initialized to zero if they are integers, but this is a dangerous assumption. I have on occasion forgotten to initialize a variable to zero when programming and lucky for me my computer has been nice enough to fix this by doing it for me. One time after programming for a couple of days at home and having no problems with the code or how the program was running I took the program to school. When running the program at school I had no idea why a particular part of the program that ran perfectly at home had a small glitch in it when I ran it at school. After a lot of debugging I finally stumbled across a variable that I was assuming was initialized to zero. It turns out that while my computer at home was nice enough to initialize variables to zero for me the computer at school thought it would be nice to initialize my integer variables to some number other than zero. The moral of this story is don’t assume anything and always make sure that you initialize your variables before you use them.

    The next method that we need to include in our program is the run method. The run method is called when we create a thread in our applet. Inside the run the method we want to loop until the applet is done or the user leaves. For now in order to ensure that we stay in the run method until the user leaves our page we will use a while loop with the keyword true used as the condition. By using the keyword true as the condition we create an infinite loop that will go until either we explicitly break out of it or the user leaves the page containing the applet. It is important not to be scared of infinite loops because they can be very useful to us if we use them properly.

      public void run()
      {
            while(true)
            {
              i++;
              repaint();
    
              try {
                    t.sleep(1000/30);
              } catch (InterruptedException e) { ; }
            }
      }

    You will notice that inside the while loop I always increment the variable i and call the repaint method. The repaint method calls my paint method and if I didn’t call repaint in the while loop any changes that were made to the game (ie. puck moving) would not show up on the screen. The reason I have the variable i is so that each time paint is called the variable i contains a new value which will be displayed on the screen in place of the old one to show that we are looping and that we now know how to implement the fourth phase of our four important phases.

    The last method that we need to implement is the paint method. The paint method is where we take care of the output that we would like to have displayed on the screen. For this applet the paint method is very simple because the only thing that it does is print a string out to the screen which shows the value of i and makes it look marginally pretty by concatenating the string i = to the front of it.

      public void paint(Graphics g)
      {
            g.drawString("i = "+i,10,20);
      }
    }

    If you compile and run this applet you will see that the applet displays the ever increasing value of i on the screen. While this may not seem very exciting it is a fundamental concept that will be critical to getting our air hockey game up and running.

    Keyboard

    The next topic we need to look at is how to get the users input from the keyboard. It is actually very easy to check out input from the keyboard because java provides us with two new methods: keyDown and keyUp.

    One important point that I should mention before we continue is that before an applet will receive keyboard events (ie. call the keyDown or keyUp methods) the user will need to click on the applet area in order to get the focus. The applet only receives keyboard events when it has the focus.

    The following is the syntax for the keyDown method. The keyUp method is identical except of course the method name is changed to keyUp from keyDown.

    public boolean keyDown(Event e, int key)
    {
      message = "value = " + key;
    
      return true;
    }

    You will notice that the keyDown method takes an integer parameter. This integer value contains the value that represents the key which was pressed. I would recommend that you set up a method similar to the one that I have outlined above and then in your paint method you can print out message (a string) so that you can see the values that are associated with each key.

    We now have the capability of accepting input from the keyboard and I think that you will agree with me that it is fairly straight forward.

    Mouse

    Now that we are up to speed on how to get input from the keyboard we can turn our attention to the mouse. The mouse is just as easy as the keyboard to use, but we have more methods at our disposal when we deal with the mouse.

    The following are the methods that we can use for the mouse:

    public boolean mouseEnter(Event e, int x, int y)
    public boolean mouseExit(Event e, int x, int y)
    public boolean mouseDown(Event e, int x, int y)
    public boolean mouseUp(Event e, int x, int y)
    public boolean mouseMove(Event e, int x, int y)
    public boolean mouseDrag(Event e, int x, int y)

    One important point to note here is that for each of the above methods you can simply return true.

    All of the methods for the mouse are fairly clear and understandable. You will notice that each method receives the x and y coordinates of the mouse location with respect to the upper left-hand corner of the applet window.

    The mouseEnter and mouseExit methods are called automatically when the mouse enters or exits the applet area. The mouseDown and mouseUp methods are called when a mouse button is pressed or released. The mouseMove method is called when the mouse is moved in the applet area. The final method, mouseDrag, is called when the mouse is moved in the applet area while a mouse button is pressed.

    The best way to test out these different mouse methods is to set up a basic applet that prints a string out to the screen. The string should be changed by the various mouse methods to reflect which method was called and the current x, y location of the mouse.

    You should now have a fairly good idea about what it takes to work with input from the keyboard and mouse in java applets. It is now time to go back into the realm of output.

    Double Buffering

    We have been focusing on the input and looping phases of our game so far, but now it is time to get back into looking at the output phase. Double buffering is a technique that will be familiar to anyone who has done much in the way of game programming. A common problem that you will notice as soon as you make an applet with threads is that you get an annoying flicker. This flicker comes from the fact that we are drawing bits and pieces of our game when we should be drawing all of our game at once.

    The trick to fixing the flicker problem is actually very simple. The first step that we want to take is to setup a couple of variables.

    Image offscreenImage;
    Graphics offscr;

    The variable offscreenImage is going to be our backbuffer where we will draw what will be appearing next on screen. We need the variable offscr to hold the graphics context of our backbuffer so that we can later draw a variety of stuff into it just like we normally would in our paint method.

    width = size().width;
    height = size().height;
    
    offscreenImage = createImage(width, height);
    offscr = offscreenImage.getGraphics();

    The next important step that we need to take is to setup our backbuffer so that we actually have some space to draw into and then we need to get its graphics context which we will store in offscr. You will notice that I use width and height to store the dimensions of my applet space and that I then use these values to create a backbuffer that is the same size. In order to get the graphics context of this backbuffer I simply have to call the method getGraphics in my variable offscreenImage and we are set. One other note that you need to watch out for is that these four lines of code should be placed inside the init method so that they are executed when the applet first starts up.

    offscr.setColor(Color.black);
    offscr.fillRect(0, 0, width, height);
    
    offscr.setColor(Color.blue);
    offscr.fillArc(0,0,width,height,startAngle,arcAngle);
    
    g.drawImage(offscreenImage, 0, 0, this);

    This next segment of code is an example of what will be in your paint method. The first step is to clear the backbuffer. We do this by simply creating a filled rectangle that has the dimensions of our applet space. Take care to note that rather than using the usual graphics context g we are instead using our backbuffer which is represented by offscr. You can clear the backbuffer to any color that you want, but I decided here that black was a good color. We can then proceed to draw any shapes or text that we would like to display while making sure that we use offscr rather than g. Once we are ready to flip our buffers and display what is in the backbuffer on the screen we then use g.drawImage to display the buffer on the screen. This way we draw everything at once. If you don’t remember what the parameters of the drawImage method stand for make sure you check back to part one of this series.

    public void update(Graphics g)
    {
      paint(g);
    }

    This piece of code that we need to add to our program to get double buffering working is the update method. Normally the update method clears the screen and then paints, but this will again lead to flicker so we need to make sure that all it does is paint. If you try writing a program with the above code, but leave out the update method change that I have shown you will still see flicker and all your work will be for naught so take care.

    Coding the Game

    So now that we have a basic idea of how to use threads, double buffering, and the mouse and keyboard we can start working on an air hockey game. I will cover what needs to be coded and how we could go about doing this here and you can look at the sample code which is available on my web site (www.cpsc.ucalgary.ca/~kinga). The code may look kind of confusing, but in the next article I will talk about how to use additional class and methods to make our code look more organized and easier to read.

    First off we are going to need to accept input so that the players can move their paddles up and down. The easiest way to accomplish this is going to be to set up a keyDown function with 4 if statements that test the key pressed against the up and down keys for the two players. These if statements will end up changing the value in a variable holding the y position of the appropriate paddle. This y position will be used for the drawing of the paddle and for collision tests to ensure that the paddle doesn’t go off the edge of the board.

    If you want to expand the game a bit an extra that you could could add in here would be allowing the paddles to move left and right as well as up and down. This means that you will have to add some extra collision detection code in to check the paddles against the edges of the board and the other paddle. You could also try adding in some mouse support for your game. This could include the ability to use the mouse to move one of the paddles around or you could use the mouse to create some sort of menu system.

    The third step that we need to cover is the output on the screen. Now you are probably saying what happened to step number two, but don’t worry it is coming shortly. The output that we need for the screen is very, very simple. All we really need are two filled rectangles for the paddles, an oval for the puck, and some text to display the score. If we wanted to we could make things more complicated by having a nice background for the game to be played on (an image or something dynamic like a starfield), having a puck whose color is constantly changing, or even obstacles on the board (this could get complicated so don’t start off trying to do this).

    The second phase which I talked about at the very beginning is the processing stage. So what needs to be processed in our game and what variables will we most likely need? The goal of the game is to have a puck bouncing back and forth on the board and it should bounce off the walls and the paddles. First off we are going to need to have the coordinates of the puck and the two paddles. This means that we will need to have an integer x,y value for each of them. Next we are going to need to have a speed value for the puck. The speed values will be integers which represent the change in the x and y postion of the puck in each time step. With this much information we can move the puck in our run method and test the positions of the puck and paddles to see if there is a collision.

    This brings up a good point: how do we detect collisions. There are a lot of complicated formulas for checking collision, but there are some simple methods that will be sufficient for us.

    Paddle-Board Collision

    For our purposes I’m going to assume that the board is the size of the entire applet area. This means that the extents of the board are from 0 to size().width and 0 to size().height. You will notice that here that I have used size().width and size().height here to represent the maximum height and width of the applet space. If you use these exactly as I have written here in your programs they will provide you with the values that you desire. Testing the paddle for collision with the edge of the board is as simple as having if statements to check whether or not the y value of the paddle is greater than the maximum height or less then zero. If you allow the paddle to move left and right then you can check to see if the x value of the paddle is less then 0 or greater than the maximum width. If we discover that there is a collision or we have gone over the edge of the board then all we have to do is move the paddle back onto the board (eg. 0 or max. height – paddle size).

    Paddle-Paddle Collision

    We only need to worry about paddle to paddle collision if we allow the user to move his paddle to the left and right. You could even avoid having to worry about this type of collision if you said that a player couldn’t move his paddle past the center of the board. Another option would be to let the paddles simply pass through each other with no collision at all. I would recommend one of the above options since the number of times the two paddles are going to get close enough for a collision is almost zero. If you are still interested in pursuing this type of collision then I would recommend that you follow the process that I will discuss in a moment for paddle and puck collisions. This method involves taking the x and y position of the paddle and comparing it against the four edges of the other paddle to see if it is inside the other paddle. If a collision has occurred then we want to move it out of collision.

    Paddle-Puck Collision

    Checking for collisions between a paddle and the puck isn’t easy, but it is a very important part of the game. You could try to get fancy here, but I recommend that you keep it simple. I believe that the easiest way to check for a collision is to check the x and y coordinates of the puck against the four edges of the paddle. The four edges of the paddle are: paddlex, paddlex + paddle_width, paddley, and paddley + paddle_height. With this knowledge in hand it is a simple matter of creating an if statement for each paddle which will consist of four parts testing the four aforementioned edges against the x and y of the puck to see if the puck is inside the paddle. If it is unclear what is going on I would recommend drawing a little diagram of what the situation looks like and this should make things easier for you. Once we have discovered that a collision has occurred then we need to come up with some means of resolving the collision. The best way to do this is to take the speed of the puck in the x direction and negate it. By negating it we get very believable bouncing of the puck off of the paddle. You could also try to add in the possibility of the puck bouncing off the bottom part of the paddle so the x would stay the same, but the y would change. While this might initially sound like a great thing to do it doesn’t necessarily add a lot to the game so try it out and decide for yourself whether it is worth the extra effort.

    One problem that you might come across is a shimmy. This is where the puck collides repeatedly with the paddle and ends up shimmying up or down the paddle before it finally breaks away. This is something that you want to avoid at all cost because it makes your game seem unprofessional and incomplete. A possible solution for this problem is to check the speed of the puck in the x direction. If the puck is coming towards the paddle then it can be checked for a collision. If on the other hand it is going away from the paddle then we can ignore any collisions that we might think we have.

    Puck-Board Collision

    Testing for collisions between the puck and the edge of the board is identical to the test that we performed when testing for collisions between the paddles and the board. The only tricky part that we have to watch out for here is that we must check the x and y values of the puck against the extents of the board. Again to resolve this particular type of collision all we have to do is negate the x or y speed of the puck depending on the edge of the board that we hit.

    Puck-Goal Collision

    This is going to be the same process as what we had to carry out for the paddle to board collision test except in this case we want to check the puck against a limited part of the board. As a starting point lets assume that the goal area consists of the entire left and right hand parts of the board. This means that we can check the x value of the puck against 0 and the maximum width of the board. If we register a collision here then we must increase the score for the appropriate player and put the puck back at the center of the board.

    The fourth and final phase is to loop. The loop as we discussed before is accomplished by using threads and the run method. If you are unsure about this you can either refer back to the threads section or check out the sample code for the air hockey game which is available on my web site.

    You are now well on the way to creating a great air hockey game. Once you have a basic game up and running you should start playing around and trying to make additions and alterations to your game. Once you have finished your game I would appreciate it if you would send me a copy of your code (kinga@cpsc.ucalgary.ca) and your applet so I can post it on my web page for others to see and learn from. For now my web site iswww.cpsc.ucalgary.ca/~kinga, but I’m in need of a new location so when I find one I will inform you of the new address.

    Popular Posts