one NPC locomotion

Signed-off-by: officereso <qrs01@snowtx.com>
This commit is contained in:
officereso 2019-05-24 18:52:25 -05:00
parent a96a7dec98
commit bcbd0c6ba9
2 changed files with 26 additions and 17 deletions

View File

@ -12,7 +12,8 @@ public class Main extends Applet {
private Rectangle lBtn = new Rectangle(480,220,120,80);
private Rectangle rBtn = new Rectangle(630,220,120,80);
private static int Px = 150;
private static boolean spwNpc1, spwNpc2 = true;
private static NPC npc1 = new NPC();
public void paint(Graphics g){
Expo.drawHeading(g, "Quentin Snow and Alekkai", "Final Project");
@ -36,15 +37,8 @@ public class Main extends Applet {
}
}
public static void npcLocomotion(Graphics g){
if (spwNpc1){
NPC npc1 = new NPC(g);
spwNpc1 = false;
}
if (spwNpc2){
NPC npc2 = new NPC(g);
spwNpc2 = false;
}
public static void npcLocomotion(Graphics g) {
NPC.make(g);
}

View File

@ -6,17 +6,32 @@ import java.applet.Applet;
import java.awt.*;
public class NPC extends Applet {
public NPC(Graphics g) {
int x = Expo.random(100, 400);
private static int x = Expo.random(100, 400);
private static int y = 100;
private static int speed = Expo.random(10, 20);
public NPC(/*Graphics g, int x, int y*/) {
// Expo.setColor(g, SpriteColors.NPC1Body);
// Expo.fillRectangle(g, x, y + 110, x + 35, y + 170);
// Expo.setColor(g, SpriteColors.Tires);
// Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
// Expo.fillRectangle(g, x + 5, y + 145, x - 5, y + 165);
// Expo.fillRectangle(g, x + 30, y + 118, x + 40, y + 138);
// Expo.fillRectangle(g, x + 30, y + 145, x + 40, y + 165);
}
public static void make(Graphics g/*, int x, int y*/) {
y += speed;
Expo.setColor(g, SpriteColors.NPC1Body);
Expo.fillRectangle(g, x, 110, x + 35, 170);
Expo.fillRectangle(g, x, y + 110, x + 35, y + 170);
Expo.setColor(g, SpriteColors.Tires);
Expo.fillRectangle(g, x + 5, 118, x - 5, 138);
Expo.fillRectangle(g, x + 5, 145, x - 5, 165);
Expo.fillRectangle(g, x + 30, 118, x + 40, 138);
Expo.fillRectangle(g, x + 30, 145, x + 40, 165);
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
Expo.fillRectangle(g, x + 5, y + 145, x - 5, y + 165);
Expo.fillRectangle(g, x + 30, y + 118, x + 40, y + 138);
Expo.fillRectangle(g, x + 30, y + 145, x + 40, y + 165);
}
}
/*
public static void make(Graphics g){
int x = Expo.random(100,400);