資源簡(jiǎn)介
一個(gè)java3d網(wǎng)球游戲的源代碼
一個(gè)java3d網(wǎng)球游戲的源代碼

代碼片段和文件信息
package?Tennis;
import?com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
import?com.sun.j3d.utils.geometry.*;
import?com.sun.j3d.utils.universe.*;
import?com.sun.j3d.utils.image.*;
import?javax.media.j3d.*;
import?javax.vecmath.*;
class?Ball?extends?VirtualEntity
{
public?double?elapsed?=?0;
public?long?lastCollisionTime?=?0;
public?Vector3d?lastCollision?=?new?Vector3d(0?0?0);
public?Vector3d?pos?=?new?Vector3d(0?TennisGame.BALL_RADIUS?0);
public?Vector3d?dir?=?new?Vector3d(0?0?0);
private?Shadow?bShadow;
public?double?speed?=?0.0;
public?boolean?stopped?=?true;
Ball()
{ models?=?new?Shape3D[1];
mtrans?=?new?Transform3D[]{?new?Transform3D()?};
Appearance?a?=?getStdAppearance(“textures/tball.gif“?Material.DIFFUSE?false);
Material?m?=?a.getMaterial();
m.setSpecularColor(0f?0f?0f);
a.setMaterial(m);
Sphere?s?=?new?Sphere(TennisGame.BALL_RADIUS?PRIMFLAGS?10?a);
models[0]?=?s.getShape(Sphere.BODY);
bShadow?=?new?Shadow(0.5f?true);
}
public?synchronized?void?changeDir(double?x?double?y?double?z?double?s)
{ speed?=?s;
stopped?=?(speed?==?0);
dir.set(x?y?z);
setLastCollision();
}
public?synchronized?void?setForService()
{
// TennisGame.court.lastZ?=?0;
changeDir(0?0?0?0);
pos.x?=?TennisGame.players[TennisGame.curServer].pModel.worldX?+?(0.25?*?TennisGame.serveSide);
pos.z?=?TennisGame.players[TennisGame.curServer].pModel.worldZ;
pos.y?=?1.5;
bShadow.update(pos);
}
private?double?tempRads?=?0.0;
public?synchronized?void?setShot(double?x?double?z?int?sType?double?s)
{ dir.set(x?-?pos.x?0?z?-?pos.z);
if(sType?==?0) //?normal?shot?-?set?dir.y?to?+?1.0?instead?of?+?0.5?for?different?results
{ //dir.normalize();
//dir.y?=?((TennisGame.NET_HEIGHT?*?2?+?1.0)?+?((Math.abs(pos.z)?/?dir.z)?*?(GAME_SPEED?*?TennisGame.GRAVITY)))?/?(TennisGame.COURT_LENGTH?/?2.0);
//speed?=?(TennisGame.MAX_SPEED?*?0.5)?+?Math.max(s?*?0.5?1);
// dir.y?=?(TennisGame.NET_HEIGHT?*?2?+?1.5);//?/?Math.min(Math.max(Math.abs(pos.z?/?(TennisGame.COURT_LENGTH))?0.8)?1.0);
tempRads?=?Math.atan((TennisGame.NET_HEIGHT?*?4.0)?/?Math.min(Math.max(Math.abs(pos.z)?TennisGame.COURT_LENGTH?*?0.65)?TennisGame.COURT_LENGTH?*?0.9));?//(TennisGame.COURT_LENGTH?*?0.9));?//?angle?of?shot?is?function?of?court?length?and?net?height
dir.y?=?(dir.length()?/?Math.cos(tempRads))?*?Math.sin(tempRads); //?straight?shot?=?variable?degrees
speed?=?5.0?+?15.0?*?Math.abs(pos.z?/?TennisGame.COURT_LENGTH)?+?s?*?10.0;
}
else?if(sType?==?1)
{ dir.y?=?(dir.length()?/?Math.cos(Math.PI?/?3.25))?*?Math.sin(Math.PI?/?3.25); //?lob?=?55?degrees
speed?=?8.0?+??s?*?9.5; //?min?speed?=?8.0?max?=?17.5
}
else?if?(sType?==?2)
{ dir.y?=?(dir.length()?/?Math.cos(Math.PI?/?6.0))?*?Math.sin(Math.PI?/?6.0); //?drop?=?30?degrees
speed?=?5.0?+?s?*?4.0; //?max?=?9.0
}
else?if(sType?==?3)
{ dir.y?=?0;
dir.norma
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4533??2004-06-17?04:22??網(wǎng)球大賽\Ball.java
?????文件???????2616??2004-06-17?04:22??網(wǎng)球大賽\Camera.java
?????文件???????7366??2004-06-17?04:22??網(wǎng)球大賽\CommThread.java
?????文件?????????50??2004-06-17?04:35??網(wǎng)球大賽\compile.bat
?????文件??????18009??2004-04-11?20:02??網(wǎng)球大賽\COPYING.txt
?????文件??????18075??2004-06-17?04:22??網(wǎng)球大賽\Court.java
?????文件???????4519??2004-06-08?04:01??網(wǎng)球大賽\hs_err_pid3960.log
?????文件?????380761??2003-05-26?18:19??網(wǎng)球大賽\max.ms3d
?????文件????????198??2004-06-17?04:22??網(wǎng)球大賽\Message.java
?????文件???????9038??2004-06-17?04:22??網(wǎng)球大賽\Pla
?????文件?????????46??2004-06-17?04:36??網(wǎng)球大賽\run.bat
?????文件???????5868??2004-06-17?04:22??網(wǎng)球大賽\ScoreBoard.java
?????文件???????1144??2004-06-17?04:22??網(wǎng)球大賽\Shadow.java
?????文件???????1622??2004-06-17?04:22??網(wǎng)球大賽\SplashScreen.java
?????文件???????1464??2004-06-17?04:38??網(wǎng)球大賽\src_tennisgame.txt
?????文件???????8697??2004-06-17?04:22??網(wǎng)球大賽\Tennisfr
?????文件??????13804??2004-06-17?04:22??網(wǎng)球大賽\TennisGame.java
?????文件??????52994??2008-09-24?11:06??網(wǎng)球大賽\TennisGame.jcd
?????文件???????2009??2004-06-17?04:39??網(wǎng)球大賽\TennisGame.jcp
?????文件???????3703??2004-06-17?04:39??網(wǎng)球大賽\TennisGame.jcu
?????文件????????265??2004-06-17?04:39??網(wǎng)球大賽\TennisGame.jcw
?????文件??????10839??2004-06-17?04:22??網(wǎng)球大賽\TennisLaunch.java
?????文件???????2047??2004-06-17?04:22??網(wǎng)球大賽\VirtualEntity.java
?????文件?????146414??2003-05-23?18:27??網(wǎng)球大賽\audio\aaah.wav
?????文件?????467988??2004-06-06?15:13??網(wǎng)球大賽\audio\applause.wav
?????文件??????33934??2003-03-06?18:02??網(wǎng)球大賽\audio\ballhit.wav
?????文件???????5412??2003-04-14?10:26??網(wǎng)球大賽\audio\beep.wav
?????文件?????138354??2002-02-20?00:45??網(wǎng)球大賽\audio\crowdcheer.wav
?????文件????1470062??2004-06-06?07:17??網(wǎng)球大賽\audio\exhort.wav
?????文件??????59666??2003-05-23?16:51??網(wǎng)球大賽\audio\firstserve.wav
............此處省略143個(gè)文件信息
評(píng)論
共有 條評(píng)論