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.

Anoth Data Class question.

Okay so i have this data class:
Code:
[color=#FF0000]  Bakugan = Struct.new(:name, :gpower, :attribute, :obtained)

  class Bakugan

    attr_accessor :id

    alias_method :bakugan_init, :initialize

    def initialize(*struct_args)

       # Calls our struct initialize method

       bakugan_init(*struct_args)

       # Set @id to be the size of our $data_bakugan list

       @id = $data_bakugans.size

       # Put our object automatically into the list

       $data_bakugans[@id] = self

     end

  end

 

  $data_bakugans = [nil]

  Bakugan.new('monster1', 450, 3, 0)

  Bakugan.new('monster2', 450, 3, 0)

  Bakugan.new('monster3', 450, 3, 0)

  Bakugan.new('monster4', 450, 3, 0)

  Bakugan.new('monster5', 450, 3, 0)

  Bakugan.new('monster5', 450, 3, 0)[/color]
and my question is if
Code:
[color=#FF0000]Bakugan.new('monster1', 450, 3, 0)[/color] goes to [color=#FF0000]Bakugan.new('monster1', 450, 3, 1)[/color] 0 to one.
how would i change the 0 to a 1 in and event and how would i print the monster1 name in text in a window? Thanks.
-SoBe
 
Have you read our other answers ?

Code:
monster1 = Bakugan.new('monster1', 450, 3, 0)

monster1.obtained = 1
Code:
self.contents.draw_text(0,0,200,24,monster1.name)

berka
 
thank you that works fine for just one, but how would i make so many ids with obtained = 1 show in a list?
i tried this but it doesnt seem to work:
Code:
if $data_bakugans[@obtained] = 1
Thank you
 

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