📄 csdn技术中心 applet射击小游戏开源.htm
字号:
else<BR>
{<BR>
g.setColor(new Color(66, 65,
66));<BR>
for(int k = 0; k <= 12; k +=
3)<BR>
{<BR>
g.drawOval(startx - xoffset + k * 20, starty, 10 * k, 16 -
k);<BR>
g.drawRect(startx - xoffset + k * 20 - 10, starty + 5, 5 * k, 16 -
k);<BR>
}<BR>
}<BR>
g.setColor(temp);</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7">
}<BR> public boolean checkexplode(Graphics
g)<BR>
{<BR> if
(explode)<BR>
{<BR>
exploding(g);<BR>
countofexplode--;<BR>
if (countofexplode ==
0)<BR>
{<BR>
stop();</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
return
true;<BR>
}<BR>
}<BR> return
false;<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void check() //tells
shotH to check the shots' movement<BR>
{<BR> if (starty <
0)<BR>
{<BR>
stop();<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7">
}<BR> public void paint(Graphics
g)<BR>
{
//this is the shots paint method... draws a line from its last
position to its current position,
basically<BR>
rot++;
//advances color
rotation<BR> if (rot ==
16)<BR>
{<BR>
rot = 0;<BR>
}
//keeps rotation below
17<BR> Color col1 = new
Color(255 - (rot * 8), rot * 8, 127 + rot *
8); //makes the new
color<BR> if (rot % 2 ==
0)<BR>
{<BR>
g.setColor(col1); //sets the current color to the
rotation color<BR>
}</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
g.fillOval((int)startx, (int)starty, firesize,
firesize); //draws a line from
the current coords to the previous
coords<BR>
g.fillOval((int)startx - xoffset, (int)starty, firesize,
firesize); //draws a line from the current
coords to the previous
coords<BR>
g.fillOval((int)startx + xoffset, (int)starty, firesize,
firesize); //draws a line from the current
coords to the previous coords</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7">
}<BR> //}<BR>};</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7">//
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //<BR>class fire
implements Runnable<BR>{<BR> int
startx;<BR> int
starty;<BR> int
firespeed;<BR> int
firesize;<BR> int rot;<BR>
int countofexplode;<BR> int
type;<BR> Thread myThread;<BR>
static int count = 0;<BR> boolean state, explode,
sharkfirehitted;<BR> public
fire()<BR>
{<BR> state =
false;<BR>
count++;<BR>
countofexplode = 0;<BR>
type = 0;</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
myThread = null;<BR> }<BR>
public fire(int x, int y, int speed, int size)<BR>
{<BR>
count++;<BR> startx =
x;<BR> starty =
y;<BR> firespeed =
speed;<BR> firesize =
size;<BR> myThread =
null;<BR> explode =
false;<BR> sharkfirehitted
= false;<BR> state =
true;<BR> countofexplode =
0;<BR> type =
0;<BR>
this.start();<BR> }<BR> public
fire(int x, int y, int speed, int size, int
atype)<BR>
{<BR> set(x, y, speed,
size, atype);<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void set(int x, int y, int speed, int size, int
atype)<BR>
{<BR> startx =
x;<BR> starty =
y;<BR> firespeed =
speed;<BR> firesize =
size;<BR> explode =
false;<BR> sharkfirehitted
= false;<BR> state =
true;<BR> countofexplode =
0;<BR> type =
atype;<BR>
this.start();<BR> }<BR> public
void set(int x, int y, int speed, int size)<BR>
{
//count++;<BR> startx =
x;<BR> starty =
y;<BR> firespeed =
speed;<BR> firesize =
size;<BR> explode =
false;<BR> sharkfirehitted
= false;<BR> state =
true;<BR> countofexplode =
0;<BR> type =
0;<BR> //
myThread=null;<BR>
this.start();<BR> }<BR> public
void setexplode()<BR>
{
//count++;<BR> explode =
true;<BR> countofexplode =
8;<BR>
//System.out.println("explode is true now
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");<BR>
//this.paint<BR> }<BR> public
void setsharkfirehitted()<BR>
{
//count++;<BR>
sharkfirehitted =
true;<BR> countofexplode =
4;<BR>
//System.out.println("explode is true now
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");<BR>
//this.paint<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void start()<BR>
{
//state=true;</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
if (myThread == null)<BR>
{<BR>
System.out.println("Starting!");<BR>
myThread = new
Thread(this);<BR>
myThread.start();</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
}<BR>
else<BR>
{<BR>
myThread.stop();<BR>
myThread = new
Thread(this);<BR>
myThread.start();<BR>
}<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void stop()<BR>
{<BR> state =
false;<BR> if (myThread !=
null)<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -