Question
Deliverables .java files as requested below XML files Basic Requirements The final project game: The scenario is based on the Pennsylvania State University system. A
Deliverables
.java files as requested below
XML files
Basic Requirements
The final project game: The scenario is based on the Pennsylvania State University system. A character (a student, a football player, a famous Penn State icon, etc.) will be walking around the state of Pennsylvania and will enter five campuses, one at a time. At each campus, the character will face challenges such as answering questions, solving a puzzle, or playing a game. The character will collect points in each location. After five visits, the game will end. Then a final screen will be shown, displaying the character's rankings according to his/her performance.
Detailed Requirements
The Map
The character will move on a map. It might be a sketch built with graphics (panels, buttons, etc.,) and a picture background.
The application has to have more than five campuses so the user has a choice of where to go. Find a creative way to also represent World Campus. It might be a special key or place for the character to enter World Campus. In order to enter the other campuses, the character has to be moved over the campus position on the screen.
The Campuses
As the character enters a campus, a new panel should show up. The panel will have one or more questions, or a challenge (a puzzle or a game). When the answer is given or the challenge is over, the character should be put back on the main map screen where he/she was last. You should keep score of the character's performance to use it in the final ranking.
The Character
The character has to be picked from a list of three choices. Each choice should make the character different; for instance, it might move faster, it might, more or less, be able to answer the questions, or have more or less speed or strength when he/she plays the games at each campus.
The Character's Movement
The character will be moved using the keyboard. When the character gets close or on top of the campus, the campus panel should appear and the campus game should be ready to be played.
The character should have an icon representing the user choice.
The Theme
The user might choose from three different options for a game theme. For instance, the theme might be Penn State football and the questions and games will be themed around that. Also, the theme might be Math and the questions and puzzles will regard Math. The theme options are your choice.
Game Over
When the character has entered and interacted with five campuses, the game is over and a final screen with the character's ranking should be displayed.
XML
The text of the questions and of the final ranking should be kept in a file and read when needed. You have to use what you learned in the XML lesson to read and write the file. XML is the required format, and it should be used as explained in the lesson.
The Timer
The time (duration of game play) should be kept, displayed at all times (you might use a progress bar, for instance), and be part of the final ranking. You might choose to give a time limit and require players to enter five campuses before the time limit is reached. A final screen with the score, time, and ranking should be shown.
Class structure
All the projects:
Have to start the basic class with the main method. It will create a JFrame, specified below.
Will have their own JFrame extending from Java's JFrame. This JFrame will create a JPanel specified below.
Will have their own JPanel extending from Java's JPanel.
Java Code
It has to be based on the examples given in class and in the textbook. If you intend to use advanced code, clear it with the instructor first.
Suggestions
Use inheritance where appropriate. Use parameters to reuse code. For instance, the Questions panel might use one panel class that receives different parameters (number of questions, name of the file with the questions, theme). Use the course examples and your own labs to get started. Start simple: start with something you might be more comfortable with. It might be the main screen, the character movement, or creating one questions/answers panel. Try to follow the lesson's examples and standards.
What Will Be Assessed
Develop, test, and execute a graphic application for simulations using Java.
Create a Java application.
Given a set of events, choose the resulting programming actions.
Understand the principles behind Java.
Understand the basic principles of object-oriented programming, including classes and inheritance.
Deliverables
.java files as requested below.
Requirements
This week the focus is on the options and the creation of a main game panel (the main panel with the map with all the campuses).
Make sure that the options chosen by the user are passed to the main game panel.
Display the choices in the main game panel.
Create default options or make sure that the user doesnt jump to the main game panel without choosing options.
Begin implementing the navigation (in and out) to the campuses' panels .
From last week:
Develop the intro screen for the game.
Add separate panels for instructions, game designers, etc.
public class app {
public static void main(String args[]) {
group6JFrame gjf = new group6JFrame();
}
}
import java.awt.*;
import javax.swing.*;
public class group6JFrame extends JFrame {
JPanelControl jpc;
public group6JFrame() {
super("Group 06: First Final Project Deliverable");
jpc = new JPanelControl();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpc, "Center");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(640, 480);
setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JPanelControl extends JPanel implements ActionListener {
JPanelIntro jpIntro;
JPanelInstructions jpInstructions;
JPanelDevelopers jpDevelopers;
JPanelThemeSelection jpTS;
JPanelCampus jpCampus;
public JPanelControl() {
super();
setBackground(Color.LIGHT_GRAY);
setLayout(new GridLayout(1, 1));
jpIntro = new JPanelIntro();
jpIntro.jbStart.addActionListener(this);
jpIntro.jbInstructions.addActionListener(this);
jpIntro.jbDevelopers.addActionListener(this);
jpTS = new JPanelThemeSelection();
jpTS.jbTS1.addActionListener(this);
jpTS.jbTS2.addActionListener(this);
jpTS.jbTS3.addActionListener(this);
jpInstructions = new JPanelInstructions();
jpInstructions.jbInstructs5.addActionListener(this);
jpDevelopers = new JPanelDevelopers();
jpDevelopers.jbDev5.addActionListener(this);
add(jpIntro);
}
@Override
public void actionPerformed(ActionEvent event) {
Object obj = event.getSource();
if (obj == jpIntro.jbStart) {
remove(jpIntro);
add(jpTS);
validate();
repaint();
}
if (obj == jpIntro.jbInstructions) {
remove(jpIntro);
add(jpInstructions);
validate();
repaint();
}
if (obj == jpInstructions.jbInstructs5) {
remove(jpInstructions);
add(jpIntro);
validate();
repaint();
}
if (obj == jpIntro.jbDevelopers) {
remove(jpIntro);
add(jpDevelopers);
validate();
repaint();
}
if (obj == jpDevelopers.jbDev5) {
remove(jpDevelopers);
add(jpIntro);
validate();
repaint();
}
if (obj == jpTS.jbTS1) {
jpCampus = new JPanelCampus("programming");
remove(jpTS);
add(jpCampus);
validate();
repaint();
}
if (obj == jpTS.jbTS2) {
jpCampus = new JPanelCampus("football");
remove(jpTS);
add(jpCampus);
validate();
repaint();
}
if (obj == jpTS.jbTS3) {
jpCampus = new JPanelCampus("math");
remove(jpTS);
add(jpCampus);
validate();
repaint();
}
}
}
import java.awt.*;
import javax.swing.*;
public class JPanelIntro extends JPanel {
JButton jbStart, jbInstructions, jbDevelopers;
JLabel jlTitle1, jlTitle2;
public JPanelIntro() {
super();
setLayout(null);
jlTitle1 = new JLabel("Welcome To The Penn State Game!");
jlTitle1.setBounds(new Rectangle(220, 10, 200, 40));
add(jlTitle1);
jlTitle2 = new JLabel("Select an Option:");
jlTitle2.setBounds(new Rectangle(270, 40, 200, 40));
add(jlTitle2);
jbStart = new JButton("Start Game");
jbStart.setBounds(new Rectangle(230, 90, 180, 80));
add(jbStart);
jbInstructions = new JButton("Instructions");
jbInstructions.setBounds(new Rectangle(230, 200, 180, 80));
add(jbInstructions);
jbDevelopers = new JButton("Game Developers");
jbDevelopers.setBounds(new Rectangle(230, 310, 180, 80));
add(jbDevelopers);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");
g.drawImage(myImage, 0, 0, this);
}
}
import java.awt.*;
import javax.swing.*;
public class JPanelInstructions extends JPanel {
JButton jbInstructs1, jbInstructs2, jbInstructs3, jbInstructs4, jbInstructs5;
public JPanelInstructions() {
super();
setLayout(null);
jbInstructs1 = new JButton("1. Move your player to the campus of your choice.");
jbInstructs1.setBounds(new Rectangle(50, 120, 500, 40));
jbInstructs1.setRolloverEnabled(false);
jbInstructs1.setFocusPainted(false);
add(jbInstructs1);
jbInstructs2 = new JButton("2. Each campus will contain a quiz or puzzle.");
jbInstructs2.setBounds(new Rectangle(50, 170, 500, 40));
jbInstructs2.setRolloverEnabled(false);
jbInstructs2.setFocusPainted(false);
add(jbInstructs2);
jbInstructs3 = new JButton("3. Solve the puzzle to conquer the campus.");
jbInstructs3.setBounds(new Rectangle(50, 220, 500, 40));
jbInstructs3.setRolloverEnabled(false);
jbInstructs3.setFocusPainted(false);
add(jbInstructs3);
jbInstructs4 = new JButton("4. Continue to the next campus until all have been completed!");
jbInstructs4.setBounds(new Rectangle(50, 270, 500, 40));
jbInstructs4.setRolloverEnabled(false);
jbInstructs4.setFocusPainted(false);
add(jbInstructs4);
jbInstructs5 = new JButton("Return to Menu");
jbInstructs5.setBounds(new Rectangle(50, 340, 150, 40));
add(jbInstructs5);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");
g.drawImage(myImage, 0, 0, this);
}
}
import java.awt.*;
import javax.swing.*;
public class JPanelDevelopers extends JPanel {
JButton jbDev1, jbDev2, jbDev3, jbDev4, jbDev5;
public JPanelDevelopers() {
super();
setLayout(null);
jbDev1 = new JButton("Allison Morrow");
jbDev1.setBounds(new Rectangle(220, 90, 200, 40));
jbDev1.setRolloverEnabled(false);
jbDev1.setFocusPainted(false);
add(jbDev1);
jbDev2 = new JButton("Thomas O'Mara");
jbDev2.setBounds(new Rectangle(220, 150, 200, 40));
jbDev2.setRolloverEnabled(false);
jbDev2.setFocusPainted(false);
add(jbDev2);
jbDev3 = new JButton("Kaija Rose");
jbDev3.setBounds(new Rectangle(220, 210, 200, 40));
jbDev3.setRolloverEnabled(false);
jbDev3.setFocusPainted(false);
add(jbDev3);
jbDev4 = new JButton("Saima Sultana");
jbDev4.setBounds(new Rectangle(220, 270, 200, 40));
jbDev4.setRolloverEnabled(false);
jbDev4.setFocusPainted(false);
add(jbDev4);
jbDev5 = new JButton("Return to Menu");
jbDev5.setBounds(new Rectangle(50, 340, 150, 40));
add(jbDev5);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");
g.drawImage(myImage, 0, 0, this);
}
}
import java.awt.*;
import javax.swing.*;
public class JPanelThemeSelection extends JPanel {
JButton jbTS1, jbTS2, jbTS3;
JLabel jlTheme;
ImageIcon imageProgramming, imageFootball, imageMath;
public JPanelThemeSelection() {
super();
setLayout(null);
jlTheme = new JLabel("Select your Theme:");
jlTheme.setBounds(new Rectangle(265, 15, 220, 20));
add(jlTheme);
imageProgramming = new ImageIcon("images/programming.png");
jbTS1 = new JButton(" Programming");
jbTS1.setBounds(new Rectangle(210, 50, 220, 100));
jbTS1.setIcon(imageProgramming);
add(jbTS1);
imageFootball = new ImageIcon("images/football.png");
jbTS2 = new JButton(" Football ");
jbTS2.setBounds(new Rectangle(210, 180, 220, 100));
jbTS2.setIcon(imageFootball);
add(jbTS2);
imageMath = new ImageIcon("images/pi.png");
jbTS3 = new JButton(" Math ");
jbTS3.setBounds(new Rectangle(210, 310, 220, 100));
jbTS3.setIcon(imageMath);
add(jbTS3);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");
g.drawImage(myImage, 0, 0, this);
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JPanelCampus extends JPanel implements KeyListener {
JButton jbUniversityPark, jbWorldCampus, jbBrandywine, jbFayett, jbErie, jbWorthingtonScranton, jbPlayer;
JLabel jlUniversityPark, jlWorldCampus, jlBrandywine, jlFayett, jlErie, jlWorthingtonScranton;
ImageIcon imageCampusIcon, imageWorldCampus, imagePlayerProgramming, imagePlayerFootball, imagePlayerMath;
int playerX, playerY;
String theme;
public JPanelCampus(String infTheme) {
super();
setLayout(null);
setFocusable(true);
addKeyListener(this);
theme = infTheme;
imageCampusIcon = new ImageIcon("images/campusIcon.png");
imageWorldCampus = new ImageIcon("images/worldCampus.png");
jbUniversityPark = new JButton();
jbUniversityPark.setBounds(new Rectangle(270, 200, 75, 50));
jbUniversityPark.setBorderPainted(false);
jbUniversityPark.setContentAreaFilled(false);
jbUniversityPark.setIcon(imageCampusIcon);
jlUniversityPark = new JLabel("University Park");
jlUniversityPark.setBounds(new Rectangle(265, 250, 100, 20));
add(jbUniversityPark);
add(jlUniversityPark);
jbWorldCampus = new JButton();
jbWorldCampus.setBounds(new Rectangle(290, 40, 75, 50));
jbWorldCampus.setBorderPainted(false);
jbWorldCampus.setContentAreaFilled(false);
jbWorldCampus.setIcon(imageWorldCampus);
jlWorldCampus = new JLabel("World Campus");
jlWorldCampus.setBounds(new Rectangle(285, 90, 100, 20));
add(jbWorldCampus);
add(jlWorldCampus);
jbBrandywine = new JButton();
jbBrandywine.setBounds(new Rectangle(500, 360, 75, 50));
jbBrandywine.setBorderPainted(false);
jbBrandywine.setContentAreaFilled(false);
jbBrandywine.setIcon(imageCampusIcon);
jlBrandywine = new JLabel("Brandywine");
jlBrandywine.setBounds(new Rectangle(430, 375, 100, 20));
add(jbBrandywine);
add(jlBrandywine);
jbFayett = new JButton();
jbFayett.setBounds(new Rectangle(50, 350, 75, 50));
jbFayett.setBorderPainted(false);
jbFayett.setContentAreaFilled(false);
jbFayett.setIcon(imageCampusIcon);
jlFayett = new JLabel("Fayett");
jlFayett.setBounds(new Rectangle(125, 365, 100, 20));
add(jbFayett);
add(jlFayett);
jbErie = new JButton();
jbErie.setBounds(new Rectangle(20, 30, 75, 50));
jbErie.setBorderPainted(false);
jbErie.setContentAreaFilled(false);
jbErie.setIcon(imageCampusIcon);
jlErie = new JLabel("Erie");
jlErie.setBounds(new Rectangle(45, 80, 100, 20));
add(jbErie);
add(jlErie);
jbWorthingtonScranton = new JButton();
jbWorthingtonScranton.setBounds(new Rectangle(490, 135, 75, 50));
jbWorthingtonScranton.setBorderPainted(false);
jbWorthingtonScranton.setContentAreaFilled(false);
jbWorthingtonScranton.setIcon(imageCampusIcon);
jlWorthingtonScranton = new JLabel("Worthington Scranton");
jlWorthingtonScranton.setBounds(new Rectangle(465, 185, 150, 20));
add(jbWorthingtonScranton);
add(jlWorthingtonScranton);
playerX = 280;
playerY = 320;
imagePlayerProgramming = new ImageIcon("images/playerProgramming.png");
imagePlayerFootball = new ImageIcon("images/playerFootball.png");
imagePlayerMath = new ImageIcon("images/playerMath.png");
jbPlayer = new JButton();
jbPlayer.setBorderPainted(false);
jbPlayer.setContentAreaFilled(false);
jbPlayer.setRolloverEnabled(false);
jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));
if (theme.equals("programming")) {
jbPlayer.setIcon(imagePlayerProgramming);
add(jbPlayer);
validate();
repaint();
}
if (theme.equals("football")) {
jbPlayer.setIcon(imagePlayerFootball);
add(jbPlayer);
validate();
repaint();
}
if (theme.equals("math")) {
jbPlayer.setIcon(imagePlayerMath);
add(jbPlayer);
validate();
repaint();
}
}
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT) {
if (playerX > 0) {
playerX = playerX - 2;
jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));
}
}
if (key == KeyEvent.VK_RIGHT) {
if (playerX < 574) {
playerX = playerX + 2;
jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));
}
}
if (key == KeyEvent.VK_UP) {
if (playerY > 0) {
playerY = playerY - 2;
jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));
}
}
if (key == KeyEvent.VK_DOWN) {
if (playerY < 395) {
playerY = playerY + 2;
jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));
}
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
requestFocusInWindow();
Image myImage = Toolkit.getDefaultToolkit().getImage("images/campusMap.png");
g.drawImage(myImage, 0, 0, this);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started