Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1412104 Posts in 69453 Topics- by 58486 Members - Latest Member: holdamech

June 27, 2024, 08:17:30 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)[SOLVED} Any idea how to fix this? (Isometric Grid Zooming)
Pages: [1]
Print
Author Topic: [SOLVED} Any idea how to fix this? (Isometric Grid Zooming)  (Read 2302 times)
bacon
Level 1
*


View Profile
« on: February 27, 2014, 10:29:00 PM »



I can scale my grid,
but I'm having problems adjusting the tiles after the scaling.
I've tried scaling then adjusting position, adjusting right after scaling (on a per tile basis), adjusting right before scaling, etc. Not really sure what else I can try but I'm open to suggestions.

To Note;
I'm using GameMaker, and these are actual bg tiles and not sprites.
view scaling may be the answer here, but I was under the impression the view doesn't scale the tiles and only scales sprites. View scaling would be more efficient obviously, but I'm not sure how to implement it because based off the included GameMaker tutorial it isn't working.


EDIT:
Solved by using views in GameMaker
« Last Edit: March 03, 2014, 04:14:12 PM by bacon » Logged

CANTATA
jgrams
Level 3
***



View Profile
« Reply #1 on: February 28, 2014, 03:26:59 AM »

In that image you're not actually scaling your grid. You're moving it nearer to and farther from the camera, but in an orthographic projection that doesn't cause it to scale...so you don't need to scale the tiles at all.

--Josh
Logged
bacon
Level 1
*


View Profile
« Reply #2 on: February 28, 2014, 08:56:58 AM »

I am scaling the tiles right now though, not moving the camera. MouseWheeling up/down adjusts tile scale only right now, I'm not changing views at all.
Logged

CANTATA
jgrams
Level 3
***



View Profile
« Reply #3 on: February 28, 2014, 11:30:10 AM »

I think we need more information to be able to help you then.

In your animated GIF, the grid is not changing size at all AFAICT. It does appear to be moving slightly along the axis running down and to the right. And the tiles are scaling, obviously. But the spacing between the tiles doesn't appear to be changing in either direction. So I'm not sure what you mean when you say:

I can scale my grid, but I'm having problems adjusting the tiles after the scaling.

Maybe you can describe what you're doing in more detail? I have to admit that I'm not familiar with Game Maker at all, so maybe I'm missing something? Anyone else want to chime in?

--Josh
Logged
bacon
Level 1
*


View Profile
« Reply #4 on: February 28, 2014, 01:48:10 PM »

I'll try to explain out how I'm handling my map and see if that helps.
I have a map holder object, oMapHolder, that contains a ds_grid ("map") of single integer numbers that is taken in by oMapHolder's step function.
I then have another grid that holds the placed tile's index at the corresponding grid location.

Code:
if (map[# 0,0] != noone && beenInitiated == false)
{  
    tileIDGrid = ds_grid_create(gridWidth, gridHeight);
    for (yCordInGrid = 0; yCordInGrid < gridHeight; yCordInGrid++)
    {
        for (xCordInGrid = 0; xCordInGrid < gridWidth; xCordInGrid++)
        {
            ds_grid_set(tileIDGrid, xCordInGrid, yCordInGrid, placeTile(xCordInGrid,yCordInGrid,map[# xCordInGrid,yCordInGrid]));
        }
    }
    beenInitiated = true;
}

This gives me the ability to call on a specific tile that I can visibly see, and edit it accordingly, i.e. if I need to change something at 3,3, I can just use that index in tileIDGrid to directly access that tile.

The problem is arising from when I am trying to zoom (panning works fine).

Here is the zoom function (obviously for zoom out, but all zoom in does is change the scale to += .1)

Code:
case zoomOut:
    {
        with (oMapHolder)
        {
            tileScale -= .1;
            for (var yIndex = 0; yIndex < gridWidth; yIndex++;)
            {
                for (var xIndex = 0; xIndex < gridWidth; xIndex++;)
                {
                    var tile = tileIDGrid[# xIndex,yIndex];


                    //the 5's here are totally arbitrary. I also tried multiplying them by the scale btu produces the same result)
                    if(xIndex>0 && xIndex>=yIndex){tile_set_position(tile, tile_get_x(tile) - 5, tile_get_y(tile) - 5);} //adjust right of origin tiles for zoom
                    if(yIndex>0 && yIndex>=xIndex){tile_set_position(tile, tile_get_x(tile) + 5, tile_get_y(tile) - 5);} //adjust left of origin tiles for zoom
                    if(yIndex == xIndex){tile_set_position(tile, tile_get_x(tile), tile_get_y(tile) - 5);} //adjust left of origin tiles for zoom
                    
                }
            }
            for (var yIndex = 0; yIndex < gridWidth; yIndex++;)
            {
                for (var xIndex = 0; xIndex < gridWidth; xIndex++;)
                {
                    var tile = tileIDGrid[# xIndex,yIndex];
                    
                    tile_set_scale(tile, tileScale, tileScale);
                }
            }
            
        }
    }

What I was trying to do was going off the assumption that I needed to change the location of the tiles after they had all been scaled, but what I am getting instead is this:



I totally recognize that I also may be approaching this the total wrong way, so if anyone wants to show me the error of my ways I'd be greatly appreciative.

Hope this helps!

PS, the grid coordinates by the cursor are reacting to a collision grid mapped to the tiles. Fixing this is a whole different issue, as now I'm just trying to focus on what is actually seen.
« Last Edit: February 28, 2014, 01:58:05 PM by bacon » Logged

CANTATA
mokesmoe
Level 10
*****



View Profile WWW
« Reply #5 on: February 28, 2014, 02:18:34 PM »

View scaling would work just fine. Tiles are the same as sprites, they just don't have an object attached.

Make sure you have the view enabled in the room ("Enable the use of Views" and "Visible when room starts")

Use view_xview/view_yview to change the position of the view in the room and view_[w/h]view for the size.
Logged
surt
Level 7
**


Meat by-product.


View Profile
« Reply #6 on: February 28, 2014, 02:23:46 PM »

I know precisely zero about game maker but I don't see any actual scaling (multiplication) going on.
It looks like you are just shifting (addition) the tile positions:
Code:
tile_set_position(tile, tile_get_x(tile) - 5, tile_get_y(tile) - 5);} //adjust right of origin tiles for zoom
Something like:
Code:
tile_set_position(tile, tile_get_x(tile) * zoomFactor, tile_get_y(tile) * zoomFactor)
Logged

Real life would be so much better with permadeath.
PJ Gallery - OGA Gallery - CC0 Scraps
bacon
Level 1
*


View Profile
« Reply #7 on: February 28, 2014, 09:23:44 PM »

View scaling would work just fine. Tiles are the same as sprites, they just don't have an object attached.

Make sure you have the view enabled in the room ("Enable the use of Views" and "Visible when room starts")

Use view_xview/view_yview to change the position of the view in the room and view_[w/h]view for the size.

This is exactly the gap of information that I was missing - that tiles are the same as sprites, but just lack an attached object. Once I set the view settings correctly for zooming it all worked. Thanks!

I know precisely zero about game maker but I don't see any actual scaling (multiplication) going on.
It looks like you are just shifting (addition) the tile positions:
Code:
tile_set_position(tile, tile_get_x(tile) - 5, tile_get_y(tile) - 5);} //adjust right of origin tiles for zoom
Something like:
Code:
tile_set_position(tile, tile_get_x(tile) * zoomFactor, tile_get_y(tile) * zoomFactor)

The code was scaling further down via the function tile_set_scale.
Logged

CANTATA
mokesmoe
Level 10
*****



View Profile WWW
« Reply #8 on: March 01, 2014, 09:08:35 AM »

I know precisely zero about game maker but I don't see any actual scaling (multiplication) going on.
It looks like you are just shifting (addition) the tile positions:

The code was scaling further down via the function tile_set_scale.

tile_set_scale only changes the size of the tiles, the position of the tiles would need to scale at the same rate.

Glad you got the views working though!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic