Kentae
Member
Hey guys.
So I'm getting this really weird error and I just can't seem to find what's wrong.
Here's the error:
And it happens when I run this code in the step event of my object:
The c_x and c_y variables are just counters that will go up to the same amount that the chunks_x and chunks_y variables are set to.
The chunkquads and quadsize variables are both set in the create event.
I'm trying to create a chunkbased terrain system but for testing purposes I'm just trying to make it as a flat plane for now.
What's weird is that it seems to have a problem with this sentance:
var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
And I just don't get what's wrong with it. It doesn't seem to make any sense what so ever.
I'm using GMS2 for this and I'm quite new to it, I've usually stuck with GMS 1.4 so far but figured I'd try and make the switch now So I'm not discarding the possibilty that I'm just missing something trivial here hehe.
So I'm getting this really weird error and I just can't seem to find what's wrong.
Here's the error:
Code:
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_terrain:
DoMul :: Execution Error
at gml_Object_obj_terrain_Step_0 (line 12) - var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_terrain_Step_0 (line 12)
Code:
// CHUNK GENERATION.
if ( c_x < chunks_x && c_y < chunks_y )
{
var vbuff = vertex_create_buffer();
vertex_begin( vbuff, global.format_default );
for ( i = 0; i < chunkquads; i++; )
{
for ( j = 0; j < chunkquads; j++; )
{
var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
var y1 = ( c_y * ( chunkquads * quadsize ) ) + ( j * quadsize );
var x2 = x1 + quadsize;
var y2 = y1 + quadsize;
var u1 = i / ( chunkquads + 1 );
var v1 = j / ( chunkquads + 1 );
var u2 = ( i + 1 ) / ( chunkquads + 1 );
var v2 = ( j + 1 ) / ( chunkquads + 1 );
vertex_position_3d( vbuff, x1, y1, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u1, v1 );
vertex_position_3d( vbuff, x2, y1, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u2, v1 );
vertex_position_3d( vbuff, x1, y2, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u1, v2 );
vertex_position_3d( vbuff, x1, y2, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u1, v2 );
vertex_position_3d( vbuff, x2, y1, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u2, v1 );
vertex_position_3d( vbuff, x2, y2, 0 );
vertex_normal( vbuff, 0, 0, 1 );
vertex_color( vbuff, c_white, 1 );
vertex_texcoord( vbuff, u2, v2 );
}
}
vertex_end( vbuff );
vertex_freeze( vbuff );
}
The chunkquads and quadsize variables are both set in the create event.
I'm trying to create a chunkbased terrain system but for testing purposes I'm just trying to make it as a flat plane for now.
What's weird is that it seems to have a problem with this sentance:
var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
And I just don't get what's wrong with it. It doesn't seem to make any sense what so ever.
I'm using GMS2 for this and I'm quite new to it, I've usually stuck with GMS 1.4 so far but figured I'd try and make the switch now So I'm not discarding the possibilty that I'm just missing something trivial here hehe.