|
||||||
| Java Tutorials Tutorials and Code for Java |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
One of the most popular things Java is used for is to make online games. While making 3d games is near impossible, two dimensional games are very do-able.
Although designing an entire game is beyond the scope of this tutorial, I will introduce to you the basic use of the graphics library. We are going to implement this into a applet to lets start with the basic framework. Java Code:
Next we are going to import the graphics class located in the java.awt package. Java Code:
Then we are going to override the paint method. Java Code:
Once we are at this point, we can call many methods on the Graphics object "g." I'm going to create a simple square. To do that we are going to use the drawRect() method which requires four parameters. The x location of the upper left corner, the y location of the upper left corner, the width, and the height. We end up with a class that looks like this:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| questions about java games | stack | Java Help | 3 | 07-02-2007 05:35 PM |
| MS-SQL deadlock and hang the Java application | reachpradeep | Database & Database Programming | 1 | 03-11-2007 04:20 AM |
| Java Facts | techni68 | Java Help | 0 | 01-17-2007 01:41 PM |
| John's Java Tutorial Index | John | Java Tutorials | 0 | 01-11-2007 03:05 PM |
| Java Help Files | xXHalfSliceXx | Java Help | 3 | 11-28-2006 11:30 PM |