Question: I need help with this , running it does not show the animation, i created two Rect classes , Sprite class and Animation class. import
I need help with this running it does not show the animation, i created two Rect classes Sprite class and Animation class.
import java.applet.Applet;
import java.awt.;
import java.awt.event.;
public class GameDriver extends Applet implements Runnable, KeyListener, MouseListener, MouseMotionListener
int mx ;
int my ;
Image beast Toolkit.getDefaultToolkitgetImagebeastlandspng;
Animation animation new AnimationGJump", ;
Rect good new Rect;
Rect bad new Rect;
Rect wall
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
new Rect
;
boolean JumpPressed false;
boolean AttackPressed false;
boolean RunPressed false;
boolean WalkPressed false;
Image offScreenImg;
Graphics offScreenPen;
String pose Dead "Jump", "JaumpAttack", "Run", "Idle", "Walk", "Attack";
Sprites soldier new SpritesG pose, ;
public void run
Game Loop
whiletrue
ifLTPressed good.moveLT;
ifRTPressed good.moveRT;
ifUPPressed good.moveUP;
ifDNPressed good.moveDN;
badchasegood;
forint i ; i wall.length; i
ifgoodoverlapswalli good.pushedOutOfwalli;
if bad.overlapswalli bad.pushedOutOfwalli;
leftwallmoveBy;
repaint;
try
Thread.sleep;
catchException x;
public void updateGraphics pen
pen.clearRect;
paintpen;
public void paintGraphics pen
pen.setColorColorBLACK;
double scale ;
pen.drawImagebeast null;
pendrawImageanimationnextImage null;
soldier.drawpen;
gooddrawpen;
baddrawpen;
forint i ; i wall.length; i
wallidrawpen;
public void init
addKeyListenerthis;
requestFocus;
addMouseListenerthis;
addMouseMotionListenerthis;
Thread t new Threadthis;
tstart;
public void mouseMovedMouseEvent e
public void mouseDraggedMouseEvent e
int nx egetX;
int ny egetY;
int dx nx mx;
int dy ny my;
forint i ; i wall.length; i
ifwalliresizer.held walliresizeBydx dy;
else
ifwalliheld wallimoveBydx dy;
mx nx;
my ny;
public void mousePressedMouseEvent e
mx egetX;
my egetY;
forint i ; i wall.length; i
ifwallicontainsmx my walligrabbed;
ifwalliresizer.containsmx my walliresizer.grabbed;
public void mouseReleasedMouseEvent e
forint i ; i wall.length; i
wallidropped;
walliresizer.dropped;
public void keyPressedKeyEvent e
int code egetKeyCode;
if code eVKUP JumpPressed true;
if code eVKDOWN AttackPressed true;
if code eVKLEFT RunPressed true;
if code eVKRIGHT WalkPressed true;
if code eVKP
forint i ; i wall.length; i
System.out.printlnwalli;
public void keyReleasedKeyEvent e
int code egetKeyCode;
if code eVKUP JumpPressed false;
if code eVKDOWN AttackPressed false;
if code eVKLEFT RunPressed false;
if code eVKRIGHT WalkPressed false;
public void keyTypedKeyEvent e
public void mouseClickedMouseEvent e
public void mouseEnteredMouseEvent e
public void mouseExitedMouseEvent e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
