Game Development Community

Some simple questions

by Matt Rock · in Torque Game Engine · 02/05/2009 (12:39 am) · 2 replies

I'm working on a simple game for a class. I've run into a pair of problems. I need to find a way to keep track of score based off of grabbing items (like Sonic's rings or Mario's coins), as well as a level timer. In the former case, I've been able to get the item to cooperate with inventory, grabbed like a weapon. However, I've found that adding variables to the PlayerBody declaration doesn't seem to allow me to access them by the item. Likewise, I can't store other variables in the gem definition.

For the timer, likewise, I am not sure where the time-tracking variable and code for it ought to go. I know triggers have a timed component, so I figure there's a more basic component I can use for the level timer.

Can variables be loaded in mission files so they can have unique times, and is there a method to loop check all the items placed in a level for their total values to make a score percentage trackable?

Thanks in advance!

About the author

Recent Threads


#1
02/07/2009 (5:54 pm)
I believe there is a pdf that includes a small tutorial that shows how to allow the player to collect items. You can use that to get an idea of how to collect them(without putting them in the players inventory, unless that is functionality that you need).

To keep track of how many are left, you can simply add 1 to a global variable when the item is created(there is a script callback for that) so that you know how many of that item are in the level total. Every time the player picks one up, add 1 to the player's score and remove 1 from the global variable. I'm not going to give any code examples, for the sake of learning.

For the level timer, look in game.cs of the FPS Starter Kit to get an idea of how to do it.
#2
02/08/2009 (6:21 am)
Thanks for the help. So far, I've been able to work out some of the item tracking. I finally figured out how to use the dynamic variable entry to make the gems track their count, which by the Torque inventory, assumes it's picking up X of that gem. Then it creates a player variable that tracks the total number picked up. The thing I want to do now is to be able to have different gem types that all add to the same total variable. This book preview discusses making grenade packs that are part of the grenade item type, but bundled.

What I want to do is to make a Gem item type. Then, each gem type would be based off of it. Ideally, they'd each have a different appearance and count value, representing the number of gems they are for inventory, and the score value for our purposes. We have an item we want to make that will negate the last 5 gems picked up; my plan if that all works is to have an array or a set of variables that maintain a running total of the last gems' counts. If/when the item is used on an opponent, it would reduce their score by the amounts listed, and then zero them out so they're 'empty' until more gems are picked up.