SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
public class Game extends JPanel implements KeyListener{
public int WIDTH;
public int HEIGHT;
boolean startScreen;
Actor kart;
Actor track;
public void init() {
WIDTH = 640;
HEIGHT = 640;
// Q1: initialiaze the startScreen variable here:
// Q2: create the kart Actor, and initialiaze all its properties here:
track = new Actor("track", -3.9*WIDTH, -2.05 * HEIGHT);
}
public void draw(Graphics2D screen) {
screen.setColor(Color.BLACK);
screen.setFont(new Font("Verdana", Font.BOLD, 30));
if (startScreen)
{
blit(screen,"background1", 0,0);
// Q3: draw the second background here:
screen.drawString("Press Enter", (int)(0.38*WIDTH), (int)(0.73*HEIGHT));
}
else
{
track.draw(screen);
// Q4: draw the kart here:
}
}
@Override
public void keyPressed(KeyEvent e) {
// Q5: complete the code to handel when a key is pressed:
/*
if (startScreen)
{
if(e.getKeyCode() == KeyEvent.VK_ENTER)
......... ;
}
else
{
.....
}
*/
}
@Override
public void keyReleased(KeyEvent e) {
// Q6: complete the code to handel when a key is released:
}
/*****************************************************************************
// This part should not be modified
*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>*/
public Game()
{
setBackground(Color.black);
setSize(WIDTH, HEIGHT);
addKeyListener(this);
setFocusable(true);
init();
}
public void blit(Graphics g, String img, double x, double y) {
String separator = System.getProperty("file.separator");
Image i = new ImageIcon("images" + separator + img + ".png").getImage();
g.drawImage(i, (int)x, (int)y, null);
}
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
draw(g2d);
}
@Override
public void keyTyped(KeyEvent e) {
}
public class Game extends JPanel implements KeyListener{     public in.pdf

Mais conteúdo relacionado

Semelhante a public class Game extends JPanel implements KeyListener{ public in.pdf

import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdf
ADITIEYEWEAR
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
anyacarpets
 
Students to Business Day 2012: Rob Miles
Students to Business Day 2012: Rob MilesStudents to Business Day 2012: Rob Miles
Students to Business Day 2012: Rob Miles
Frederik De Bruyne
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
JUSTSTYLISH3B2MOHALI
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
anjandavid
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
aoneonlinestore1
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdf
aaicommunication34
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
anwarsadath111
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
kavithaarp
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
AustinIKkNorthy
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
trishulinoverseas1
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdf
trishulinoverseas1
 

Semelhante a public class Game extends JPanel implements KeyListener{ public in.pdf (20)

Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScript
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdf
 
Windows Phone: From Idea to Published Game in 75 minutes
Windows Phone: From Idea to Published Game in 75 minutesWindows Phone: From Idea to Published Game in 75 minutes
Windows Phone: From Idea to Published Game in 75 minutes
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
 
Students to Business Day 2012: Rob Miles
Students to Business Day 2012: Rob MilesStudents to Business Day 2012: Rob Miles
Students to Business Day 2012: Rob Miles
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdf
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
 
Sbaw091110
Sbaw091110Sbaw091110
Sbaw091110
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdf
 

Mais de 360transfashion

Q4- Read below scenario and answer the questions- Scenario- Perth.pdf
Q4- Read below scenario and answer the questions-   Scenario-   Perth.pdfQ4- Read below scenario and answer the questions-   Scenario-   Perth.pdf
Q4- Read below scenario and answer the questions- Scenario- Perth.pdf
360transfashion
 

Mais de 360transfashion (20)

Q5-2- The illustration below is a food web diagram for a subset of the.pdf
Q5-2- The illustration below is a food web diagram for a subset of the.pdfQ5-2- The illustration below is a food web diagram for a subset of the.pdf
Q5-2- The illustration below is a food web diagram for a subset of the.pdf
 
Q4-8- Now imagine what might happen in warmer weathe The Kingbirds fro.pdf
Q4-8- Now imagine what might happen in warmer weathe The Kingbirds fro.pdfQ4-8- Now imagine what might happen in warmer weathe The Kingbirds fro.pdf
Q4-8- Now imagine what might happen in warmer weathe The Kingbirds fro.pdf
 
Q4- Read below scenario and answer the questions- Scenario- Perth.pdf
Q4- Read below scenario and answer the questions-   Scenario-   Perth.pdfQ4- Read below scenario and answer the questions-   Scenario-   Perth.pdf
Q4- Read below scenario and answer the questions- Scenario- Perth.pdf
 
Q4- Given the floating point representation (IEEE Sign precision) - (0.pdf
Q4- Given the floating point representation (IEEE Sign precision) - (0.pdfQ4- Given the floating point representation (IEEE Sign precision) - (0.pdf
Q4- Given the floating point representation (IEEE Sign precision) - (0.pdf
 
Q4 (12 marks) Let X follows Geometric distribution with parameter p- L.pdf
Q4 (12 marks) Let X follows Geometric distribution with parameter p- L.pdfQ4 (12 marks) Let X follows Geometric distribution with parameter p- L.pdf
Q4 (12 marks) Let X follows Geometric distribution with parameter p- L.pdf
 
Q4 (10-) 1- What does PC stand for- How to get the address of the next.pdf
Q4 (10-) 1- What does PC stand for- How to get the address of the next.pdfQ4 (10-) 1- What does PC stand for- How to get the address of the next.pdf
Q4 (10-) 1- What does PC stand for- How to get the address of the next.pdf
 
Q3-25- Wildebeests are large mammals that graze in the African savanna.pdf
Q3-25- Wildebeests are large mammals that graze in the African savanna.pdfQ3-25- Wildebeests are large mammals that graze in the African savanna.pdf
Q3-25- Wildebeests are large mammals that graze in the African savanna.pdf
 
Q2- You could use the follouring paths to navigate Linure directories-.pdf
Q2- You could use the follouring paths to navigate Linure directories-.pdfQ2- You could use the follouring paths to navigate Linure directories-.pdf
Q2- You could use the follouring paths to navigate Linure directories-.pdf
 
Q2- What is the difference between HTML elements and tags- Q3- What.pdf
Q2- What is the difference between HTML elements and tags-   Q3- What.pdfQ2- What is the difference between HTML elements and tags-   Q3- What.pdf
Q2- What is the difference between HTML elements and tags- Q3- What.pdf
 
Q2- Which of the following could be used by an incumbent to deter entr.pdf
Q2- Which of the following could be used by an incumbent to deter entr.pdfQ2- Which of the following could be used by an incumbent to deter entr.pdf
Q2- Which of the following could be used by an incumbent to deter entr.pdf
 
Q2- In this predation experiment on the effects of lizards on the spid.pdf
Q2- In this predation experiment on the effects of lizards on the spid.pdfQ2- In this predation experiment on the effects of lizards on the spid.pdf
Q2- In this predation experiment on the effects of lizards on the spid.pdf
 
Q1- Which of the following is considered the basic unit for theory dev.pdf
Q1- Which of the following is considered the basic unit for theory dev.pdfQ1- Which of the following is considered the basic unit for theory dev.pdf
Q1- Which of the following is considered the basic unit for theory dev.pdf
 
Q1-20- Which of the following statements about evolution and ecology i.pdf
Q1-20- Which of the following statements about evolution and ecology i.pdfQ1-20- Which of the following statements about evolution and ecology i.pdf
Q1-20- Which of the following statements about evolution and ecology i.pdf
 
Q1- The primary causes of failure in multinational ventures stem from.pdf
Q1- The primary causes of failure in multinational ventures stem from.pdfQ1- The primary causes of failure in multinational ventures stem from.pdf
Q1- The primary causes of failure in multinational ventures stem from.pdf
 
Q1- Suppose that is uniformly distributed between -1 and 1 - What is.pdf
Q1- Suppose that  is uniformly distributed between -1 and 1 - What is.pdfQ1- Suppose that  is uniformly distributed between -1 and 1 - What is.pdf
Q1- Suppose that is uniformly distributed between -1 and 1 - What is.pdf
 
Q1- Can 172-20-241-39 ping 172-20-240-11- Why or why not- Q2- If an a.pdf
Q1- Can 172-20-241-39 ping 172-20-240-11- Why or why not-  Q2- If an a.pdfQ1- Can 172-20-241-39 ping 172-20-240-11- Why or why not-  Q2- If an a.pdf
Q1- Can 172-20-241-39 ping 172-20-240-11- Why or why not- Q2- If an a.pdf
 
Q1 (4 points) Here is a phylogeny of corona viruses- They have been ar.pdf
Q1 (4 points) Here is a phylogeny of corona viruses- They have been ar.pdfQ1 (4 points) Here is a phylogeny of corona viruses- They have been ar.pdf
Q1 (4 points) Here is a phylogeny of corona viruses- They have been ar.pdf
 
Q- Write one statement to assign x with (a^12 + b^12)^c using the pow(.pdf
Q- Write one statement to assign x with (a^12 + b^12)^c using the pow(.pdfQ- Write one statement to assign x with (a^12 + b^12)^c using the pow(.pdf
Q- Write one statement to assign x with (a^12 + b^12)^c using the pow(.pdf
 
PYTHON Create a Team class- 1- Have the Team class have attributes for.pdf
PYTHON Create a Team class- 1- Have the Team class have attributes for.pdfPYTHON Create a Team class- 1- Have the Team class have attributes for.pdf
PYTHON Create a Team class- 1- Have the Team class have attributes for.pdf
 
Python- Scaling was required in case of multiple linear regression mod.pdf
Python- Scaling was required in case of multiple linear regression mod.pdfPython- Scaling was required in case of multiple linear regression mod.pdf
Python- Scaling was required in case of multiple linear regression mod.pdf
 

Último

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

public class Game extends JPanel implements KeyListener{ public in.pdf

  • 1. public class Game extends JPanel implements KeyListener{ public int WIDTH; public int HEIGHT; boolean startScreen; Actor kart; Actor track; public void init() { WIDTH = 640; HEIGHT = 640; // Q1: initialiaze the startScreen variable here: // Q2: create the kart Actor, and initialiaze all its properties here: track = new Actor("track", -3.9*WIDTH, -2.05 * HEIGHT); } public void draw(Graphics2D screen) { screen.setColor(Color.BLACK); screen.setFont(new Font("Verdana", Font.BOLD, 30)); if (startScreen) { blit(screen,"background1", 0,0); // Q3: draw the second background here: screen.drawString("Press Enter", (int)(0.38*WIDTH), (int)(0.73*HEIGHT)); } else { track.draw(screen); // Q4: draw the kart here: } } @Override public void keyPressed(KeyEvent e) { // Q5: complete the code to handel when a key is pressed: /* if (startScreen) { if(e.getKeyCode() == KeyEvent.VK_ENTER) ......... ;
  • 2. } else { ..... } */ } @Override public void keyReleased(KeyEvent e) { // Q6: complete the code to handel when a key is released: } /***************************************************************************** // This part should not be modified * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>*/ public Game() { setBackground(Color.black); setSize(WIDTH, HEIGHT); addKeyListener(this); setFocusable(true); init(); } public void blit(Graphics g, String img, double x, double y) { String separator = System.getProperty("file.separator"); Image i = new ImageIcon("images" + separator + img + ".png").getImage(); g.drawImage(i, (int)x, (int)y, null); } @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); draw(g2d); } @Override public void keyTyped(KeyEvent e) { }