Hola amigos hace tiempo que no hago una consulta por aca pero la verdad es que estoy armando un juego de puzzle de 3x3 y la verdad que anda perfecto pero necesito modificar la ubicacion del rompecabezas en otra posicion, osea se encuentra ubicada en la posicion 0,0 y necesito que se ubica en x=0; y=192; no se si me explico el codigo que tengo para crear el rompecabezas atravez de un background (tiles) en el evento create es:
var i, temp;
//Specify how many pieces across the puzzle will be
size = 3;
//Find the dimensions of the pieces
tile = background_get_width(0) div size;
//Create a grid structure to hold the solution
solve = ds_grid_create(size,size);
//Create a grid structure to hold the board
board = ds_grid_create(size,size);
//Create the pieces and add them to the list
for(i=0; i<sqr(size); i+=1)
{
temp = tile_add(0, tile * (i mod 3), tile * (i div 3), tile, tile, tile * (i mod 3), tile * (i div 3), 0);
ds_grid_add(solve, i mod 3, i div 3, temp);
ds_grid_add(board, i mod 3, i div 3, temp);
}
//Remove one corner piece from the puzzle
var xx, yy;
xx = choose(0,size-1);
yy = choose(0,size-1);
tile_delete(ds_grid_get(solve, xx, yy));
ds_grid_set(solve, xx, yy, -1);
ds_grid_set(board, xx, yy, -1);
//Shuffle the pieces
ds_grid_shuffle(board);
//Shuffle the pieces on the board
for(yy=0; yy<size; yy+=1)
for(xx=0; xx<size; xx+=1)
if ds_grid_get(board,xx,yy)
tile_set_position(ds_grid_get(board,xx,yy), tile * xx, tile * yy);
y el codigo que uso para verificar los movimiento y demas del rompecabezas en el evento de pulsacion del mouse es:
if score exit;
if alarm[0] exit;
//Find the tile under the mouse...
var piece;
xx = mouse_x div tile;
yy = mouse_y div tile;
piece = ds_grid_get(board, xx, yy);
if !piece exit;
//Find location of the blank spot
var blank;
blank[0] = ds_grid_value_x(board,0,0,size,size,-1)
blank[1] = ds_grid_value_y(board,blank[0],0,blank[0],size,-1)
//Swap tiles if they're next to each other
if abs(blank[0]-xx)+abs(blank[1]-yy)==1
{
ds_grid_set(board, xx, yy, -1);
ds_grid_set(board, blank[0], blank[1], piece);
tile_set_position(piece, blank[0] * tile, blank[1] * tile);
}
//Compare the board to the solution
for(yy=0; yy<size; yy+=1)
for(xx=0; xx<size; xx+=1)
if ds_grid_get(board,xx,yy) != ds_grid_get(solve,xx,yy)
break;
else
if xx == size-1
if yy == size-1
alarm[0] = 15;
en fin funciona bien arriba del room como esta ubicado pero necesito que funcione mas abajo y no se bien que codigo modificar dado que este codigo no es mio y no tengo tiempo como para ponerme a reescrivir el codigo, adjunto un editable. si me ayudan les voy a agradecer.-
Nunca he usado grids, pero me parece que es En el primer código, hasta el final:
//Shuffle the pieces on the board
for(yy=0; yy<size; yy+=1)
for(xx=0; xx<size; xx+=1)
if ds_grid_get(board,xx,yy)
tile_set_position(ds_grid_get(board,xx,yy), tile * xx, tile * yy);
Modificando yy = 192. O eso creo :-[
Gracias, Penumbra pero he probado eso y nada no se si a alguien se le ocurre algun metodo mas simple o algo para mejorar o asimilarse al funcionamiento del editable que adjunte le agradesco ya que lo necesito para terminar un game que me encargaron, pero bueno sino voy a tener que reescribir el codigo de cero, creo que deberia crear una grid de 3x3 y hacer que los background de 300x300 se dividan en tiles de 100x100 pero no me ubico bien como hacerlo.-
Doy por solucionado este tema otra vez mas gracias a TEXIC. Realmente un groso. se merece todos los elogios.- ;)