• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Daishim

Reducing Large Number of Variables

5 posts in this topic

I am working on a game with a rather large amount of weapons and equipment items, is there an efficient way to only load into memory the ones needed at the current moment and as new ones are encountered the variables for them will be declared? ie, I have a Broadsword in the game, but the character doesn''t have one, so the damage, range, and other stats aren''t needed.
0

Share this post


Link to post
Share on other sites
This is just a theory... Perhaps you could define a pointer struct ITEM *items (global) and keep count of the item amount and make a function for removing items and adding them somehow like this :

...
item_amount++;
add_item();
...
remove_item_a(item_number);
item_amount--;
remove_item_b();
...

add_item()
{
int i;
struct ITEM temp[item_amount]; /*The catch is that I''m not sure if you can use variables like this*/
for(i=0;itemp=items[i];
/*set the new item info to temp[item_amount]*/
*items=temp; /*Not sure about this either*/
}

remove_item_a(item_number)
{
int i;
struct ITEM temp[item_amount];
for(i=0;itemp[i]=items[i];
for(i=item_number+1;itemp[item_number-1]=temp[item_number];
*items=temp;
}

remove_item_b()
{
int i;
struct ITEM temp[item_amount];
for(i=0;itemp[i]=items[i];
*items=temp;
}

I dunno, maby it seems too good and easy to be true. Opinions anyone? Could use something like this myself..
0

Share this post


Link to post
Share on other sites
Don''t you have to use malloc and free, or new and delete?

If it''s relatively small, like 1000 ints (4 KB) then you could let it pass statically unless you''re targeting 8-16mb crowds.

If it''s a really large #, like 320,000 ints (1.3 MB) then you might want to allocate it using linked lists or some other dynamic variable system. If you have time and/or cash buy or borrow from a friend Andre LaMothe''s Tricks of the Windows Game Programming Gurus, he describes linked lists in detail. Or you could do a web search on linked lists. If you''re targeting 512MB crowds then you might not need this .

If it''s a 4kb structure, with 20,000 max (80MB) then you absolutely need linked lists unless you''re targeting the mainframe crowd.
0

Share this post


Link to post
Share on other sites
What about my theoretical way of doing it? Can someone say if it''s a working solution?
0

Share this post


Link to post
Share on other sites
ummm...
dunno how much it''ll help you, but i have
a good linked list unit (c/c++) from my
uni lessons, if you need it, just say the word

Gil
0

Share this post


Link to post
Share on other sites
One way you could do it is to have a base class that is the basic weapon definition, which could just be a 16 bit int to use as an identifier, and if you don't want to use built in RTTI, a virtual function to return if it is the base class.
class base
{
public:
short int unique_id;
virtual bool isBase() { return true; };
}

and also have a derived class containing full stats
class derived : public base
{
// whatever stats you need
public:
virtual bool isBase() { return false; }
}

Then you have a list/array of pointers to class base, for each
weapon/armour type (basically it's just an array of pointers to ints at this point) when you come accross a weapon you access it in the array (I'd match the unique_id to the array posn so I could do something like....)
if (baseArray[obj.unique_id].isBase())
{
// derive the child using the parent
baseArray[obj.unique_id] = new derived(obj);
}

In the child's constructor load you stats from file. To really save memory, periodically check how recently an object was used & revert the pointer back to a base class if not recently used.

I'd appreciate comments, cause I just thought of this now.

Brad


Edited by - brad_beveridge on July 22, 2001 6:23:06 PM
0

Share this post


Link to post
Share on other sites