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.

emm... a bit stupid question... but i really don't remember it O.O

WiZ`

Member

this is the question... i've to make appear a window and an immage in the game map when a variable calle $juke is true... i've tried like this in the def main of the class scene_map
Code:
    if $juke == true
      # Sfondo Lettore MP3
      @jukeback = Sprite.new
      @jukeback.bitmap = RPG::Cache.windowskin("006-JukeBox.PNG")
      @jukeback.x = 30
      @jukeback.y = 30
      # Window dati brano suonato
      @jukebox_window = Window_JukeBox.new
      @jukebox_window.opacity = 0
      @jukebox_window.x = 30
      @jukebox_window.y = 10
    end
but it doesn't work
i've also put an update and a dispose, when i've found the other one... but i don't see any sprite or window when i do like that :\ could you help me pls? ^^

EDIT: i've forgot this other script XD Window_JukeBox
Code:
class Window_JukeBox < Window_Base

  def initialize
    super(320, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def refresh
    self.contents.clear
    if $song_name != nil
      self.contents.font.color = text_color(10)
      self.contents.draw_text(0, 0, self.width - 40, 32, $song_name, 1)
    else
      self.contents.draw_text(0, 0, self.width - 40, 32, "...", 1)
    end
  end
end
i don't know... but maybe it could come in hand :)
 

khmp

Sponsor

It is not a stupid question so don't think that WiZ`. To start though I am really confused on what your end goal is. Do you want a window to show with a special windowskin that acts like a jukebox? And with it but separate from the window an image file? Could you draw a simple picture in paint and post it so me and others that want to help you know what you want?

PS: Thanks for the sig thing!  ;D
 

WiZ`

Member

ok... i need to explain it better :p
then...

this is the image, i need to put it in the upper-left corner of the screen, http://img221.imageshack.us/img221/7062/006jukeboxai3.th.png[/img] over it i need to put a window whit the name of the played song (i've all the script, it's completed, there are no problem about it)...
i need this window and image to act just like the character the tileset and the panorama on the map: when you enter menù or save or shop etc. the image and the window will disappear, and they'll come back when you re-enter in the scene_map

i hope you all could understand what i need ^^
 
False and nil evaluates as a logical false, any other thing evaluates as logical true.

This should make the work:
Code:
class Scene_Map
  alias old_main main
  def main
    if $juke
      # Sfondo Lettore MP3
      @jukeback = Sprite.new
      @jukeback.bitmap = RPG::Cache.windowskin("006-JukeBox.PNG")
      @jukeback.x = 30
      @jukeback.y = 30
      # Window dati brano suonato
      @jukebox_window = Window_JukeBox.new
      @jukebox_window.opacity = 0
      @jukebox_window.x = 30
      @jukebox_window.y = 10
    end
    old_main
    
    #... Oh, don´t forget to update those objects if needed, huh?
  end
end
Also, i discourage the use of global variables. Can´t you store this flag elsewhere? Like in Game_Temp, or Game_System for example?

EDIT: Oh, now i think i understood what you were trying to do. Why don´t you try this?
Code:
class Game_Temp
  alias old_initialize initialize
  attr_accessor :juke
  attr_accessor :song_name
  def initialize
    @juke = false
    @song_name = ""
  end
end

class Scene_Map
  alias old_main main
  def main
    # Sfondo Lettore MP3
    @jukeback = Sprite.new
    @jukeback.bitmap = RPG::Cache.windowskin("006-JukeBox.PNG")
    @jukeback.x = 30
    @jukeback.y = 30
    # Window dati brano suonato
    @jukebox_window = Window_JukeBox.new
    @jukebox_window.opacity = 0
    @jukebox_window.x = 30
    @jukebox_window.y = 10
    old_main
    @jukeback.dispose
    @jukebox_window.dispose
  end
  
  alias old_update update
  def update
    old_update
    if $game_temp.juke
      @jukeback.visible = true
      @jukebox_window.visible = true
    else
      @jukeback.visible = false
      @jukebox_window.visible = false
    end
    @jukeback.update
    @jukebox_window.update
  end
end

class Window_JukeBox < Window_Base

  def initialize
    super(320, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def refresh
    self.contents.clear
    if $game_temp.song_name != nil
      self.contents.font.color = text_color(10)
      self.contents.draw_text(0, 0, self.width - 40, 32, $game_temp.song_name, 1)
    else
      self.contents.draw_text(0, 0, self.width - 40, 32, "...", 1)
    end
  end
  
  def update
    super
    if @last_name != $game_temp.song_name
      @last_name = $game_temp.song_name
      refresh
    end
  end
end
Haven´t tested, but this should work.
 
Oh sorry i forgot to dispose the window and the sprite xD

Please re-check the code, i corrected it. Notice that this is MY suggestion too, i´m not using $juke and $song_name, but yet $game_temp.juke and $game_temp.song_name.

BTW, in your code, does it appear anything? Or, are you sure you´re setting that flag to true?

EDIT: DAMN F*** INTERNET SORRY SEPH!!! >.<
 

khmp

Sponsor

ZOMG Linkin_T you totally knifed me.  ;D

Code:
class Window_JukeBox < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 219 + 32, 38 + 32)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if $song_name != nil
      self.contents.font.color = text_color(10)
      self.contents.draw_text(0, 0, self.width - 40, 32, $song_name, 1)
    else
      self.contents.draw_text(0, 0, self.width - 40, 32, '...', 1)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #-------------------------------------------------------------------------- 
  def update
    if $song_name != @song_name
      @song_name = $song_name
      refresh
    end
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  # Alias some methods.
  alias_method :wiz_jukebox_main, :main
  alias_method :wiz_jukebox_update, :update
  # Constants
  JUKEBOX_IMAGE = '006jukeboxai3.png'
  JUKEBOX_X = 0
  JUKEBOX_Y = 0
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create the sprite.
    @jukebox = Sprite.new
    @jukebox.bitmap = RPG::Cache.picture(JUKEBOX_IMAGE)
    @jukebox.x = JUKEBOX_X
    @jukebox.y = JUKEBOX_X
    @jukebox.z = 9998
    @jukebox.visible = false
    # Create the window.
    @jukebox_window = Window_JukeBox.new
    @jukebox_window.x = JUKEBOX_X - 4
    @jukebox_window.y = JUKEBOX_Y - 12
    @jukebox_window.z = 9999
    @jukebox_window.opacity = 0
    @jukebox_window.visible = false
    
    wiz_jukebox_main
    
    # Dispose of the window.
    @jukebox_window.dispose
    # Dispose of the sprite.
    @jukebox.bitmap.dispose
    @jukebox.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if $juke
      @jukebox.visible = true
      @jukebox_window.visible = true
      @jukebox_window.update
    else
      @jukebox.visible = false
      @jukebox_window.visible = false
    end
    wiz_jukebox_update
  end
end
 

khmp

Sponsor

S'alright I took too long testing it to reply before you. Originally I was trying to just draw_text on the bitmap so there wouldn't be a need for a window. It didn't work out too well. :P
 

WiZ`

Member

anyway... i can't make it work also whit your version... i really don't know what's wrong whit this script... it seams to be simple... but i don't know how to make it work :\
 

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