Question
I need to create a sprite that moves from the left to the right of the screen, using only two queues. The requirements for this
I need to create a sprite that moves from the left to the right of the screen, using only two queues.
The requirements for this assignment are to:
- Load your custom sprite (128 x 128) into the game engine using Art.txt
- Make your sprite appear when running the program
- Write the Vector2D class using the template
- Load your frames into the first Queue
- Using a timer, two Vector2D queues, and your custom engine, make the image move from the left side of the screen to the right. Once the image reaches the end of the animation, it should reset by transferring the second Queue back to the first.
Does this look good so far?
Main.java
--------------------
package Main;
import java.awt.Color; import java.util.LinkedList; import java.util.Queue; import Data.Vector2D; import logic.Control; import timer.stopWatchX;
public class Main{ // Fields (Static) below... public static Color c = new Color(0,128,0); public static boolean isImageDrawn = false; public static stopWatchX timer = new stopWatchX(250); public static Queue
Vector2D.java ----------------------------------
/* This class is used to give you a handy way to pass a pair of 2D coordinates as a single object. The behavior (methods) of the class should allow for robust options in the future. */
package Data;
public class Vector2D { // Fields // TODO: Add private class fields to store x and y values given in class constructor private int x; private int y; // Constructor public Vector2D(int x, int y){ // TODO: Save the constructor parameters into class fields this.x = x; this.y = y; } // Methods public int getX(){ // TODO: Remove my placeholder code below (which is there to prevent an error) and replace it with returning the value of your private field x return x; } public int getY(){ // TODO: Remove my placeholder code below (which is there to prevent an error) and replace it with returning the value of your private field y return y; } public void setX(int newX){ // TODO: Update the value of x to be the value in newX (Absolute assignment) this.x = newX; } public void setY(int newY){ // TODO: Update the value of y to be the value in newY (Absolute assignment) this.y = newY; } public void adjustX(int adjustment){ // TODO: Change the previous value of x by adding the adjustment to the previous value (Relative assignment) // Backward adjustments can be made by passing a negative number as an adjustment this.x+=adjustment; } public void adjustY(int adjustment){ // TODO: Change the previous value of y by adding the adjustment to the previous value (Relative assignment) // Backward adjustments can be made by passing a negative number as an adjustment this.y+=adjustment; } }
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