Rendering Functions

1.Quick Glance

Game worlds are all “rendered” from code onto the screen. Here is a list of all of the current function you can use to render things like images, animations, lines and shapes onto the screen with ease.

2.Rendering Functions

void GPE.render_circle( float x, float y, float radius, Color circleColor, bool isOutline, float oulineWidth, bool renderImmediately)

Renders a circle with (x,y,r)  and renders immediately or is placed in the shape rendering queue in the frame.

Scope: GPE

Return type : void

Parameters:

  • float x – the x-coordinate to center the circle around
  • float y- the y-coordinate to center the circle around
  • float radius – the radius of the circle to render
  • Color circleColor- the RGB or Hex color of the circle to draw.
  • bool isOuline – set to true if an outline or false to fill the circle on the screen
  • float outlineWidth – the width of the outline if isOutline is set to true
  • bool renderImmediately – set true to draw when called or false to add to render pipeline. Defaults to false

 

void GPE.render_line( float x1, float y1, float x2, float y2, Color lineColor, float lineWidth, bool renderImmediately)

Renders a line from (x1,y1) to (x2,y2)  with lineColor and lineWidth and renders immediately or is placed in the shape rendering queue in the frame.

Scope: GPE

Return type : void

Parameters:

  • float x1  -the first x-coordinate of the line.
  • float y1 – the first y-coordinate of the line.
  • float x2  -the second x-coordinate of the line.
  • float y2 – the second y-coordinate of the line.
  • Color lineColor- the RGB or Hex color of the line to draw.
  • float lineWidth- the width of the line. Defaults to 1.
  • bool renderImmediately – set true to draw when called or false to add to render pipeline. Defaults to false

 

void GPE.render_rectangle( float x1, float y1, float x2, float y2, Color rectColor,bool isOutLine, float lineWidth, bool renderImmediately)

Renders a rectangle with rectColor, outline(boolean) with rectLineWidth(pixel outline size)  and renders immediately or is placed in the shape rendering queue in the frame.

Scope: GPE

Return type : void

Parameters:

  • float x1  -the first x-coordinate of the rectangle.
  • float y1 – the first y-coordinate of the rectangle.
  • float x2  -the second x-coordinate of the rectangle.
  • float y2 – the second y-coordinate of the rectangle.
  • Color rectColor- the RGB or Hex color of the rectangle to draw.
  • bool isOutLine – set true to draw an outlined rectangle, false to render whole shape. Defaults to false.
  • float lineWidth- the width of the lines if isOutline is set to true. Defaults to 1.
  • bool renderImmediately – set true to draw when called or false to add to render pipeline. Defaults to false.

 

void GPE.render_sprite( int spriteIdIn, int frameNumb, int xOn, int yOn, float scaleX, float scaleY)

Retrieves the width of a sprite whose id is spriteId.  Returns 0 by default

Scope: GPE

Return type : void

Parameters:

  • int spriteId– an integer of a sprite(aka spr_player_walk). If undefined, null or non-number based this function returns 0.
  • int frameNumb – the frame number of the animation to render.
  • int xOn – the x-coordinate relative to the current camera to render the sprite.
  • int yOn – the x-coordinate relative to the current camera to render the sprite
  • float scaleX – Used to scale the current frame on the x-axis. Defaults to 1.
  • float scaleY – Used to scale the current frame on the y-axis. Defaults to 1.

 

void GPE.render_sprite_rotated( int spriteIdIn, int frameNumb, int xOn, int yOn, Degree rotation, float scaleX, float scaleY)

Retrieves the width of a sprite whose id is spriteId.  Returns 0 by default

Scope: GPE

Return type : void

Parameters:

  • int spriteId– an integer of a sprite(aka spr_player_walk). If undefined, null or non-number based this function returns 0.
  • int frameNumb – the frame number of the animation to render.
  • int xOn – the x-coordinate relative to the current camera to render the sprite.
  • int yOn – the x-coordinate relative to the current camera to render the sprite
  • Degree rotation – the angle in which to render the sprite(in degrees ). Use gpe.degree() to convert radians to degrees for this function if needed.
  • float scaleX – Used to scale the current frame on the x-axis. Defaults to 1.
  • float scaleY – Used to scale the current frame on the y-axis. Defaults to 1.

 

 

void GPE.render_square( int xOn, int yOn, float squareSize, Color squareColor, bool isOutline, float squareLineWidth, bool renderImmediately )

Renders a square at (x, y) with its sides equalling squareSize.

Scope: GPE

Return type : void

Parameters:

  • int xOn – the x-coordinate relative to the current camera to render the sprite.
  • int yOn – the x-coordinate relative to the current camera to render the sprite
  • float squareSize – the size of the square in pixels.
  • Color squareColor – the color of the square in Hex or rgb.
  • bool isOutline – set true to draw the square as an outline. Defaults to false.
  • bool renderImmediately – set true to add this render call to the render pipeline. Defaults to false.

 

void GPE.render_text(int fontId, int xOn, int yOn, String textToRender, Color fontRenderColor, int fontHalign, int fontValign)

Retrieves Renders a text using the assigned font resource.

Scope: GPE

Return type : void

Parameters:

  • int fontId– an integer of a FONT(aka fnt_menu). If undefined, null or non-number based this function used 20px Arial FONT.
  • int xOn – the x-coordinate to render the text.
  • int yOn – the y-coordinate to render the text.
  • String textToRender – the string of characters to render. If empty the function does nothing.
  • Color fontRenderColor – an RGB or Hex color. i.e: “rgba( 255,255,255) or #FFF.
  • int fontHalign-  Left- fa_left, Center – fa_center, Right – fa_right. Defaults to fa_left;
  • int fontValign-  Top- fa_top, Middle – fa_middle, Bottom – fa_bottom. Defaults to fa_top;

 

void GPE.render_texture( int texureIdIn, int  xDraw, int yDraw)

Renders a given texture at (xDraw, yDraw)

Scope: GPE

Return type : void

Parameters:

  • int textureId – an interger of a texture(aka tex_grass). If undefined, null or non-number based this function this function does nothing.
  • int xDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.
  • int yDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.

 

void  GPE.render_texture_scaled( int texureIdIn,  int xDraw,  int yDraw,  int width, int height)

Renders a given texture at (xDraw, yDraw) scaled to a new width and height

Scope: GPE

Return type : void

Parameters:

  • int textureId – an interger of a texture(aka tex_grass). If undefined, null or non-number based this function this function does nothing.
  • xDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.
  • yDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.
  • width – the new width to resize the texture to on render.
  • height – the new height to resize the texture to on render.

 

void GPE.render_texture_clipped(int texureIdIn,  int xDraw, int yDraw,  GPERect clipBox)

Renders a given texture at (xDraw, yDraw)

Scope: GPE

Return type : void

Parameters:

  • int textureId – an interger of a texture(aka tex_grass). If undefined, null or non-number based this function this function does nothing.
  • int xDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.int
  • int yDraw – The x-coordinate of where to draw the texture on the screen relative to the game’s camera.
  • GPERect clipBox – a GPE Rectangle of where to draw only  a section of the texture(similar to drawing a sprite frame or a tile from a tilesheet image).

 

void GPE.render_triangle( int spriteIdIn, int frameNumb, int xOn, int yOn, Degree rotation, float scaleX, float scaleY)

Retrieves the width of a sprite whose id is spriteId.  Returns 0 by default

Scope: GPE

Return type : void

Parameters:

  • int spriteId– an integer of a sprite(aka spr_player_walk). If undefined, null or non-number based this function returns 0.
  • int frameNumb – the frame number of the animation to render.
  • int xOn – the x-coordinate relative to the current camera to render the sprite.
  • int yOn – the x-coordinate relative to the current camera to render the sprite
  • Degree rotation – the angle in which to render the sprite(in degrees ). Use gpe.degree() to convert radians to degrees for this function if needed.
  • float scaleX – Used to scale the current frame on the x-axis. Defaults to 1.
  • float scaleY – Used to scale the current frame on the y-axis. Defaults to 1.

 

void GPE.render_wrapped_text(int fontId, int xOn, int yOn, String textToRender, Color fontRenderColor, maxWidth, lineHeight)

Retrieves Renders a text using the assigned font resource over multiple lines(similar to a paragraph.

Scope: GPE

Return type : void

Parameters:

  • int fontId– an integer of a FONT(aka fnt_menu). If undefined, null or non-number based this function used 20px Arial FONT.
  • int xOn – the x-coordinate to render the text.
  • int yOn – the y-coordinate to render the text.
  • String textToRender – the string of characters to render. If empty the function does nothing.
  • Color fontRenderColor – an RGB or Hex color. i.e: “rgba( 255,255,255) or #FFF.
  • int maxWidth –  The max-width of each-line within the wrapped text area.
  • int lineHeight-  The vertical difference between each line within the wrapped text. This equates generally to the font-height plus any padding you choose.

 

void GPE.set_render_alpha( int newAlphaValue)

Sets the default alpha to render all content with. The game defaults to 255. The lower the number the more transparent the image is with 0 representing it being completely invisible.

Scope: GPE

Return type : void

Parameters:

  • int newAlphaValue– an alpha value between 0 and 255.

Suggest Edit