diff --git a/src/project/Colors.java b/src/project/Colors.java index debe8ef..516a7a6 100644 --- a/src/project/Colors.java +++ b/src/project/Colors.java @@ -10,4 +10,7 @@ public class Colors { static final Color startBlue = new Color(112, 113, 255); static final Color red = new Color(255, 6, 0); static final Color endGreen = new Color(150, 255, 0); + static final Color playerBody = new Color(247, 17, 17); + static final Color Tires = new Color(0, 0, 0); + static final Color NPC1Body = new Color(0, 247, 0); } diff --git a/src/project/Draw.java b/src/project/Draw.java index 7eefc94..285dc17 100644 --- a/src/project/Draw.java +++ b/src/project/Draw.java @@ -13,24 +13,27 @@ public class Draw extends Applet { } } - public static void begin(Graphics g){ + public static void begin(Graphics g, int score) { road(g); - LRbtn(g); - //project.Sprites.NPC.NPC(g,Expo.random(110,390)); + btns(g); + Expo.setFont(g, "Default", 1, 15); + Expo.drawString(g, "Your score is " + score, 600, 100); } public static void end(Graphics g){ Expo.setBackground(g,Colors.red); Expo.setColor(g,Colors.endGreen); + Expo.setFont(g, "Default", 1, 100); Expo.drawString(g,"YOU DIED",100,100); } - public static void LRbtn(Graphics g){ + public static void btns(Graphics g) { Expo.setFont(g,"Default",1,100); Expo.setColor(g,Colors.startBlue); Expo.drawString(g,"<=",480,300); - Expo.drawString(g,"=>",620,300); + Expo.fillCircle(g, 650, 271, 20); + Expo.drawString(g, "=>", 660, 300); } diff --git a/src/project/Main.java b/src/project/Main.java index e1f387d..e4effa8 100644 --- a/src/project/Main.java +++ b/src/project/Main.java @@ -1,6 +1,6 @@ package project; -import project.Sprites.NPC; +import project.Sprites.*; import java.applet.Applet; import java.awt.*; @@ -9,38 +9,57 @@ import java.awt.*; public class Main extends Applet { private static boolean start = false; private Rectangle startBtn = new Rectangle(100,100,340,600); - private Rectangle lBtn = new Rectangle(480,220,120,80); - private Rectangle rBtn = new Rectangle(630,220,120,80); + public static int score = 0; + private Rectangle lBtn = new Rectangle(480, 240, 150, 80); private static int Px = 150; - private static NPC npc1 = new NPC(); - - - public void paint(Graphics g){ - Expo.drawHeading(g, "Quentin Snow and Alekkai", "Final Project"); - if (start){ - Draw.begin(g); - playerLocomotion(g); - npcLocomotion(g); + private Rectangle rBtn = new Rectangle(660, 240, 150, 80); + public static void npcLocomotion(Graphics g) { + if (score > 3) { + new NPC1(g, Px); } - else{ - Draw.startScreen(g); + if (score > 30) { + new NPC2(g, Px); + } + if (score > 35) { + new NPC3(g, Px); + } + if (score > 50) { + new NPC4(g, Px); + } + if (score > 70) { + new NPC5(g, Px); + } + if (score > 80) { + new NPC6(g, Px); } } - public static void playerLocomotion(Graphics g){ - project.Sprites.player.make(g,Px,427); - if (Px <= 107|| Px >= 375){ + public static void playerLocomotion(Graphics g) { + project.Sprites.player.make(g, Px, 427); + if (Px <= 107 || Px >= 375) { Draw.end(g); Px = 10000; } } - public static void npcLocomotion(Graphics g) { - NPC.make(g); - } + public void paint(Graphics g) { + Expo.drawHeading(g, "Quentin Snow and Alekkai", "Final Project"); + if (start && !NPC1.ended && !NPC2.ended && !NPC3.ended && !NPC4.ended && !NPC5.ended && !NPC6.ended) { + Draw.begin(g, score); + playerLocomotion(g); + npcLocomotion(g); + } + if (!start) { + Draw.startScreen(g); + } + + if (NPC1.ended || NPC2.ended || NPC3.ended || NPC4.ended || NPC5.ended || NPC6.ended) { + Draw.end(g); + } + } public boolean mouseDown(Event e, int x, int y){ if (startBtn.inside(x,y)){ @@ -52,8 +71,9 @@ public class Main extends Applet { if (rBtn.inside(x,y)){ Px+=10; } + score++; + System.out.println(score); repaint(); - System.out.println(x+" "+y); return true; } } diff --git a/src/project/Sprites/NPC.java b/src/project/Sprites/NPC.java deleted file mode 100644 index f9007be..0000000 --- a/src/project/Sprites/NPC.java +++ /dev/null @@ -1,47 +0,0 @@ -package project.Sprites; - -import project.Expo; - -import java.applet.Applet; -import java.awt.*; - -public class NPC extends Applet { - 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, 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 = Expo.random(100,400); - Expo.setColor(g,SpriteColors.NPC1Body); - Expo.fillRectangle(g, x, 110, x+35, 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); - - } -}*/ diff --git a/src/project/Sprites/NPC1.java b/src/project/Sprites/NPC1.java new file mode 100644 index 0000000..89acf07 --- /dev/null +++ b/src/project/Sprites/NPC1.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC1 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC1(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/ diff --git a/src/project/Sprites/NPC2.java b/src/project/Sprites/NPC2.java new file mode 100644 index 0000000..6c0e952 --- /dev/null +++ b/src/project/Sprites/NPC2.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC2 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC2(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/ diff --git a/src/project/Sprites/NPC3.java b/src/project/Sprites/NPC3.java new file mode 100644 index 0000000..9223bdb --- /dev/null +++ b/src/project/Sprites/NPC3.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC3 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC3(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/ diff --git a/src/project/Sprites/NPC4.java b/src/project/Sprites/NPC4.java new file mode 100644 index 0000000..2884497 --- /dev/null +++ b/src/project/Sprites/NPC4.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC4 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC4(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/ diff --git a/src/project/Sprites/NPC5.java b/src/project/Sprites/NPC5.java new file mode 100644 index 0000000..249a7ee --- /dev/null +++ b/src/project/Sprites/NPC5.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC5 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC5(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/ diff --git a/src/project/Sprites/NPC6.java b/src/project/Sprites/NPC6.java new file mode 100644 index 0000000..0e3b8f2 --- /dev/null +++ b/src/project/Sprites/NPC6.java @@ -0,0 +1,53 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC6 extends Applet { + public static boolean ended = false; + private static int x = Expo.random(100, 400); + private static int y = -15; + private static int speed = Expo.random(10, 40); + + public NPC6(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43) && !ended) { + y += speed; + 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); + } else { + Draw.end(g); + ended = true; + } + if (y > 350) { + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(10, 40); + } + } +} + +/* + public static void make(Graphics g){ + int x = Expo.random(100,400); + Expo.setColor(g,SpriteColors.NPC1Body); + Expo.fillRectangle(g, x, 110, x+35, 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); + + } +}*/