This site requires JavaScript, please enable it in your browser!
Greenfoot back
Xmin_Terminator
Xmin_Terminator wrote ...

2017/4/23

I NEED IMMEDIATE HELP

3
4
5
6
7
8
9
Xmin_Terminator Xmin_Terminator

2017/4/28

#
I came up with an error, really all the rest is adding about 700 more actors at least, probably gonna be nearing 1000
danpost danpost

2017/4/28

#
Xmin_Terminator wrote...
Where do I place line 18 then? and if you really want the whole thing of background here :
From what I just wrote, where do you think it should go?
Xmin_Terminator Xmin_Terminator

2017/4/28

#
Ok I understood it second time, thanks a lot, it is working now, I am near to finishing my game, that's a lot again for the massive help, even though to you I may seem extremely stupid.
Xmin_Terminator Xmin_Terminator

2017/4/28

#
One last question, does greenfoot come up with an error if too many actors are added in the world subclass?
Yehuda Yehuda

2017/4/28

#
Yes, but usually the error doesn't come up with the amount of actors people use. They think it's because of that, but it then turns out to be something else.
Xmin_Terminator Xmin_Terminator

2017/4/28

#
What is the limit? because I will end up using about 1000 and a bit
Yehuda Yehuda

2017/4/30

#
Xmin_Terminator wrote...
What is the limit? because I will end up using about 1000 and a bit
Why don't you just do everything you want to and then see if you get any errors?
Xmin_Terminator Xmin_Terminator

2017/4/30

#
How do I like change the count act cycles to 61, so that it stops counting up, and therefore stop loosing score every second, I want this for when the player finishes the game and so that the players score stays the same and doesn't drain down, that way they can read their score. I have a EndPad so I would like this to happen upon the collision of the EndPad and the Player. And I just wanted to know the limit out of curiosity.
danpost danpost

2017/5/1

#
You could have one range and two different values of interest for the field. A positive value (or range from one to the top value) or one of the two values: zero or negative one. When positive, decrease the value. When zero, lose score and reset to the top value. When negative one (which does not have to be checked for, do nothing:
if (actCounter > 0) actCounter--;
if (actCounter == 0)
{
    loseScore();
    actCounter = 61;
}
With the above code, if the value of 'actCounter' was '-1', there will not be any change in the value of the 'actCounter' field and no points will be taken from the score.
Xmin_Terminator Xmin_Terminator

2017/5/1

#
How do I find if two actors are intersecting in the world class, in the world class
danpost danpost

2017/5/1

#
Xmin_Terminator wrote...
How do I find if two actors are intersecting in the world class, in the world class
There are ways to accomplish that; however, because all collision methods in the Actor class have 'protected' access, you cannot directly use them. Maybe you should explain what you want to do. It may provide a simple way around that.
Xmin_Terminator Xmin_Terminator

2017/5/1

#
Oh sorry don't need help, I think I managed to do it after some trial and error
Xmin_Terminator Xmin_Terminator

2017/5/1

#
Here's what I did :
int stopMoving = 0;
   public void endTheGame()
   {
       Actor EndPad = getOneObjectInFront(EndPad.class);
       if(EndPad != null)
       {
          stopMoving = 1;
       }
   }
   
    public void act()
   {
       movement();
       getPoints();
       endTheGame();
   }
    
    public Player()
   {
        GreenfootImage myImage = getImage();
        int myNewHeight = (int)myImage.getHeight()/3;
        int myNewWidth = (int)myImage.getWidth()/3;
        myImage.scale(myNewWidth, myNewHeight);
    }
   
   public void movement() 
   {
       if(Greenfoot.isKeyDown("right"))
       {
          setRotation(0);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("left"))
       {
          setRotation(180);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("up"))
       {
          setRotation(270);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("down"))
       {
          setRotation(90);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
   }
So If the player hasn't hit the end, it can move, it seems to work. Now I am going on to a game over screen.
Xmin_Terminator Xmin_Terminator

2017/5/1

#
Wait oops I forgot to make the score counter stop, I almost forgot. Still need help on finding Edit: I managed to do this with a Boolean that detected this
Xmin_Terminator Xmin_Terminator

2017/5/1

#
There may be something in my code that may break the game, so could you please check over it to make sure it is ok. PLAYER
public boolean noMove = false;
   public int stopMoving = 0;
   public void endTheGame()
   {
       Actor EndPad = getOneObjectInFront(EndPad.class);
       if(EndPad != null)
       {
          stopMoving = 1;
          noMove = true;
       }
   }
   
    public void act()
   {
       movement();
       getPoints();
       endTheGame();
   }
    
    public Player()
   {
        GreenfootImage myImage = getImage();
        int myNewHeight = (int)myImage.getHeight()/3;
        int myNewWidth = (int)myImage.getWidth()/3;
        myImage.scale(myNewWidth, myNewHeight);
    }
   
   public void movement() 
   {
       if(Greenfoot.isKeyDown("right"))
       {
          setRotation(0);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("left"))
       {
          setRotation(180);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("up"))
       {
          setRotation(270);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
       if(Greenfoot.isKeyDown("down"))
       {
          setRotation(90);
          if(getOneObjectInFront(Wall.class)==null)
          if(getOneObjectInFront(Maze.class)==null)
          if(getOneObjectInFront(LaserWall.class)==null)
          if(stopMoving == 0)
          move(3);
       }
   }
BACKGROUND1
public boolean noMove;
    private int actCycles = -300;
    public void countingCycles() 
    {
        actCycles++;
        if (actCycles == 30)
        {
            getScoreCounter().loseScore();
            actCycles = 0;
        }
        if(noMove = true)
        {
            actCycles = 31;
        }
    }
All I need is that the player can't move once it reaches the end and the score counter stops loosing points when the player reaches the end. the - 300 in the actCycles is to give the player time to go through the instructions. and I changed it to loose score 2 times a second for balancing reasons
There are more replies on the next page.
3
4
5
6
7
8
9