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

2017/2/6

@danpost Score switching worlds...

1
2
3
4
Kokoro Kokoro

2017/2/6

#
I use your Zombie Shooter Demo so i would like to request just help... I look for when a player arrives at the score of 50 or 100 to pass to another world but not with the same "Chased" actor...
danpost danpost

2017/2/6

#
In world act method, add the following line:
if (score > 50 /** or '100' */) Greenfoot.setWorld(/** put new world object here*/);
Kokoro Kokoro

2017/2/6

#
Thanks !! Also any idea how to make an "Chaser" shoot you?
danpost danpost

2017/2/6

#
Kokoro wrote...
Thanks !! Also any idea how to make an "Chaser" shoot you?
The chasers would need to occasionally create bullets that take on their rotation.
Kokoro Kokoro

2017/2/6

#
Nope "cannot find symbol object "Welt_2" not works..
danpost danpost

2017/2/6

#
Kokoro wrote...
Nope "cannot find symbol object "Welt_2" not works..
Try:
ChaserBullet bullet = new ChaserBullet(); // adjust class name as needed
bullet.setRotation(getRotation());
getWorld().addObject(bullet, getX(), getY());
Kokoro Kokoro

2017/2/6

#
I'm lost... like i just want to make it shoot tell me in which class "QActor" or Chaser? Also the world change cannot be done with that score function .. "if (score > 50 /** or '100' */) Greenfoot.setWorld(/** put new world object here*/);"
Kokoro Kokoro

2017/2/6

#
Well i managed to fix the world teleportation by score... Still i need help with an actor that shoots you and also i need help with the "Scoreboard" that thing in left well it needs a white element that shows the score any way to fix ? I'm sure is in Welt > at public class or more..
danpost danpost

2017/2/6

#
The code for the chasers to fire bullets goes in the act method of the Chaser class. The change world code, after inserting the new world object where indicated, would go in the act method of the class of the currently active world.
Kokoro Kokoro

2017/2/6

#
Ok i will try also thanks for the support sir !!
danpost danpost

2017/2/6

#
Kokoro wrote...
Ok i will try also thanks for the support sir !!
The code for chasers to fire bullets should be contained in an 'if' block whose conditions somehow limit the production of the bullets.
Kokoro Kokoro

2017/2/6

#
I'm dumb explain me step by step... :(
danpost danpost

2017/2/6

#
Kokoro wrote...
I'm dumb explain me step by step... :(
What do you have so far? Show your current code.
Kokoro Kokoro

2017/2/6

#
So to restart it over teleport by the score is fine... Well about an actor shoots you...
import greenfoot.*;

public class Chaser extends QActor
{
    int dr = 0; // the current turn rate
    
    public Chaser()
    {
        setBoundedAction(Welt.actionType, Welt.actionDistance); // set bound fields
        // create image for this actor
        GreenfootImage image = new GreenfootImage(30, 30);
        image.fillOval(0, 0, 30, 30);
        image.setColor(new java.awt.Color(224, 240, 255));
        image.fillOval(7, 7, 16, 16);
        setImage(image);
        
    }

    /**
     * turn and move actor
     */
    public void act()
    {
        int dx = 0, dy = 0; // the differences in locational coordinates
        int rate = 0; // the rate of turn and speed

        Actor chased = Welt.chased;
        if (chased != null && chased.getWorld() != null)
        { // set variable values
            dx = getX()-chased.getX();
            dy = getY()-chased.getY();
            rate = 400-(int)Math.abs(dx)-(int)Math.abs(dy);

        }
        if (rate > 100)
        { // chase
            // the next code line does what is described in the following commented lines
               // determine shortest turn direction to face chased
            // int angleDiff = getRotation()-(int)(Math.atan2(dy, dx)*180/Math.PI); // range: -359 to 359
            // int anglet = (angleDiff+360+180)%360-180; // range: -180 to 179 (sign is turn direction)
               // turn and move
            // turn(16*rate*(int)Math.signum(anglet)); 
            turn(16*rate*(int)Math.signum((getRotation()-(int)(Math.atan2(dy, dx)*180/Math.PI)+540)%360-180));
            move(rate/8, getQR()); // between 'move(0.1)' to 'move(0.4)' for a non-QActor, which is not possible
        }
        else
        { // wander
            // vary turn rate
            dr += 2-Greenfoot.getRandomNumber(5)-(int)Math.signum(dr);
            // limit turn rate to between 40 q-rotation units left and right
            if (dr < -40) dr = -40;
            if (dr > 40) dr = 40;
            // turn and move
            turn(dr);
            move(10);
        
        }
    }
}
danpost danpost

2017/2/6

#
I am pressed for time at the moment. Will return in a bit.
There are more replies on the next page.
1
2
3
4