SlideShare a Scribd company logo
1 of 3
Download to read 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

More Related Content

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

Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScriptSam Cartwright
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfADITIEYEWEAR
 
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.pdfanyacarpets
 
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 MilesFrederik 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.pdfJUSTSTYLISH3B2MOHALI
 
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.pdfanjandavid
 
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 DetectionJenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
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.;.pdfaoneonlinestore1
 
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.pdfaaicommunication34
 
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.pdfanwarsadath111
 
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 { .pdfkavithaarp
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicssnelkoli
 
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-.docxAustinIKkNorthy
 
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).pdftrishulinoverseas1
 
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.pdftrishulinoverseas1
 

Similar to 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
 

More from 360transfashion

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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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-.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 
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(.pdf360transfashion
 
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.pdf360transfashion
 
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.pdf360transfashion
 

More from 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
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

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) { }