Developing the setup routine

As in python, using a function is a better way to reuse code and keep code ‘DRY’. I moved the array routine into its own function which is called from setup.

..

I saved this and explored the pac-man game, looking at the global variables and how these would map to my own maze dragon game.

globals [
  level         ;; current level
  score         ;; your score
  lives         ;; remaining lives
  extra-lives   ;; total number of extra lives you've won
  scared        ;; time until ghosts aren't scared (0 means not scared)
  level-over?   ;; true when a level is complete
  dead?         ;; true when Pac-Man is loses a life
  next-bonus-in ;; time until next bonus is created
  tool which-ghost ;; variables needed to properly load levels 4 and above.
]

So examining the list to start with, i would need levels, but i would have rooms, and score, lives would be useful. There are no levels as such, once you have completed the adventure the score and time it took to complete is significant. At the moment I’m not doing the AI for the opponents, so ‘scared’ and ‘level-over’ are also not applicable, as well as bonuses and ghost-speicic globals.

My initial list of globals started as

globals [
  lives ;; amount of lives the player has
  health ;; the health of the player
  score ;; players score
  room ;; the room the player is in
]

and I have moved the array-creation to dungeon-map-array

to setup
 dungeon-map-array
end

to dungeon-map-array

I now have the global variables to start creating the rendering procedures for my maps

Leave a Reply

Your email address will not be published. Required fields are marked *