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

2012/6/25

Making actor score points/menu tourbleshooting.

1
2
3
4
5
SPower SPower

2012/6/26

#
And about that shooting repeatedly, you put it in the act method, that is called repeatedly.
ThinkingPainter ThinkingPainter

2012/6/26

#
okay its fixed now about it shooting when blip turns how do i fix that
ThinkingPainter ThinkingPainter

2012/6/26

#
weve come this far might as well finish the deed...
SPower SPower

2012/6/26

#
We didn't come far: we did almost nothing. With this:
ThinkingPainter wrote...
okay its fixed now about it shooting when blip turns how do i fix that
do you mean that you want to shoot when the blip turns?
ThinkingPainter ThinkingPainter

2012/6/26

#
if Blip turns right i want the Shot to fire right. if Blip turns left i want the shot to fire left if blip turns backwards i want him to fire a shot backwards. not just straight forward. see what i mean?
SPower SPower

2012/6/26

#
Yes, this is just working: you just have to turn the blip somewhere.
ThinkingPainter ThinkingPainter

2012/6/26

#
You can turn Blip any way and he just fires straight up.
SPower SPower

2012/6/26

#
Do you really turn, using 'setRotation' on THAT blip?
ThinkingPainter ThinkingPainter

2012/6/26

#
the code i got from http://www.greenfoot.org/doc/howto-1 was only coded to fire in one direction not all directions.
ThinkingPainter ThinkingPainter

2012/6/26

#
this is how blip turns
 public void act() 
    {
      if (shotTimer > 0) {
            shotTimer = shotTimer - 1;
        }
        else if (Greenfoot.isKeyDown("space")) {
            getWorld().addObject(new Shot(this), getX(), getY());
            shotTimer = 100; // delay next shot
        }
        if (Greenfoot.isKeyDown("w"))
      {
          move(4); 
        }
      if (Greenfoot.isKeyDown("a"))
      {
          turn (-3);
      }
      if (Greenfoot.isKeyDown("d"))
      {
          turn(3);
      }
      if (Greenfoot.isKeyDown("s"))
      {
          move(-4);
      }
          
    
      eat();    
   
    }   
SPower SPower

2012/6/26

#
I don't see you creating a new shot...
ThinkingPainter ThinkingPainter

2012/6/26

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class RedBlip here.
 * 
 * @author (Caleb Painter) 
 * @version (6/22/2012 VERSION 1.0)
 */
public class Blip extends Actor
{
   private int shotTimer = 0;

 /**
     * Act - do whatever the Blip wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
      if (shotTimer > 0) {
            shotTimer = shotTimer - 1;
        }
        else if (Greenfoot.isKeyDown("space")) {
            getWorld().addObject(new Shot(this), getX(), getY());
            shotTimer = 100; // delay next shot
        }
        if (Greenfoot.isKeyDown("w"))
      {
          move(4); 
        }
      if (Greenfoot.isKeyDown("a"))
      {
          turn (-3);
      }
      if (Greenfoot.isKeyDown("d"))
      {
          turn(3);
      }
      if (Greenfoot.isKeyDown("s"))
      {
          move(-4);
      }
        {
          setRoation(int Blip);
        }
    
      eat();    
   
    }   
  
    
        public Blip()  
 {  
    GreenfootImage image = getImage();  
    image.scale(image.getWidth() - 10, image.getHeight() - 10);  
    setImage(image); 
    
 }  
  public void eat()
  {
      Actor goldenball;
      goldenball= getOneObjectAtOffset(0, 0, GoldenBall.class);
      if (goldenball != null)
      {
          World world;
          world = getWorld();
          world.removeObject(goldenball);
       Blip blip = new Blip();  
       Shot shot = new Shot(blip);shot.setRotation(getRotation());  
       getWorld().addObject(shot, getX(), getY());  
       
       // set the rotation      
      // add it to the world 
        }
        }
     
    
    }
ThinkingPainter ThinkingPainter

2012/6/26

#
its right there at 67-72
SPower SPower

2012/6/26

#
ThinkingPainter wrote...
the code i got from http://www.greenfoot.org/doc/howto-1 was only coded to fire in one direction not all directions.
That scenario wasn't made to shoot in different directions...
ThinkingPainter ThinkingPainter

2012/6/26

#
Well i know that! i want mine to shoot it different directions... havnt you been paying attention?
There are more replies on the next page.
1
2
3
4
5