This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Several forum topics in the past have asked about how to implement | |
* a timer or delay without using an Appstate or Control or an extra | |
* thread, which may be overkill for simple purposes such as delaying | |
* input into an Analog Listener (say, holding down a button to increment | |
* an integer value). I use getTimeInSeconds() here because getTime() | |
* returns ticks, and so you get unexpected behaviour like the timer | |
* counting 9.8 -> 9.9 -> 1.0 -> 1.1 etc. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WorldNode extends Node { | |
@Override | |
public void read(JmeImporter e) throws IOException { | |
super.read(e); | |
InputCapsule capsule=e.getCapsule(this); | |
enemies=(Node) capsule.readSavable("Enemies", new Node()); | |
staticObjects=(Node) capsule.readSavable("StaticObjects", new Node()); | |
powerUps=(Node) capsule.readSavable("PowerUps", new Node()); | |
sky=(Geometry) capsule.readSavable("Sky", new Geometry()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LittleLevelState implements Savable{ | |
private WorldNode littleWorld1; | |
private WorldNode littleWorld2; | |
public LittleLevelState(WorldNode littleWorld1, WorldNode littleWorld2) { | |
this.littleWorld1 = littleWorld1; | |
this.littleWorld2 = littleWorld2; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main extends SimpleApplication { | |
public ArrayList<BaseEntity> entities = new ArrayList<BaseEntity>(); | |
public ArrayList<Spatial> blocks = new ArrayList<Spatial>(); | |
public Player player; | |
public static void main(String[] args) { | |
AppSettings settings= new AppSettings(true); | |
settings.setTitle("jMonkey Pong 3D"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static float[] RGBToOpenGL(int r1, int g1, int b1) { | |
float[] tmp = new float[3]; | |
tmp[0] = r1/255f; | |
tmp[1] = g1/255f; | |
tmp[2] = b1/255f; | |
return tmp; | |
} | |
public static float[] RGBAToOpenGL(int r1, int g1, int b1, int a1) { | |
float[] tmp = new float[4]; | |
tmp[0] = r1/255f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main extends SimpleApplication { | |
static final float START_Y = 150f ; | |
public static void main(String[] args) { | |
Main app = new Main(); | |
app.start(); | |
} | |
@Override | |
public void simpleInitApp() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean scale = true ; | |
float timePassed = 0.0f; | |
/* This is the update loop */ | |
@Override | |
public void simpleUpdate(float tpf) | |
{ | |
timePassed+= tpf; | |
if (timePassed >= 0.3 ){timePassed=0; scale=(!scale); } //change decrease/increase every 0.3 sec. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sets the MaterialFaces for a given object. By using the applyToFront and | |
* applyToBack parameters, each desired combination of face settings can be | |
* produced (None, Front, Back, Both). | |
* @param spatial The spatial for which to set the MaterialFace | |
* @param applyToFront True if the front face should have the material applied | |
* @param applyToBack True if the back face should have the material applied | |
* @see MaterialFace | |
*/ | |
public static void setMaterialFaceApplication(Spatial spatial, boolean applyToFront, boolean applyToBack){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future fut = application.enqueue(new Callable() { | |
public Object call() throws Exception { | |
//this is where you modify your object, you can return a result value | |
return modifyObject(); | |
} | |
}); | |
//to retrieve return value (waits for call to finish, fire&forget otherwise): | |
fut.get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ResourceLocator myLocator= new ResourceLocator(){ | |
public URL locateResource(String resourceName){ | |
//GET THE URL HERE | |
} | |
}); | |
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, myLocator); |
OlderNewer