• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Is it possible to move vertex buffers in a room in GMS2?

acidemic

Member
I am working on the 2D game where I have terrain being drawn using the vertex buffers. So far this was ok until I decided to introduce pieces of terrain with parallax movement. So now I want parallax affected terrain to move relatively to the main player's terrain. Programming parallax logic is not a problem, but i don't know how to draw the vertex buffers in other coordinates rather than where they were created. Is it possible to move vertex buffers around the room in GMS2. I don't need 3D.... just simple 2D.... even not that, just 1D.... :)))) cause I need to move vertex buffer only against the X axis (basically change it's x coordinate).

Found only that GMS 1.x had function d3d_transform_set_translation() which is now obsolete in GMS2.
 

slojanko

Member
You can with matrices: https://forum.yoyogames.com/index.p...arted-with-3d-in-gms2-project-download.12145/
Spoiler #3

Code:
// matrix_build(x, y, z, xrotation, yrotation, zrotation, xscale, yscale, zscale);
var mat = matrix_build(room_width * 0.5, room_height * 0.5, 0, 0, 0, 45, 1, 1, 1);

// Apply matrix to drawing
matrix_set(matrix_world, mat);

// Submit your buffer here
vertex_submit(model, pr_trianglelist, -1);

// Reset matrix
matrix_set(matrix_world, matrix_build_identity());
 

acidemic

Member
You can with matrices: https://forum.yoyogames.com/index.p...arted-with-3d-in-gms2-project-download.12145/
Spoiler #3

Code:
// matrix_build(x, y, z, xrotation, yrotation, zrotation, xscale, yscale, zscale);
var mat = matrix_build(room_width * 0.5, room_height * 0.5, 0, 0, 0, 45, 1, 1, 1);

// Apply matrix to drawing
matrix_set(matrix_world, mat);

// Submit your buffer here
vertex_submit(model, pr_trianglelist, -1);

// Reset matrix
matrix_set(matrix_world, matrix_build_identity());
Thank you! Will try this tomorrow.
 

acidemic

Member
FANTASTIC!!! It works flawlessly.
Worth noting that the code has to be used in Draw event.

I used "xmov" and "ymov" variables which would change only the x and y positions of the object on screen in order to create parallax movement effect. All other arguments are not used.
Code:
// matrix_build(x, y, z, xrotation, yrotation, zrotation, xscale, yscale, zscale);
var mat = matrix_build(xmov, ymov, 0, 0, 0, 0, 1, 1, 1);
matrix_set(matrix_world, mat);
gpu_set_texrepeat(1);
vertex_submit(ter_buffer, pr_trianglelist, ter_texture); // Drawing piece of textured terrain
gpu_set_texrepeat(0);
matrix_set(matrix_world, matrix_build_identity());
 
Last edited:
Top