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.

[VX] How to tile things horizontally

ikos

Member

Hey, all. It's been some time. Alright; here it goes!

I have this script that tells the player various things in the menu. They're tiled vertically

"1
2
3"

The thing is though, I would really like them to be tiled horizontally. "1 2 3" Do you all think you could help?

Code:
module DarkOdyssey
  MenuVIcons = [131,147,188]
  MenuVTexts = ['$game_variables[999].to_s','$game_party.gold','time']
end

class Window_DOMenuVar < Window_Base
  def initialize(x, y)
    super(x, y - 0, 160, WLH * DarkOdyssey::MenuVIcons.size + 32)
    refresh

  end

  def time
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    if hour >= 1
      return sprintf("%01d:%02d:%02d", hour, min, sec)
    else
      return sprintf("%01d:%02d", min, sec)
    end
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.windowskin = Cache.system('window')
    y = 0
    for i in 0...DarkOdyssey::MenuVIcons.size
      self.contents.draw_text(0, y, 128, WLH, eval(DarkOdyssey::MenuVTexts[i]), 2)
      draw_icon(DarkOdyssey::MenuVIcons[i], 0, y)
      y += WLH
    end
  end
  
  def update
    super
    refresh if Graphics.frame_count / Graphics.frame_rate != @total_sec
  end
end

class Scene_Menu
  alias darkodyssey_menuvariables_start start
  def start
    darkodyssey_menuvariables_start
    @gold_window.dispose
    @gold_window = Window_DOMenuVar.new(0,384 - 24 * DarkOdyssey::MenuVIcons.size)
  end
  
  alias darkodyssey_menuvariables_update update
  def update
    darkodyssey_menuvariables_update
    @gold_window.update
  end
end
 
in this line
Code:
self.contents.draw_text(0, y, 128, WLH, eval(DarkOdyssey::MenuVTexts[i]), 2)
in the part with (0, y, 128... exchange 0 and y. Things should now be aligned horizontally, but you will probably need to add a value to "y" depending on the item being drawn if it's width differs from the other items.
 

ikos

Member

Dargor":1ujnf31w said:
in this line
Code:
self.contents.draw_text(0, y, 128, WLH, eval(DarkOdyssey::MenuVTexts[i]), 2)
in the part with (0, y, 128... exchange 0 and y. Things should now be aligned horizontally, but you will probably need to add a value to "y" depending on the item being drawn if it's width differs from the other items.

When I do that (I've done x,0 , y,0, and even added values) I just get all of the textual values in the same location. So it's just a blur of numbers. :\
 
it should look like:
y = 0
for i in 0...DarkOdyssey::MenuVIcons.size
wx = 0
case i
when 0
wx = 10
when 1
wx = 40
end

self.contents.draw_text(y + wx, 0, 128, WLH, eval(DarkOdyssey::MenuVTexts), 2)
draw_icon(DarkOdyssey::MenuVIcons, 0, y)
y += WLH
end


wx is the added value based on the item you draw.
 

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