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.

ARRAYS, Math and case select

Status
Not open for further replies.
First off, thanks Sephiroths Spawn for the tutorial from Asylum, it helped me finger out how to add the base stats I needed....

IN ruby, is it faster to...

access from an array(which I cant figure out yet) for preexisting values

Do the math on the spot

Utilize a large select case statement for 8 base stats with about 5 subordinate stats beneath it...

The whole
ie
Case @actore.int
When > 50 and < 60
SP_Bon = 6
sp_damage_bonus = 24
Prim_projec_hit% = Prim_projec_hit% + 1
sp_recover = 2
Melee_Hit% = melee_hit% +1
When
WHEN
else
end
 
It all depends on what you are aiming for.

It looks like what you are doing, you are branching a certain operation depending on a stat. In this case, it would probably be easier to do a case statement.

Now, when you get into complicated math problems, and searching complex things, it is good to create a cache of your searches, to speed things up. If you want an example of this, check the Curve Generator module in my test bed v.4 in my signature. But in most cases, you don't need to do something like this.
 
Status
Not open for further replies.

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