Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Map-Preview

Hello folks,

Okay, here I go. I am trying, well actually retrying I just lost the code, to make a map preview. This preview is a small viewport of the map where the player is located. Changing the viewport was the easy part. Now I am trying to get the tilemap ox and oy to the right values so the player is displayed in center. Or shoudl I change the $game_map.display_x and _y ?

I don't know anymore.

Meâ„¢
 
I think, you should try something like this :

Code:
$game_player.moveto(x, y)
$game_player.refresh
$game_map.update
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update

but I guess we can't help you much if you don't post your code.
 
The point is, Ive lost the code.

I am ill, not enough energy to actually write it again, sounds pathetic I know, but that is just how it is. I will try to explain this to you guys. The thing you gave me Sewlyn, works when your viewports center is in the center of the screen, but mine is not.

Lets say we have this viewport: Viewport#new(240,300,100,50)
What I am trying, is to display the player in the center. All the events should also be in place, and the map should be able to update. When you change the Game_Map#display variables, it changes back when updating ... (something, can't remember, not home)...

So, again, I want the player showed on the tileset with the events in the right posisiton, where the player is in the exact middle of the viewport.

Meâ„¢

Edit: shoudl I post an image ? not that is helps much...
 
Meâ„¢;146480 said:
Lets say we have this viewport: Viewport.new(320,240,200,200)
What I am trying, is to display the player in the center. All the events should also be in place, and the map should be able to update. When you change the Game_Map#display variables, it changes back when updating ... (something, can't remember, not home)...

well, to center this viewport (320,240,200,200) you take the width and height values and divide them by two I think...
Code:
$game_player.moveto(x, y)
$game_player.refresh
$game_map.update
# so in this case :
@tilemap.ox = $game_map.display_x / 4 [U]+ 100[/U]
@tilemap.oy = $game_map.display_y / 4 [U]+ 100[/U]
@tilemap.update
 
That is what I thought and already tried. I did do that, the events wont move along. (because of Game_Map#display_(x|y) , which get changed back if you set it manually when you update game map)
 
Code:
# In Spriteset_Map, pass the player´s tile X and Y
def center_tilemap(px, py)
  @tilemap.ox = ((px * 32) - (@tilemap.viewport.width / 2 - 16))
  @tilemap.oy = ((py * 32) - (@tilemap.viewport.height / 2 - 16))
end

Well this is a piece of code i wrote for a small utility i did with Tilemaps a while ago. I just adapted it, but i´m not sure if it will work. Here´s the original code:
Code:
Bah, forget it! xD

P.S.: I think i understood your question, i will try that out.
 
Lets say we have this viewport: Viewport#new(240,300,100,50)
What I am trying, is to display the player in the center. All the events should also be in place, and the map should be able to update. When you change the Game_Map#display variables, it changes back when updating ... (something, can't remember, not home)...

So, again, I want the player showed on the tileset with the events in the right posisiton, where the player is in the exact middle of the viewport.

Just a kind of looktrough window.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top