How to type code blocks

Markdown code block : Embed your code in 3 backticks, like this

```<optional language>
//your code here
```    

If you don’t know how to type a backtick, here are some related links :
How to type a backtick on windows
For mac users :
On qwerty keyboards it’s the key right to the left shift (along with the " key).
On azerty keyboards it’s the key over the right shift (along with the £ key).

This uses highlight.js, but uses a subset of the supported langages (following code block uses java).
If no language is specified java is used by default.

package jme3test.helloworld;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/** Sample 1 - how to get started with the most simple JME 3 application.
 * Display a blue 3D cube and view from all sides by
 * moving the mouse and pressing the WASD keys. */
public class HelloJME3 extends SimpleApplication {

    public static void main(String[] args){
        HelloJME3 app = new HelloJME3();
        app.start(); // start the game
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1); // create cube shape
        Geometry geom = new Geometry("Box", b);  // create cube geometry from the shape
        Material mat = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");  // create a simple material
        mat.setColor("Color", ColorRGBA.Blue);   // set color of material to blue
        geom.setMaterial(mat);                   // set the cube's material
        rootNode.attachChild(geom);              // make the cube appear in the scene
    }
}

Note that this is the preferred way of inserting code blocks.

Default code block : Paste the code, Select the code and hit the </> button in the tool bar. Alternatively you can indent each line of code by 4 space.

package jme3test.helloworld;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/** Sample 1 - how to get started with the most simple JME 3 application.
 * Display a blue 3D cube and view from all sides by
 * moving the mouse and pressing the WASD keys. */
public class HelloJME3 extends SimpleApplication {

    public static void main(String[] args){
        HelloJME3 app = new HelloJME3();
        app.start(); // start the game
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1); // create cube shape
        Geometry geom = new Geometry("Box", b);  // create cube geometry from the shape
        Material mat = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");  // create a simple material
        mat.setColor("Color", ColorRGBA.Blue);   // set color of material to blue
        geom.setMaterial(mat);                   // set the cube's material
        rootNode.attachChild(geom);              // make the cube appear in the scene
    }
}


**Github link :** You can also just put a github link to a code file, and a preview is displayed (you can't scroll so that's more aesthetic than useful) ; like this :
3 Likes
Here is a ChaseCameraAppState that rotates around the target spatial's local axis
Big quality games like the mummy,portal,nfs in jmonkey no comprimasation on speed and graphics
Scroll panel in lemur
Animations do not play until joystick analog event ends
How do I make an image draw-able so that the user is able to draw on the image?
Unsupported operation exception in JME 3.1
ClassCastException in using models with textures
Physics elimination
GhostControl not detecting overlap with BetterCharacterControl
[Solved] JME 3.1 Android Terrain Texture Problems
pickObject with Ray
SimEthereal basic example - plus public server
How to serialize an ArrayList<CustomObject>?
Box Drop Stack (Android Game) RELEASED
Shader Grid Creation
Moving spatial with appstate
Understanding AbstractControl to myself
Node Won't Move with chase camera
Texture not rendering at an angle
That's why everyone asks about BufferedImages
Bitmap Text goes black
How to disable audio for SimpleApplication
Help With OptionsMenu NiftyGUI
How to stop an animation to start other
Map size and Light source
Nifty UI Custom listbox items could be selected only by clicking in empty item area
App.start error
JME3.1 - Rendering failure specifically for android 7 (Nougat)
PR for Plane
ArrayIndexOutOfBounceException while loading mesh.xml file
SkyFactory: not displaying skyBox
Need advice: Textfield, incorrect cursor position with different font
VoxelEngine Questions
Play video on JMonkeyEngine
Trouble with mouse picking certain models[Solved]
[SOLVED] Having BetterCharacterControl control move in the direction of the camera, at a constant speed
[SOLVED] J3o model mesh geometry
[SOLVED] Where to put inputManager.setCursorVisible(true);?
[SOLVED] Create objects at random position without overlap in jmonkey
Using .getWorldTranslation() resets mesh translation [SOLVED]
[SOLVED]Problem with FloatBits overflow over:69.0 (sim-eth-es + bullet)
[SOLVED] Plugins Won't Install on Linux
.obj vs .blend pros and cons
Is there an easier way to copy pasted code on this forum?
Can´t change my screen
[SOLVED] Can't run compiled JAR Java.nullpointerException [jMonkeyEngine SDK 3.1, JDK 8]
Cubes are not displaying correctly and balls dont keep bouncing
[SOLVED] Detaching an AppState inside an AppState
3D Model Scene: Wall obstacles
Nifty Jme downscale image in different resolutions
JME3 Water Effect on arbitrary shapes (polygons) / DIY version :D
I cannot see my sky
Augmented Reality jme on your Pc (or whateva, webcam background anyway)
NiftyGui
How should I start with IOS?
Moving sun code
Official VR module
Making a cube move along an infinity path in loop
Sim-eth-basic on android
How to draw a line
Anyone have a good third person camera?
Spatial disappears when I move it
Spatial disappears when I move it
Need help about low FPS
rootNode doesn't work with Nifty
Paint to texture on Android extremely slow

@nehon you should edit your sample to use ` instead of '.
you can embed ` x3 in ` x3

```<optional language>
//your code here

(for github users, it's the same syntax)
1 Like

Thanks a lot. It’s easier to understand like this.

1 Like

mhhh, i did type 3 backticks…
I didn’t realized they were shown as '.
Thanks for the tips :wink: I edited the post

1 Like

You can scroll the initial view by giving the URL a line number, like so:

https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/helloworld/HelloJME3.java#L30

Additionally, if you don’t want highlight.js but don’t want to indent your text, this works too:

```text
public class Main {}
```

turns into:

public class Main {}
3 Likes

Nice of you to stop by @riking :smile:

Thanks for the tip. Seems it wasn’t prepared for a dark theme though.

2 Likes

hey nice! thanks for the addition

1 Like

Is it just on my side, or is the “github code with line number” unreadable because of the coloring?

Thats the only code block i am having that issue however…

1 Like

Nope it’s not only on your side, I still need to tweak the style of github code blocks so that it fits in our dark theme

2 Likes

Should be better now

2 Likes

good only for github users :thinking:

…or JME forum users. Else I have no idea what you are talking about.