Bounce problem with the left mouse button ??? !!!

luxo-JR

Member
Hello, I have a problem with the management of the mouse and more particularly with the left button (movement to the right of my object).
I am using the 'left released' event.
I have the feeling that there is a rebound effect, the value goes from 55 (test value) to a value of 63 at once (a mouse click).
I tracked with show_debug_message (locx); the variable to follow 'locx'.
I use the same principle for the opposite move (to the left) and everything is fine, same mouse event.
An idea ?
Thank you.
Jean-François
 

luxo-JR

Member
Hello? It is not a question of sprite ... I am working on the adaptation of a landscape generator (C language to GML).
I have a set of 8 arrows (north, south, east, west, northeast, etc.).
The problem arises in calculating the index of the position in the array that contains the map information.
I have already coded the north and west directions, but for the east direction I have the feeling of a bounce from the click (left button) of the mouse, after a few clicks it changes to a value that puts me in error ???
 

TheouAegis

Member
You should post relevant code. Are you snapping positions to a grid or something? Because 63 would be one pixel off from a power of 2 grid. You said this is a conversion from another project, are you using the round() function and getting different results from the function than you were getting in C?
 

luxo-JR

Member
Hello, It is not a calculation of pixels but the calculation of an index of an array. I have a structure table (66 columns x 63 rows) which contains two pieces of information, first the code of the object I need to draw and then the name of that same object; what is important is the code. I store my map in this table ... For the movement on this map, I have arrows (sprites) which are sensitive to the mouse (click left button) and this is where I think there are a rebound problem ... the problem is on the locx and locy variables.

GML:
function DrawLocation(){
 var distance = argument0;
 var xtype = argument1;
 var ytype = argument2;
 var scrtype = argument3;

var locx;
var locy;
var xx;
var g_Feature;

// work out the real y coordinate
    locy = AdjustMapPos ( global.Y_CurrentLocation,
                          ytype,
                          global.landscape[distance].dx,
                          global.landscape[distance].dy );
                          /* Nord */
                          if (locy < 0)
                          {
                              locy = 0;
                          }
                          /* Sud */
                          if (locy > global.Map_Grid_Nb_Lig)
                          {
                              locy = global.Map_Grid_Nb_Lig - 1;
                          }

// work out the real x coordinate
    locx = AdjustMapPos ( global.X_CurrentLocation,
                          xtype,
                          global.landscape[distance].dx,
                          global.landscape[distance].dy );
                          /* Ouest */
                          if (locx < 0)
                          {
                              locx = 0;
                          }
                          /* Est */
                         if (locx > global.Map_Grid_Nb_Col)
                          {
                              locx = global.Map_Grid_Nb_Col - 1;
                          }

// actually get the location data
    //GetLocation ( locx, locy ) ;
    
    //show_message("> locx : " + string(locx) + " ! locy : " + string(locy));
    show_debug_message(locx);
    //init-01-g_Feature = global.Map_Grid[locy][locx].Map_Location_Code;
g_Feature = global.Map_Grid[locy][locx].Map_Location_Code;
    //show_message("> g_Feature : " + string(g_Feature));
// work out where on screen, x coordinate this item should be
    xx = 320;
    switch ( scrtype ) {
        case 0: xx += global.landscape[distance].xadj ;                break;
        case 1: xx -= global.landscape[distance].xadj ;                   break;
        case 2: xx = (xx + global.landscape[distance].xadj) - 100 ;    break;
        case 3: xx = (xx - global.landscape[distance].xadj) + 100 ;    break;
    }

// and draw it
    /*g_Feature = 1;*/
    DrawFeature ( g_Feature,
                  xx,
                  //global.landscape[distance].y,
                  global.landscape[distance].dy,
                  global.landscape[distance].size );

}
 

luxo-JR

Member
This is the 'AdjustMapPos' function :

GML:
function AdjustMapPos(){
    var pos = argument0;
    var type = argument1;
    var dx = argument2;
    var dy = argument3;
    switch ( type ) {
        case 0: pos = pos + dy; break;
        case 1: pos = pos - dy; break;
        case 2: pos = pos + dx; break;
        case 3: pos = pos - dx; break;
    }
    return pos ;
}
 
Top