Aircraft Wars Game 2.0

added green buff

JFrame interface is still Flicker is changed to Frame and double buffering technology is added. The interface does not flicker, but it should burn too much space

Modified the survival and death The condition is the corresponding function body

Encapsulation of the code, enhancement of the random appearance of Buff

< p>/**
* Green buff
* Protect the aircraft from injury for five seconds
* @author Xiaofan knocks the code
*
*/
public class GreenBuff extends GameObject{
int buffstarttime=-1;//Determine whether the buff has been eaten and record the time

public GreenBuff() {
width=Constant.GREEN_BUFF_WIDTH;
height=Constant.GREEN_BUFF_HEIGHT;

x=Math.random()*Constant.FRAME_WIDTH;
y=30;
speed=6 ;
}
//Display
public void draw(Graphics g) {
if(y {
if(buffstarttime==-1)//Have not been eaten and not eaten
{
Color c=g.getColor();
g.setColor(Color.GREEN);
y+ =speed;
g.fillOval((int)x, (int)y, width, height);
g.setColor(c);
}
Else {
Buffstarttime=-1;//Out of screen
}
}
}

Double buffering technology

Image ImageBuffer = null;
Graphics GraImage = null;

//Override the update method public void update(Graphics g){ ImageBuffer = createImage(this.getWidth(), this.getHeight()); //Create graphics buffer GraImage = ImageBuffer.getGraphics(); Get graphics buffer The graphics context of the area paint(GraImage); //Call the paint method GraImage.dispose(); //Release graphics context resources g.drawImage(ImageBuffer, 0, 0, this); //Draw the graphics buffer onto the screen)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1779 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.