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.

Journal pictures

I made an add-on to a journal script I was using so it will display a picture for each quest that's in the journal. However, if I leave the game running for a few minutes, the game will crash and say 'failed to create bitmap.' Here is the code for the picture part of the journal:

Code:
#==============================================================================
# ** Journal
#------------------------------------------------------------------------------
#  This window displays a journal.
#==============================================================================

class Window_JournalRight < Window_Base
# ------------------------

attr_accessor :index
attr_accessor :quest_size

def initialize
  
   # Offset - enter the offset to the first variable you are using
   # This is one less than the variable number.
   
   @offset = 0
   
   @questpic = []
   @questpic[0] = '/journal/quest_default.png'
   @questpic[1] = '/journal/farm.png'
   @questpic[2] = '/journal/farm2.png'
   @questpic[3] = '/journal/farm3.png'
   
   super(0, 32, 460, 640) 
 
   @index = 0 
   @quest_size = @questpic.size

         @testpic = RPG::Sprite.new 
  
   refresh

 end


#--------------------------------------------------------------------------
# * Draw the contents of the item window
#--------------------------------------------------------------------------

  def refresh
     
 #        @testpic.visible = false
#    self.contents.clear
    
    for i in @index..@questpic.size - 1
      if $game_variables[i + @offset] > 0
        
        
     @testpic.bitmap = Bitmap.new("Graphics/Pictures" + @questpic[i])
     @testpic.x = 350
     @testpic.visible = true
        
        @index = i
        break
      end
    end  
    if @index == 0
      
     @testpic.bitmap = Bitmap.new("Graphics/Pictures" + @questpic[0])
     @testpic.x = 350
     @testpic.visible = true

    end
  end
end


end

If I try to clear the sprite (where I commented out  # @testpic.visible = false and #self.contents.clear) then the image won't show up at all. So I don't know if clearing the sprite everytime it refreshes has something to do with the game crashing if it stays on that journal screen with the pictures for a long time or not. I'm not sure what else I can do to keep the pictures form overloading like that...
 

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