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.

Image Not Displaying

I have written a script with a bit of help, but when I attempt to run it, all that happens is that a black screen appears, and you can't even exit out of it until you have waited a few seconds and pressed 'X'.

I think that there is a bit of the script that is not letting the image show, but the script runs on two things; one thing in the menu, and another that powers the window. Here are the two bits of script:

Menu script:
Code:
  elsif cmdBadges>=0 && command==cmdBadges
    scene=PokemonBadgesScene.new
    screen=PokemonBadges.new(scene)
    pbFadeOutIn(99999) {
      screen.pbStartScreen
      @scene.pbRefresh
      }

Window powering and calculating script:
Code:
class PokemonBadgesScene
  
def pbBadges
  loop do
    Graphics.update
    Input.update
    self.update
    if Input.trigger?(Input::B)
      break
    end
    if Input.trigger?(Input::C)
      break
    end
  end
end

def pbEndScene
  # Fade out all sprites
  pbFadeOutAndHide(@sprites)
  # Dispose all sprites
  pbDisposeSpriteHash(@sprites)
end

def pbStartScene
  # Create sprite hash
  @sprites={}
  # Allocate viewport
  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  @viewport.z=99999
  # Create badge window
  # Refer it to it using: @sprites["badge_window"]
  @sprites["badge_window"] = SpriteWindow_Base.new(0, 0,
  Graphics.width,Graphics.height)
  @sprites["badge_window"].contents = Bitmap.new(Graphics.width, Graphics.height)
  pbBadgeCase
end

def pbBadgeCase
  x, y = 0, 0
  for i in 0...8
    if i / 4 >= 1
      x = 0
      y += 480 / 2
    end

  if $Trainer.badges[i]
    badge_image = Bitmap.new('Graphics/Pictures/dpbadges.PNG')
    @sprites["badge_window"].contents.blt(x, y, badge_image, badge_image.rect)
  end

  x += 640 / 4
  # Fade in all sprites
  pbFadeInAndShow(@sprites)
    end
  end
end

class PokemonBadges

def initialize(scene)
  @scene = scene
end

def pbStartScreen
  @scene.pbStartScene
  @scene.pbBadges
  @scene.pbEndScene
end
end

Thanks for your help, guys.
 

khmp

Sponsor

Every time I glance at that code I immediately think of "punk buster", anti-cheat client. There's a couple problems and the main one might be that whatever "pbFadeOutIn(99999)" is doing is occurring when the scene global isn't switched. "$scene" is the global variable storing the current scene that is running. You are never changing it. You created a local variable "scene" which is different than "$scene". And why do you have it so the PokemonBadges takes in the scene object? It can already access the scene through global scope "$scene".

Scene objects need a "main" method unless you changed the way the program runs scenes. You created a method called "pbBadges" which seems to do the work of "main" and "update". But the scene will not be able to start if that method is never called. You also need a way to lead into a Scene with a Graphics.transition and lead out with a Graphics.freeze. Otherwise you won't break the Graphics.freeze of the previous scene.

And you also make use of a lot of methods I'm unfamiliar with. Are you using the Pokemon starter kit? What are all the "pb" methods?

Could you describe what exactly is meant to happen when you enter this scene. I think you are complicating things.
 

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