网站首页 > 文章中心 > 其它

java敲代码爆炸特效

作者:小编 更新时间:2023-10-04 14:29:38 浏览量:68人看过

Java代码,敲代码

public class Vehicles {

java敲代码爆炸特效-图1

private String brand;

private String color;

//构造方法

public Vehicles(String brand, String color) {

this.brand = brand;

this.color = color;

}

public void run() {

System.out.println("我已经开动了");

public void showinfo() {

java敲代码爆炸特效-图2

System.out.println("商标: " + brand);

System.out.println("颜色: " + color);

保存为Vehicles.java

/////////////////////////////////////////////////////////////

public class Car extends Vehicles {

private int seats;

public Car(String brand, String color, int seats) {

super(brand, color);

this.seats = seats;

public void showCar() {

super.showinfo();

System.out.println("座位: " + seats + " 个");

保存为 Car.java

//////////////////////////////////////////////////////////////////////////////

public class Truck extends Vehicles {

private float load;

public Truck(String brand, String color, float load) {

this.load = load;

public void showTruck() {

System.out.println("载重 :" + load + "吨");

保存为Truck.java

public class Test {

public static void main(String[] args) {

Vehicles vehicle = new Vehicles("奥迪", "黑色");

vehicle.showinfo();

car.showCar();

Truck truck = new Truck("解放", "蓝色", 10);

truck.showTruck();

作为一个Java初学者,照着书敲代码有用吗

绝对是有用的,很大用出.

代码就是这样,你只有敲得多了才会慢慢学好.

不要怕累,多联系会好的.

如有帮助请采纳谢谢

页面特效:下星星的代码(JAVA代码)

java敲代码爆炸特效-图3

以下的代码就可以,lz自己在*的地方填入星星的图片就可以了

style

/style

script language="javascript"

snow = false; // false-rain; true-snow

snowsym = " * " are the symbols for each

rainsym = " * " can put images here.

/**************Do not need to change anything below***********/

if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}

movex = -speed/angle; movey = speed; count = 0;

function moverain(){

for(move = 0; move drops; move++){

xx[move]+=movex; yy[move]+=mv[move];

hmm = Math.round(Math.random()*1);

if(xx[move] 0){xx[move] = maxx+10;}

if(yy[move] maxy){yy[move] = 10;}

drop[move].left = xx[move]

drop[move].top = yy[move]+document.body.scrollTop;

}setTimeout('moverain()','1')}

/script

if (document.all){

drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()

ly = "document.all[\'"; st = "\'].style"

for(make = 0; make drops; make++){

drop[make] = eval(ly+'drop'+make+st);

xx[make] = Math.random()*maxx;

yy[make] = -100-Math.random()*maxy;

drop[make].left = xx[make]

drop[make].top = yy[make]

if(snow){col = 'white'}else{col = 'white'}

drop[make].color = col;

window.onload=moverain

/body

java编按鼠标就发射子弹代码

监听鼠标动作,

然后控制子弹图片移动.

然后跟目标做碰撞检测.

java 事件 消息传递机制 实际上是

java全是代码,怎么会做出非常漂亮的画面

唉,给你看看小Case的,自己运行一下

import java.awt.AlphaComposite;

import java.awt.Color;

import java.awt.Graphics;

import java.awt.image.BufferedImage;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.SwingUtilities;

public class TranslucentButton extends JButton {

BufferedImage buttonImage = null;

/** Creates a new instance of TranslucentButton */

public TranslucentButton(String label) {

super(label);

setOpaque(false);

public void paint(Graphics g) {

// Create an image for the button graphics if necessary

if (buttonImage == null || buttonImage.getWidth() != getWidth() ||

buttonImage.getHeight() != getHeight()) {

buttonImage = getGraphicsConfiguration().

createCompatibleImage(getWidth(), getHeight());//返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容的 BufferedImage

Graphics gButton = buttonImage.getGraphics();

gButton.setClip(g.getClip());//设置获取的当前的剪贴区域

// Have the superclass render the button for us

super.paint(gButton);

// Make the graphics object sent to this paint() method translucent

AlphaComposite newComposite =

// Copy the button's image to the destination graphics, translucently

private static void createAndShowGUI() {

JFrame f = new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel checkerboard = new Checkerboard();

checkerboard.add(new TranslucentButton("Translucent Button"));

f.add(checkerboard);

f.setVisible(true);

public static void main(String args[]) {

Runnable doCreateAndShowGUI = new Runnable() {

createAndShowGUI();

};

SwingUtilities.invokeLater(doCreateAndShowGUI);//swing线程

private static class Checkerboard extends JPanel {

public void paintComponent(Graphics g) {

g.setColor(Color.white);

g.fillRect(0, 0, getWidth(), getHeight());

g.setColor(Color.BLACK);

for (int stripeX = 0; stripeX getWidth(); stripeX += CHECKER_SIZE) {

用java线程做飞机大战,发射子弹及爆炸的代码怎么写啊,求高人,写上注释吧,不然看不懂,谢谢

代码有点多, 实现思路, 实现键盘事件监听机制, 在监听函数中判断 按了什么键,比如按J就发送子弹. 然后启动子弹线程. 定义一个子弹类线程, 定义出子弹的所在属性和方法.

写个方法,判断子弹是否击中目标,以XY坐标相交来判断

以上就是土嘎嘎小编为大家整理的java敲代码爆炸特效相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章