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.

Wheel Graphic

OS

Sponsor

I am writing a time script that has a rotating graphic that represents the time of day. Here is the current sprite I am using:

Code:
class Sprite_Wheel < Sprite
  def initialize
   super()
   self.bitmap = RPG::Cache.picture("Wheel#{$game_time.hour?(12)}")
   self.x = 160
   self.y = 460 - self.bitmap.height
   refresh
  end
  
  def refresh
    self.bitmap.clear
    @hour = $game_time.hour?(12)
    bitmap = RPG::Cache.picture("Wheel#{@hour}")
    self.bitmap.blt(0, 0, bitmap, bitmap.rect)
  end
  
  def update
    super
    refresh if @hour != $game_time.hour?(12)
  end
end

$game_time.hour?(24) returns the current hour on the 24 hour clock. I can also use $game_time.hour?(12), which will only return 1-12. There are only 12 graphics to load.

The problem is, which ever hour I start on doesn't have a graphic. Every time it hits the starting hour (currently 2), the graphic doesn't load. I don't know why, though. I tried a bunch of things, but nothing worked.

Any help is appreciated. Peace.
 
Is it unable to find the file(which causes a crash)?

do this:

p $game_time.hour?(12) and see what it returns.
p "Wheel#{$game_time.hour?(12)}" and see what it returns.

Check if the file even exists in the picture folder.
 

OS

Sponsor

I just tested it, and it reads it fine. I tried during the hour that has no graphic and I got returned 2 and Wheel2, which is the name of the graphic.

EDIT: Guess what? The line "self.bitmap.clear" just had to be deleted. Now it works fine. Peace!
 

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