• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Prize Wheels

Resource Prize Wheels N/A

AiurJordan

twitch.tv/aiurjordan
Member
Joined
Aug 10, 2019
Posts
83
Radius 144

I can't seem to get it to rotate perfectly no matter how hard I try. I think this is more than acceptable though
 

Attachments

  • prizewheel.png
    prizewheel.png
    11.2 KB · Views: 202

AiurJordan

twitch.tv/aiurjordan
Member
Joined
Aug 10, 2019
Posts
83
Last one, sorry to keep hitting you with notifications.
I noticed a small bug while trying to use a second wheel style.
Ruby:
Expand Collapse Copy
#Find
@style=WheelStyles[0]

#Change to
@style=WheelStyles[style]

The way it was written, defaulted to style 0 no matter what you defined in the WheelStyles array or called with Wheel(x,y,style=z)

Here is the Prize array for this wheel, it corresponds to the values exactly, incase anyone wanted a wheel with values printed on it, I went in and did them by hand in aesprite.
Ruby:
Expand Collapse Copy
["100","2500","100","7500","100","10000","100","5000","100","15000"],

If anyone wants COINS instead of money as the cost.

Use a conditional branch before calling Wheel.

Ruby:
Expand Collapse Copy
!$PokemonBag.pbHasItem?(:COINCASE)
\CN\rYou don't have a Coin Case.
Exit Event Processing
else
Wheel(0,0,style=0)

Ruby:
Expand Collapse Copy
      if Input.trigger?(Input::C)
        if @cost>0
          confirmtext="\\CNSpin the wheel for #{@cost} coins? (ESC to quit)"
        else
          confirmtext="\\CNSpin the wheel?"
        end
          if pbConfirmMessage("#{confirmtext}")
            pbSEPlay(@style[4],@style[5],@style[6])
            if $Trainer.coins>=@cost
              $Trainer.coins-=@cost
            else
              pbMessage(_INTL("\\CNYou don't have enough coins..."))
              break
            end
 

Attachments

  • prizewheel2.png
    prizewheel2.png
    14.9 KB · Views: 204
Last edited:
o que fazer?
Hm, that's really strange- it's treating ItemIconSprite like a constant, but I can't see any reason why that would be, and I'm not getting this error myself. Can you share your version of the script just so I can make sure nothing got messed up? And it looks like you've got some other scripts installed, could you tell me what all you have? I wonder if one of them doesn't have a compatibility issue with this.
 

Ique

Rookie
Member
Joined
Mar 29, 2021
Posts
2
Hm, that's really strange- it's treating ItemIconSprite like a constant, but I can't see any reason why that would be, and I'm not getting this error myself. Can you share your version of the script just so I can make sure nothing got messed up? And it looks like you've got some other scripts installed, could you tell me what all you have? I wonder if one of them doesn't have a compatibility issue with this.
Ruby:
Expand Collapse Copy
Prizes = [
[:POKEBALL,:REPEATBALL,:FASTBALL,:LEVELBALL,:NESTBALL,:DUSKBALL,:DIVEBALL,:HEAVYBALL,:GREATBALL,:MASTERBALL],
[:CHARMANDER,:CYNDAQUIL,:EEVEE,:PIKACHU,:CHIKORITA,:BULBASAUR,:SQUIRTLE,:TOTODILE,:MARILL,:RATTATA],
["100","200","300","400","500","600","700","800","900","1000"],
[:POKEBALL,"100",:CHARMANDER,:POKEBALL,"100",:CHARMANDER,:POKEBALL,"100",:CHARMANDER,:POKEBALL,"100",:CHARMANDER,],
["100","2500","100","7500","100","10000","100","5000","100","15000"],
]


WheelStyles = [
#bg graphic, wheel graphic, radius, minimum spins,
#spin SFX, volume, pitch
#winning sfx, volume, pitch
["hatchbg","prizewheel",110,3,"battle ball shake",80,150,"mining reveal full",100,100],
["hatchbg","prizewheel2",110,3,"battle ball shake",80,150,"mining reveal full",100,100]
]

def Wheel(prizelist,cost,style=0,costcoins=false,prizecoins=false)
  PrizeWheel.new(prizelist,cost,style,costcoins,prizecoins)
end


class PrizeWheel


  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end


  def initialize(prizelist,cost,style=0,costcoins=false,prizecoins=false)
    @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @prizes=Prizes[prizelist]
    @costcoins = costcoins
    @prizecoins = prizecoins
    @sprites = {}
    @cost=cost
    @style=WheelStyles[style]
    @bg=@style[0]
    @wheel=@style[1]
    @minspins=@style[3]
    @prizespin=0
    @angle=[72,36,0,313,287,251,216,180,144,108]
    @xyangle=[198,234,270,306,340,16,52,90,126,162]
    @sprites["bg"] = Sprite.new(@viewport)
    @sprites["bg"].bitmap = Bitmap.new("Graphics/Pictures/#{@bg}")
    @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow",8,28,40,2,@viewport)
    @sprites["downarrow"].x = (Graphics.width/2)-15
    @sprites["downarrow"].y = 10
    @sprites["downarrow"].z = 5
    @sprites["downarrow"].play
    @sprites["wheel"] = Sprite.new(@viewport)
    @sprites["wheel"].bitmap = Bitmap.new("Graphics/Pictures/#{@wheel}")
    @sprites["wheel"].center_origins
    @sprites["wheel"].x=Graphics.width/2
    @sprites["wheel"].y=Graphics.height/2
    for i in 0...10
      if getID(PBItems,@prizes[i])>0
        @sprites["prize#{i}"]=ItemIconSprite.new(0,0,0,@viewport)
        @sprites["prize#{i}"].item=getID(PBItems,@prizes[i])
        @sprites["prize#{i}"].center_origins
      elsif getID(PBSpecies,@prizes[i])>0
        @sprites["prize#{i}"]=PokemonSpeciesIconSprite.new(getID(PBSpecies,@prizes[i]),@viewport)
        @sprites["prize#{i}"].ox=32
        @sprites["prize#{i}"].oy=32
      else
        @sprites["prize#{i}"] = Sprite.new(@viewport)
        if @prizecoins == true
          @sprites["prize#{i}"].bitmap = Bitmap.new("Graphics/Items/COINCASE")
        else
          @sprites["prize#{i}"].bitmap = Bitmap.new("Graphics/Pictures/Money")
        end
        @sprites["prize#{i}"].center_origins
      end
      @sprites["prize#{i}"].angle = @angle[i]
      @sprites["prize#{i}"].x=(Graphics.width/2) + Math.cos(@xyangle[i].degrees)*@style[2]
      @sprites["prize#{i}"].y=(Graphics.height/2) + Math.sin(@xyangle[i].degrees)*@style[2]
    end
    main
  end

  def main
    loop do
      Graphics.update
      Input.update
      pbUpdate
      if Input.trigger?(Input::C)
        if @cost>0
          if @costcoins == true
            confirmtext="Spin the wheel for #{@cost} coins?"
          else
            confirmtext="Spin the wheel for $#{@cost}?"
          end
        else
          confirmtext="Spin the wheel?"
        end
          if pbConfirmMessage("#{confirmtext}")
            if @costcoins == true
              if $Trainer.coins>=@cost
                $Trainer.coins-=@cost
              else
               pbMessage(_INTL("You don't have enough coins..."))
                break
              end
            else
              if $Trainer.money>=@cost
                $Trainer.money-=@cost
              else
                pbMessage(_INTL("You don't have enough money..."))
                break
              end
            end
          spins=rand(360)
          spins+=360*(@minspins)
          spun=0
          click=true
          loop do
          pbUpdate
            @sprites["wheel"].angle -= 5
            @prizespin+=5
             for i in 0...10
              @sprites["prize#{i}"].angle -= 5
                @sprites["prize#{i}"].x= (Graphics.width/2) + Math.cos((@xyangle[i]+@prizespin).degrees)*@style[2]
                @sprites["prize#{i}"].y= (Graphics.height/2) + Math.sin((@xyangle[i]+@prizespin).degrees)*@style[2]
            end
            spun+=5
            Graphics.update
            if click=true
                pbSEPlay(@style[4],@style[5],@style[6])
                click=false
              else
                click=true
            end
            if spun>=spins
            prize=0
            prizey=[]
            for i in 0...10
              prizey[i]=@sprites["prize#{i}"].y
            end
             winner=prizey.min
              for i in 0...10
                if @sprites["prize#{i}"].y==winner
                   prize=i
                 end
              end
              prize=@prizes[prize]
              pbSEPlay(@style[7],@style[8],@style[9])
                if getID(PBItems,prize)>0
                pbUpdate
                pbReceiveItem(prize)
              elsif
                getID(PBSpecies,prize)>0
                pbUpdate
                  pbAddPokemon(prize,20)
              else
                if @prizecoins == true
                  pbMessage("You won #{prize} coins!")
                  prize = prize.to_i
                  $Trainer.coins+=prize
                else
                  pbMessage("You won $#{prize}!")
                  prize = prize.to_i
                  $Trainer.money+=prize
                end
              end
            break
            end
          end
        end
      end
      if Input.trigger?(Input::B)
        break
      end
    end
    pbFadeOutAndHide(@sprites) {pbUpdate}
    dispose
  end

  def dispose
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end


#center_origins command from Marin's Scripting Utilities.
#If you have that script, you can delete this section
class Sprite
    def center_origins
      return if !self.bitmap
      self.ox = self.bitmap.width / 2
      self.oy = self.bitmap.height / 2
  end
end



#.degrees command, to convert degrees to radians
class Numeric
     def degrees
     self * Math::PI / 180
     end
end
 

Magic0loc0

Rookie
Member
Joined
Feb 17, 2021
Posts
6
Hi Tech. I was wondering if there was a way to kick the player from the Prize Wheel screen once they've spun the wheel once. I'm trying to make it a daily event in my game, but right now I can spin endlessly as long as I stay in the Prize Wheel screen. Thanks in advance!
 
Hi Tech. I was wondering if there was a way to kick the player from the Prize Wheel screen once they've spun the wheel once. I'm trying to make it a daily event in my game, but right now I can spin endlessly as long as I stay in the Prize Wheel screen. Thanks in advance!
Oh, that's fun! I think daily events are a nice way to keep minigames like this relevant!

I should rewrite the code to make this simpler, but a cheap fix for now- in the section around line 150, put

Ruby:
Expand Collapse Copy
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
under the code for each way the player receives their prize. It should end up looking like this:

Ruby:
Expand Collapse Copy
              if GameData::Item.try_get(prize)
                pbUpdate
                pbReceiveItem(prize)
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
              elsif GameData::Species.try_get(prize)
                pbUpdate
                  pbAddPokemon(prize,20)
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
              else
                if @prizecoins == true
                  pbMessage("You won #{prize} coins!")
                  prize = prize.to_i
                  $Trainer.coins+=prize
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
                else
                  pbMessage("You won $#{prize}!")
                  prize = prize.to_i
                  $Trainer.money+=prize
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
                end
 

Magic0loc0

Rookie
Member
Joined
Feb 17, 2021
Posts
6
Oh, that's fun! I think daily events are a nice way to keep minigames like this relevant!

I should rewrite the code to make this simpler, but a cheap fix for now- in the section around line 150, put

Ruby:
Expand Collapse Copy
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
under the code for each way the player receives their prize. It should end up looking like this:

Ruby:
Expand Collapse Copy
              if GameData::Item.try_get(prize)
                pbUpdate
                pbReceiveItem(prize)
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
              elsif GameData::Species.try_get(prize)
                pbUpdate
                  pbAddPokemon(prize,20)
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
              else
                if @prizecoins == true
                  pbMessage("You won #{prize} coins!")
                  prize = prize.to_i
                  $Trainer.coins+=prize
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
                else
                  pbMessage("You won $#{prize}!")
                  prize = prize.to_i
                  $Trainer.money+=prize
                  pbFadeOutAndHide(@sprites) {pbUpdate}
                  dispose
                end
Thanks for the fast help! Nice!
 
TechSkylander1518 updated Prize Wheels with a new update entry:

Fixing shiny bug

Not sure why this is working this way, but it was defaulting to shiny menu sprites for Pokemon if the game had any, should be fixed now! It's just a one-line change- if you're using an older version, under

Ruby:
Expand Collapse Copy
@sprites["prize#{i}"]=PokemonSpeciesIconSprite.new(@prizes[i],@viewport)

Add:
Ruby:
Expand Collapse Copy
        @sprites["prize#{i}"].shiny = false

Thanks to ImZero for reporting!

Read the rest of this update entry...
 

SloppleMcFlopple

Rookie
Member
Joined
Nov 10, 2021
Posts
1
Hey I was wondering if there was a way to remove the "Spin the wheel? Yes or No" so the wheel just spins when a player interacts with it.
 
Hey I was wondering if there was a way to remove the "Spin the wheel? Yes or No" so the wheel just spins when a player interacts with it.
Remove this part of the script:
Ruby:
Expand Collapse Copy
        if @cost>0
          if @costcoins == true
            confirmtext="Spin the wheel for #{@cost} coins?"
          else
            confirmtext="Spin the wheel for $#{@cost}?"
          end
        else
          confirmtext="Spin the wheel?"
        end
          if pbConfirmMessage("#{confirmtext}")

And in this part-
Ruby:
Expand Collapse Copy
            break
            end
          end
        end
      end

Remove the second-to-last "end".
 
TechSkylander1518 updated Prize Wheels with a new update entry:

Reinventing the Wheel

v20 update comes with some great overhauls!
  • Data is now set up in a module with named values that can be set in any order, rather than an array. (Thanks to ThatWelshOne_ for this, I based it on his Modern Quest System!
  • As a result of this, default values for wheels can be set as well!
  • Cost and currency are now properties of the wheel itself rather than done in the event. All you do in the event is just call the wheel data!
  • Currencies are now set as integers, not strings...

Read the rest of this update entry...
 
Back
Top