diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index 7aeaf1c..d73b08a 100644 Binary files a/SMIMS-Game/MyWorld.class and b/SMIMS-Game/MyWorld.class differ diff --git a/SMIMS-Game/MyWorld.java b/SMIMS-Game/MyWorld.java index 3047bc1..04592df 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -31,6 +31,8 @@ public class MyWorld extends World { Player player = new Player(); addObject(player,302,320); + Score score = new Score(); + addObject(score, 200, 50); } public void act() diff --git a/SMIMS-Game/Player.class b/SMIMS-Game/Player.class index 5090825..17d46e2 100644 Binary files a/SMIMS-Game/Player.class and b/SMIMS-Game/Player.class differ diff --git a/SMIMS-Game/Player.java b/SMIMS-Game/Player.java index 2abc718..8f3d948 100644 --- a/SMIMS-Game/Player.java +++ b/SMIMS-Game/Player.java @@ -64,7 +64,7 @@ public class Player extends Actor setLocation(getX(), newY); - Actor ground = getOneIntersectingObject(Ground.class); + Actor ground = getOneIntersectingObject(Plattform.class); if (ground != null && verticalSpeed >= 0) { diff --git a/SMIMS-Game/Score.class b/SMIMS-Game/Score.class new file mode 100644 index 0000000..2d6ec6b Binary files /dev/null and b/SMIMS-Game/Score.class differ diff --git a/SMIMS-Game/Score.ctxt b/SMIMS-Game/Score.ctxt new file mode 100644 index 0000000..79e8783 --- /dev/null +++ b/SMIMS-Game/Score.ctxt @@ -0,0 +1,11 @@ +#BlueJ class context +comment0.target=Score +comment0.text=\r\n\ Write\ a\ description\ of\ class\ UI\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params= +comment1.target=void\ act() +comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ UI\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n +comment2.params= +comment2.target=void\ draw_score() +comment3.params= +comment3.target=int\ calculate_score() +numComments=4 diff --git a/SMIMS-Game/Score.java b/SMIMS-Game/Score.java new file mode 100644 index 0000000..bec09ba --- /dev/null +++ b/SMIMS-Game/Score.java @@ -0,0 +1,29 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class UI here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Score extends Actor +{ + int timer; + /** + * Act - do whatever the UI wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + timer++; + draw_score(); + } + + public void draw_score(){ + setImage(new GreenfootImage("Score:" + calculate_score(), 24, Color.WHITE, Color.BLACK)); + } + + public int calculate_score(){ + return timer/60; + } +}