Merge remote-tracking branch 'origin/main'
# Conflicts: # SMIMS-Game/MyWorld.class
This commit is contained in:
Binary file not shown.
@@ -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()
|
||||
|
||||
Binary file not shown.
@@ -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)
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user