Pages

Monday, August 24, 2020

Day 6: Arrays and Collections

Object Evolution

She has recognized and learned how useful instance variables are to her game.  I think part of why she is getting this so quickly is that I introduced her to making her own dice-based games when she was 5.  With games like Pathfinder/D&D, Shadowrun, and Battletech obviously a bit much for someone that age, it was still valuable to get her a few dice and show her how to map out what each of the values mean when rolled (after which we spent hours coming up with insane monsters to randomly run into in our adventures).

Fights usually went something like this:  "roll a d6 when encountering a hostile creature, 1 = creature bored runs away, 2=miss, 3=hit for d4 damage, 4=d10 damage, 5=d20, 6=headshot monster dies."

Within her game's list of components, each:
  • Hero has a name, life, gold, weapon,
  • Weapon has a name, attack, effect,
  • Attack has a name, value, range, 
  • Monster has a name, life, weapon, boss.

She has also realized that she needs to store additional sets of items that may be plural (some obvious, some not-so-obvious):
  • Combo → a list of attacks performed in order that trigger a special attack
  • SpriteList → a set of image tiles that describe movement over time
  • Gang → a group of Monster objects that when killed as a whole drop additional loot
  • LootTable → potential loot drops with chance rates per Monster or Gang


Additional Math Operations

To realize the benefit of sprites and loot, we will also be discussing the modulus operator (%).  The simplest way of performing smooth tiled movement over time is to have a group of sprites for each direction that cycle (independent of CPU speed).  This can be accomplished by utilizing a universe timer, with each object possessing it's own offset (to keep the same object types from visually aligning), and then switching to the next sprite as the universe iterates.  Modulus is used to trigger looping within the fixed sprite list length (using the remainder keeps us from ever stepping beyond the max size).  We will also expand on her understanding of Random, seeds, and how to produce non-trivial random ranges.

No comments: