Kind of new to teh greenfoot scene and have found myself quite teh predicament.
I am trying to move a score through one class (called ship_1, dont question teh '1') to its subclass (Score).
The idea is that as the ship gets more points the score will change the number of score until when it gets to 10, there will be a winning screen (or loosing if u hit the edge of the world) So this is kind of needed.
This is the Ship of course
And this is the Score
Problem revolves around the fact that as the Ship class gets points the Score class does not, I've been told by a friend they know what I need but they haven't gotten in touch yet and thought id put this out there in case you guys have a better idea... Any ideas?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | public class ship_1 extends Mover { //gives the word 'Score' meaning int Score = 0 ; /** * This will remove Enemy if the player connects to one * We will add to a score board to allow for a game */ public void absorb() { if (isTouching(Enemy. class )) { removeTouching(Enemy. class ); Score = Score + 1 ; } } //this code alows for us to check the score when testing public int displayScore() { return Score; } public void wall() { if ( isAtEdge () ) { getWorld().removeObject( this ); } } public void act() { Control_1(); absorb(); wall(); } } |
1 2 3 4 5 6 7 8 9 10 11 | public class Score extends ship_1 { /** * If the score of teh ship rises, then this class will change image */ public void act() { int score = displayScore(); setImage( new GreenfootImage(score + ".png" )); } } |