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

2012/3/11

power ups?

2
3
4
5
6
7
8
danpost danpost

2014/4/18

#
In 'whatever': * add any required actor for ability * set any fields required for ability In your code above for the Starfighter class, lines 69 through 71, line 69 removes the powerup, and the other lines, lines 70 and 71, perform the 'whatever' for the ability given by the SpeedBoost powerup.
GamesGrinder1998 GamesGrinder1998

2014/4/18

#
danpost wrote...
In 'whatever': * add any required actor for ability * set any fields required for ability In your code above for the Starfighter class, lines 69 through 71, line 69 removes the powerup, and the other lines, lines 70 and 71, perform the 'whatever' for the ability given by the SpeedBoost powerup.
thanks, how would i write the timer code for the powerup to just stay on the screen a few seconds if it is not shot. also could give an example of what i could possibly write in 'whatever', would it be as simple as speed += 5???
danpost danpost

2014/4/18

#
GamesGrinder1998 wrote...
how would i write the timer code for the powerup to just stay on the screen a few seconds if it is not shot
Your indication is that your starfighter must shoot the powerup icon to gain the ability. Is that correct? As far as the few seconds to stay on the screen, I already built that into the Powerup class. You can adjust the 'lifespan' value as desired.
GamesGrinder1998 GamesGrinder1998

2014/4/18

#
danpost wrote...
GamesGrinder1998 wrote...
how would i write the timer code for the powerup to just stay on the screen a few seconds if it is not shot
Your indication is that your starfighter must shoot the powerup icon to gain the ability. Is that correct? As far as the few seconds to stay on the screen, I already built that into the Powerup class. You can adjust the 'lifespan' value as desired.
ok so to sum up i only need one class for the 3 powerups and the world will randomnly pick which powerup to put on the screen...also will the powerup showing each time be delayed between each one
danpost danpost

2014/4/19

#
GamesGrinder1998 wrote...
will the powerup showing each time be delayed between each one
I am not sure what you are asking here. Be a little more specific. This, however, may answer the question. We put a minimum 20 second delay on the spawning and only a 5 to 6 seconds of showing a powerup. That would mean at least 14 seconds will pass between the disappearing of one and the showing of the next.
GamesGrinder1998 GamesGrinder1998

2014/4/19

#
danpost wrote...
GamesGrinder1998 wrote...
will the powerup showing each time be delayed between each one
I am not sure what you are asking here. Be a little more specific. This, however, may answer the question. We put a minimum 20 second delay on the spawning and only a 5 to 6 seconds of showing a powerup. That would mean at least 14 seconds will pass between the disappearing of one and the showing of the next.
ok but have you answered my other question on spawning the enemies about how in multiplayer mode, it spawns in the player one box but i want it to spawn in the player 2 box....how do you fix that
danpost danpost

2014/4/19

#
GamesGrinder1998 wrote...
have you answered my other question on spawning the enemies about how in multiplayer mode, it spawns in the player one box but i want it to spawn in the player 2 box....how do you fix that
I do not see anywhere in this discussion where you ask anything like that. And explain the boxes -- what are they, how do they relate to your players, etc.
GamesGrinder1998 GamesGrinder1998

2014/4/19

#
danpost wrote...
GamesGrinder1998 wrote...
have you answered my other question on spawning the enemies about how in multiplayer mode, it spawns in the player one box but i want it to spawn in the player 2 box....how do you fix that
I do not see anywhere in this discussion where you ask anything like that. And explain the boxes -- what are they, how do they relate to your players, etc.
in my other discussion about spawning enemies you haven't replied, boxes i mean if the starfighter2 shoots a enemy, it will respawn on the starfighter ones side, i used what you told me to int x = minx+.....but i get that problem how do i fix it
GamesGrinder1998 GamesGrinder1998

2014/4/19

#
GamesGrinder1998 wrote...
danpost wrote...
GamesGrinder1998 wrote...
have you answered my other question on spawning the enemies about how in multiplayer mode, it spawns in the player one box but i want it to spawn in the player 2 box....how do you fix that
I do not see anywhere in this discussion where you ask anything like that. And explain the boxes -- what are they, how do they relate to your players, etc.
in my other discussion about spawning enemies you haven't replied, boxes i mean if the starfighter2 shoots a enemy, it will respawn on the starfighter ones side, i used what you told me to int x = minx+.....but i get that problem how do i fix it
i got a new problem saying '.class' expected in my starfighter, here is the code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Starfighter here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Starfighter extends Player
{
    private final int SPEED_BOOST_TIMER = 115;  
    private int SpeedBoostTimeLeft = SPEED_BOOST_TIMER;  
    private int Speed;  
    private boolean gotSpeedBoost = false; 
    private int x;
    private int y;

    public Starfighter()
    {
        Speed = 5;
    }    

    public void act() 
    {
        checkKeys();
        atWorldEdge(); 
        stopAtWalls(); 
        getSpeedBoost();  
        if (gotSpeedBoost)  
        {  
            speedBoostTimer();  
        }
    }

    public void checkKeys()
    {
        if ( Greenfoot.isKeyDown("left") )
        {
            move(-5);
        }
        if ( Greenfoot.isKeyDown("right") )
        {
            move(5);
        }   
        if("space".equals(Greenfoot.getKey()))
        {
            getWorld().addObject(new Fireball(getRotation()), getX(), getY());
            Greenfoot.playSound("fireball.wav");
        }    
    }

    public void stopAtWalls()
    {  
        if(getOneIntersectingObject(Wall.class)!=null)
        {
            setLocation(x,y);
        }
        else
        {
            x = getX();
            y = getY();
        }    
    }  

    public void getSpeedBoost()  
    {  
        Powerup pu = (Powerup)getOneObjectAtOffset(0, 0, Powerup.class);  
        if (pu != null)  
            int kind = pu.getType();  
        getWorld().removeObject(pu);  
        if (kind == Powerup.SPEED_PU) { speed += 5 }  
    }

    public void speedBoostTimer()  
    {  
        SpeedBoostTimeLeft--;  
        if (SpeedBoostTimeLeft <= 0)  
        {  
            gotSpeedBoost = false;  
            Speed -= 5;  
            SpeedBoostTimeLeft = SPEED_BOOST_TIMER;  
        }  
    }  
}    
danpost danpost

2014/4/19

#
I am not exactly sure what you are getting at. Are you saying that enemies will be killed (hopefully) by the starfighter on the side it is spawned on? can either ship fire at any enemy or only at those on its side? It might help if I had some context as to what you are trying to accomplish (in general, as well as specific to the issue).
danpost danpost

2014/4/19

#
You are missing an open curly bracket between lines 68 and 69.
GamesGrinder1998 GamesGrinder1998

2014/4/19

#
danpost wrote...
You are missing an open curly bracket between lines 68 and 69.
don't worry i somehow fixed it but now it saying can't find file but i designed my images on fireworks and there is a fw after it, do i have to put it and its PNG Image P.S what does PNG stand for?
danpost danpost

2014/4/19

#
Portable Network Graphics (PNG). I do not believe that Greenfoot supports '.fw' image files.
GreenfootImage API (first constructor detailed) wrote...
Supported file formats are JPEG, GIF and PNG.
GamesGrinder1998 GamesGrinder1998

2014/4/19

#
danpost wrote...
Portable Network Graphics (PNG). I do not believe that Greenfoot supports '.fw' image files.
GreenfootImage API (first constructor detailed) wrote...
Supported file formats are JPEG, GIF and PNG.
i deleted the fw from it but it still comes up with the message, do i write the png in caps
danpost danpost

2014/4/19

#
GamesGrinder1998 wrote...
i deleted the fw from it but it still comes up with the message, do i write the png in caps
Renaming the file is not enough. The file must be saved into one of the supported formats. And yes, the way you write it must be consistent with the way the filename was saved for the file.
There are more replies on the next page.
2
3
4
5
6
7
8