📄 csdn技术中心 applet射击小游戏开源.htm
字号:
{
//count++;<BR> explode =
true;<BR> countofexplode =
8;<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("sharkfire_shot
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>
{<BR>
myThread.stop();<BR>
myThread =
null;<BR>
System.out.println(" sharkfire_shot thread stopped
");<BR>
}<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void destroy()<BR>
{<BR>
System.gc();<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void run()<BR>
{<BR> //Do
stuff<BR>
//System.out.println("run");<BR>
myThread.setPriority(Thread.MIN_PRIORITY);</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
while (myThread !=
null)<BR>
{<BR>
try<BR>
{<BR>
Thread.sleep(100);<BR>
}<BR>
catch(InterruptedException
e)<BR>
{<BR>
}<BR>
//
repaint();</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
if (starty < 0) //from buttom to
top<BR>
{<BR>
System.out.println("sharkfire_shot stop" + starty + "cont is " +
count);</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
myThread.stop();<BR>
}</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
}<BR> myThread =
null;<BR> }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void move()
//tells shotH to move all the shots<BR>
{<BR> starty -=
firespeed;<BR> xoffset +=
firespeed; //the fire will be move to the position with
x cordinate startx startx+xoffset and startx-xoffset</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
//shark_fire<BR>
//
System.out.println("moving ");<BR>
}</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f1fee7"> public
void exploding(Graphics g) //tells shotH to move all the
shots<BR>
{
//starty+=firespeed;<BR>
System.out.println(" sharkfire_shot exploding ");</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
g.fillOval(startx, starty, (int)((firesize + (10 - countofexplode) *
3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
g.fillRoundRect(startx, starty, (10 - countofexplode) * 3, (10 -
countofexplode) *
3,<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));<BR>
g.fillOval(startx - xoffset, starty, (int)((firesize + (10 -
countofexplode) * 3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
g.fillRoundRect(startx + xoffset, starty, (10 - countofexplode) * 3,
(10 - countofexplode) *
3,<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));<BR>
g.fillOval(startx - xoffset, starty, (int)((firesize + (10 -
countofexplode) * 3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
g.fillRoundRect(startx + xoffset, starty, (10 - countofexplode) * 3,
(10 - countofexplode) *
3,<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()),<BR>
(int)((firesize + (10 - countofexplode) * 3) *
Math.random()));<BR> Color
temp = g.getColor();<BR>
switch (countofexplode %
8)<BR>
{<BR>
case
0:<BR>
case
1:<BR>
case
2:<BR>
g.setColor(new Color(255, 255,
206));<BR>
break;<BR>
case
3:<BR>
g.setColor(new Color(49, 48,
49));<BR>
break;<BR>
case
4:<BR>
case
5:<BR>
g.setColor(new Color(255, 251,
247));<BR>
break;<BR>
case
6:<BR>
g.setColor(new Color(255, 69,
255));<BR>
break;<BR>
case
7:<BR>
//case
8:<BR>
//default:g.setColor(new
Color(255,243,231));<BR>
break;<BR>
}<BR> if (countofexplode %
3 == 0)<BR>
{<BR>
g.fillOval(startx, starty, (int)((firesize + (10 - countofexplode) *
300) *
Math.random()),<BR>
(int)(2 * (firesize) * Math.random()));</FONT></P>
<P><FONT
style="BACKGROUND-COLOR: #f1fee7">
}<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -