From ce7d8c113e88644b420eef91f8cfbdbecfb868b3 Mon Sep 17 00:00:00 2001 From: Adrian400811 Date: Wed, 12 Jun 2024 22:04:59 -0400 Subject: [PATCH] Finished Level 0 --- Brick.java | 18 ++++++---- FloorHole.java | 19 +++++++++++ JumpBooster.java | 0 Level.java | 7 ++-- LoadSettings.java | 0 Mobs.java | 12 +++++-- Spider.java | 10 ++++-- doc/Bee.html | 0 doc/BlueBee.html | 0 doc/Brick.html | 0 doc/Button.html | 0 doc/Coin.html | 0 doc/Collection.html | 0 doc/Crown.html | 0 doc/EndScreen.html | 0 doc/GameOverScreen.html | 0 doc/GreenBee.html | 0 doc/ImgScroll.html | 0 doc/Level.html | 0 doc/Level0.html | 0 doc/Level1.html | 0 doc/Mites.html | 0 doc/Mobs.html | 0 doc/Orb.html | 0 doc/RedBee.html | 0 doc/Spider.html | 0 doc/SuperDisplayLabel.html | 0 doc/SuperSmoothMover.html | 0 doc/Tile.html | 0 doc/TitleScreen.html | 0 doc/allclasses-index.html | 0 doc/allpackages-index.html | 0 doc/help-doc.html | 0 doc/index-all.html | 0 doc/jquery-ui.overrides.css | 0 doc/member-search-index.js | 0 doc/module-search-index.js | 0 doc/overview-tree.html | 0 doc/package-search-index.js | 0 doc/package-tree.html | 0 doc/resources/glass.png | Bin doc/resources/x.png | Bin doc/script-dir/jquery-3.6.1.min.js | 0 doc/script-dir/jquery-ui.min.css | 0 doc/script-dir/jquery-ui.min.js | 0 doc/search.js | 0 doc/stylesheet.css | 0 doc/tag-search-index.js | 0 doc/type-search-index.js | 0 images/saveButtonImage.png | Bin images/saveFile1.png | Bin images/saveFile2.png | Bin levels/0.csv | 51 ++++++++++++++++++++++++++++- levels/1.csv | 0 54 files changed, 99 insertions(+), 18 deletions(-) create mode 100755 FloorHole.java mode change 100644 => 100755 JumpBooster.java mode change 100644 => 100755 LoadSettings.java mode change 100644 => 100755 doc/Bee.html mode change 100644 => 100755 doc/BlueBee.html mode change 100644 => 100755 doc/Brick.html mode change 100644 => 100755 doc/Button.html mode change 100644 => 100755 doc/Coin.html mode change 100644 => 100755 doc/Collection.html mode change 100644 => 100755 doc/Crown.html mode change 100644 => 100755 doc/EndScreen.html mode change 100644 => 100755 doc/GameOverScreen.html mode change 100644 => 100755 doc/GreenBee.html mode change 100644 => 100755 doc/ImgScroll.html mode change 100644 => 100755 doc/Level.html mode change 100644 => 100755 doc/Level0.html mode change 100644 => 100755 doc/Level1.html mode change 100644 => 100755 doc/Mites.html mode change 100644 => 100755 doc/Mobs.html mode change 100644 => 100755 doc/Orb.html mode change 100644 => 100755 doc/RedBee.html mode change 100644 => 100755 doc/Spider.html mode change 100644 => 100755 doc/SuperDisplayLabel.html mode change 100644 => 100755 doc/SuperSmoothMover.html mode change 100644 => 100755 doc/Tile.html mode change 100644 => 100755 doc/TitleScreen.html mode change 100644 => 100755 doc/allclasses-index.html mode change 100644 => 100755 doc/allpackages-index.html mode change 100644 => 100755 doc/help-doc.html mode change 100644 => 100755 doc/index-all.html mode change 100644 => 100755 doc/jquery-ui.overrides.css mode change 100644 => 100755 doc/member-search-index.js mode change 100644 => 100755 doc/module-search-index.js mode change 100644 => 100755 doc/overview-tree.html mode change 100644 => 100755 doc/package-search-index.js mode change 100644 => 100755 doc/package-tree.html mode change 100644 => 100755 doc/resources/glass.png mode change 100644 => 100755 doc/resources/x.png mode change 100644 => 100755 doc/script-dir/jquery-3.6.1.min.js mode change 100644 => 100755 doc/script-dir/jquery-ui.min.css mode change 100644 => 100755 doc/script-dir/jquery-ui.min.js mode change 100644 => 100755 doc/search.js mode change 100644 => 100755 doc/stylesheet.css mode change 100644 => 100755 doc/tag-search-index.js mode change 100644 => 100755 doc/type-search-index.js mode change 100644 => 100755 images/saveButtonImage.png mode change 100644 => 100755 images/saveFile1.png mode change 100644 => 100755 images/saveFile2.png mode change 100644 => 100755 levels/1.csv diff --git a/Brick.java b/Brick.java index e81aad3..9f2c757 100755 --- a/Brick.java +++ b/Brick.java @@ -1,18 +1,22 @@ -import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) +import greenfoot.GreenfootImage; /** * Write a description of class Block here. - * - * @author (your name) + * + * @author (your name) * @version (a version number or a date) */ -public class Brick extends Tile -{ +public class Brick extends Tile { + public Brick() { + GreenfootImage image = new GreenfootImage("brick.jpg"); + image.scale(64, 64); + setImage(image); + } + /** * Act - do whatever the Block wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ - public void act() - { + public void act() { } } diff --git a/FloorHole.java b/FloorHole.java new file mode 100755 index 0000000..f618802 --- /dev/null +++ b/FloorHole.java @@ -0,0 +1,19 @@ +import greenfoot.Actor; +import greenfoot.GreenfootImage; +import greenfoot.World; + +import java.util.List; + +public class FloorHole extends Actor { + public FloorHole() { + GreenfootImage image = new GreenfootImage(1, 1); + setImage(image); + } + + public void addedToWorld(World w) { + List brick = getObjectsInRange(32, Brick.class); + for (Brick b : brick) { + w.removeObject(b); + } + } +} diff --git a/JumpBooster.java b/JumpBooster.java old mode 100644 new mode 100755 diff --git a/Level.java b/Level.java index 0a92add..572582a 100755 --- a/Level.java +++ b/Level.java @@ -40,10 +40,8 @@ public static void addCrown() { } public void spawnFloor(ImgScroll sc) { - for (int j = 0; j < sc.getScrollHeight() - 100; j += 300) { - for (int i = 0; i < sc.getScrollWidth() + 64; i += 63) { - addObject(new Brick(), i, 700); - } + for (int i = 0; i < sc.getScrollWidth() + 64; i += 64) { + addObject(new Brick(), i, 700); } } @@ -119,6 +117,7 @@ public void spawnTerrain(int[][] identifier) { case 8 -> new Spider(); case 9 -> new Crown(); case 10 -> new JumpBooster(); + case 11 -> new FloorHole(); default -> null; }; if (a != null) { diff --git a/LoadSettings.java b/LoadSettings.java old mode 100644 new mode 100755 diff --git a/Mobs.java b/Mobs.java index 040a648..bb3eb24 100755 --- a/Mobs.java +++ b/Mobs.java @@ -17,7 +17,8 @@ public Mobs() { public void addedToWorld(World w) { this.w = w; } - public void act(){ + + public void act() { stepped(); } @@ -110,11 +111,16 @@ public Player getPlayer(int range) { } return null; } - public void stepped(){ - if(getOneObjectAtOffset(getX(), -(getImage().getHeight()/2), Player.class)!=null){ + + public void stepped() { + if (getWorld() == null) { + return; + } + if (getOneObjectAtOffset(getX(), -(getImage().getHeight() / 2), Player.class) != null) { getWorld().removeObject(this); } } + public void attack(int dmg) { Player p = (Player) getOneIntersectingObject(Player.class); if (p == null) { diff --git a/Spider.java b/Spider.java index 9c3108b..d66d5a4 100755 --- a/Spider.java +++ b/Spider.java @@ -27,7 +27,7 @@ public void addedToWorld(World w) { } public void act() { - if (checkBlock()) { + if (checkBlock() || checkY()) { holdAct--; hold(); } else { @@ -61,15 +61,19 @@ private boolean checkBlock() { return getOneIntersectingObject(Tile.class) != null; } + private boolean checkY() { + return (getY() < 0 || getY() > w.getHeight()); + } + public void timeout() { if (w == null) { return; } - if (!oob && (getX() < 0 || getX() > w.getWidth() || getY() < 0 || getY() > w.getHeight())) { + if (!oob && (getX() < 0)) { oob = true; startTime = System.currentTimeMillis(); } - if (oob && !(getX() < 0 || getX() > w.getWidth() || getY() < 0 || getY() > w.getHeight())) { + if (oob && !(getX() < 0)) { oob = false; } if (oob) { diff --git a/doc/Bee.html b/doc/Bee.html old mode 100644 new mode 100755 diff --git a/doc/BlueBee.html b/doc/BlueBee.html old mode 100644 new mode 100755 diff --git a/doc/Brick.html b/doc/Brick.html old mode 100644 new mode 100755 diff --git a/doc/Button.html b/doc/Button.html old mode 100644 new mode 100755 diff --git a/doc/Coin.html b/doc/Coin.html old mode 100644 new mode 100755 diff --git a/doc/Collection.html b/doc/Collection.html old mode 100644 new mode 100755 diff --git a/doc/Crown.html b/doc/Crown.html old mode 100644 new mode 100755 diff --git a/doc/EndScreen.html b/doc/EndScreen.html old mode 100644 new mode 100755 diff --git a/doc/GameOverScreen.html b/doc/GameOverScreen.html old mode 100644 new mode 100755 diff --git a/doc/GreenBee.html b/doc/GreenBee.html old mode 100644 new mode 100755 diff --git a/doc/ImgScroll.html b/doc/ImgScroll.html old mode 100644 new mode 100755 diff --git a/doc/Level.html b/doc/Level.html old mode 100644 new mode 100755 diff --git a/doc/Level0.html b/doc/Level0.html old mode 100644 new mode 100755 diff --git a/doc/Level1.html b/doc/Level1.html old mode 100644 new mode 100755 diff --git a/doc/Mites.html b/doc/Mites.html old mode 100644 new mode 100755 diff --git a/doc/Mobs.html b/doc/Mobs.html old mode 100644 new mode 100755 diff --git a/doc/Orb.html b/doc/Orb.html old mode 100644 new mode 100755 diff --git a/doc/RedBee.html b/doc/RedBee.html old mode 100644 new mode 100755 diff --git a/doc/Spider.html b/doc/Spider.html old mode 100644 new mode 100755 diff --git a/doc/SuperDisplayLabel.html b/doc/SuperDisplayLabel.html old mode 100644 new mode 100755 diff --git a/doc/SuperSmoothMover.html b/doc/SuperSmoothMover.html old mode 100644 new mode 100755 diff --git a/doc/Tile.html b/doc/Tile.html old mode 100644 new mode 100755 diff --git a/doc/TitleScreen.html b/doc/TitleScreen.html old mode 100644 new mode 100755 diff --git a/doc/allclasses-index.html b/doc/allclasses-index.html old mode 100644 new mode 100755 diff --git a/doc/allpackages-index.html b/doc/allpackages-index.html old mode 100644 new mode 100755 diff --git a/doc/help-doc.html b/doc/help-doc.html old mode 100644 new mode 100755 diff --git a/doc/index-all.html b/doc/index-all.html old mode 100644 new mode 100755 diff --git a/doc/jquery-ui.overrides.css b/doc/jquery-ui.overrides.css old mode 100644 new mode 100755 diff --git a/doc/member-search-index.js b/doc/member-search-index.js old mode 100644 new mode 100755 diff --git a/doc/module-search-index.js b/doc/module-search-index.js old mode 100644 new mode 100755 diff --git a/doc/overview-tree.html b/doc/overview-tree.html old mode 100644 new mode 100755 diff --git a/doc/package-search-index.js b/doc/package-search-index.js old mode 100644 new mode 100755 diff --git a/doc/package-tree.html b/doc/package-tree.html old mode 100644 new mode 100755 diff --git a/doc/resources/glass.png b/doc/resources/glass.png old mode 100644 new mode 100755 diff --git a/doc/resources/x.png b/doc/resources/x.png old mode 100644 new mode 100755 diff --git a/doc/script-dir/jquery-3.6.1.min.js b/doc/script-dir/jquery-3.6.1.min.js old mode 100644 new mode 100755 diff --git a/doc/script-dir/jquery-ui.min.css b/doc/script-dir/jquery-ui.min.css old mode 100644 new mode 100755 diff --git a/doc/script-dir/jquery-ui.min.js b/doc/script-dir/jquery-ui.min.js old mode 100644 new mode 100755 diff --git a/doc/search.js b/doc/search.js old mode 100644 new mode 100755 diff --git a/doc/stylesheet.css b/doc/stylesheet.css old mode 100644 new mode 100755 diff --git a/doc/tag-search-index.js b/doc/tag-search-index.js old mode 100644 new mode 100755 diff --git a/doc/type-search-index.js b/doc/type-search-index.js old mode 100644 new mode 100755 diff --git a/images/saveButtonImage.png b/images/saveButtonImage.png old mode 100644 new mode 100755 diff --git a/images/saveFile1.png b/images/saveFile1.png old mode 100644 new mode 100755 diff --git a/images/saveFile2.png b/images/saveFile2.png old mode 100644 new mode 100755 diff --git a/levels/0.csv b/levels/0.csv index 4ca1dad..233552f 100755 --- a/levels/0.csv +++ b/levels/0.csv @@ -124,4 +124,53 @@ 59,4,1 59,3,1 59,2,1 -60,10,2 \ No newline at end of file +70,11,11 +70,1,1 +70,9,8 +71,11,11 +71,1,1 +71,4,8 +72,11,11 +72,2,1 +72,5,8 +73,10,1 +74,10,1 +75,10,1 +76,10,1 +77,10,1 +78,10,1 +79,11,11 +80,11,11 +80,1,1 +80,2,8 +81,11,11 +82,11,11 +82,1,1 +82,3,8 +83,10,1 +84,10,1 +84,9,1 +85,10,1 +85,9,1 +85,8,1 +86,10,1 +86,9,1 +86,8,1 +86,7,1 +90,8,3 +90,9,3 +91,7,3 +91,8,3 +91,9,3 +91,10,3 +92,7,3 +92,8,3 +92,9,3 +92,10,3 +93,7,3 +93,8,3 +93,9,3 +93,10,3 +94,8,3 +94,9,3 +100,10,2 \ No newline at end of file diff --git a/levels/1.csv b/levels/1.csv old mode 100644 new mode 100755