Collectables in the game

Collectables in the game

Postby davy » 18 Apr 2012, 18:56

Since im not familiar with the code structure of the code right now i would like to ask for a few tips on what files i should modify and keep in mind and stuff to implement this properly (collectables) to fit the code.
davy
 
Posts: 16
Joined: 16 Apr 2012, 21:25

Re: Collectables in the game

Postby Edward_Lii » 18 Apr 2012, 19:54

Hello davy,

davy {l Wrote}:Since im not familiar with the code structure of the code right now i would like to ask for a few tips on what files i should modify and keep in mind and stuff to implement this properly (collectables) to fit the code.

Okay, here are some tips/hints.

Keep in mind that you don't have to implement everything at once.
That's why I divided it into smaller chunks, the core needs to be done, the others can be done later.
Core:
A collectable is going to be a type of block, because that allows themes to change it from a pick-up to something else (e.g. lit/unlit candle).
  • Add the new block to the block_type enum in Globals.h
  • Keep track of two vars in Game.cpp, one for the current number and one for the total number of collectables in the level
  • In the loadLevelFromNode method in Game.cpp check the type and increase the total number of collectables var by one.
  • Somewhere in the Player class collision with the exit block is checked, this needs to contain an if-statement that will check if the current number of collectables >= total number of collectables.
  • Add a collision check in the Player class for Collectable blocks in which the current var is increased (objParent->currentCollectables++ ;) ).
  • A collectable can either be taken/activated or not, for this you can use the temp variable of the Block class.

Interface:
The player needs get feedback how many collectables he has.
These tasks can pretty much be implemented separately.
  • Add a gameToolTip in Game.cpp for when the exit is locked (current < total).
  • Add a text somewhere on the screen that shows the text (<current> / <total>) with an icon. (Also in Game.cpp)
  • Create theme states for when the collectable is taken or not and add the code that switch the state (Player.cpp).
  • Create theme states for the exit when it's closed, no need to keep track of that just set the appearance to closed when there are collectables, and change it when the number of collectables are is high enough.
One of the advantages of using a var for the total number is that it will make it easier to support for example 2 collectables needed while 4 in the level.

LevelEditor:
The user needs to be able to add collectables using the leveleditor, so here are the tasks needed to implement that.
  • Add the Collectable block to the editorTileOrder in LevelEditor.h

If you've got any questions left feel free to ask. ;)

And thanks for your contributions. :)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Who is online

Users browsing this forum: No registered users and 1 guest