• 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.
Sign in to follow this  
Followers 0
lmbarns

Logic help...

5 posts in this topic

I have a pool of 30 models I need to keep track of which are active through several levels.

 

Level 1 I need to check which models are active, subtract those from the pool of 30, and instantiate the rest that aren't activated yet.

 

The activatedModels are stored in a comma separated string which is available to each level. When a new model is activated, I simply append it's number to the string and destroy the model. Each unique model has a number 0-29. The "activated" string for activated models looks like "6,1,4,3,19,14,"

 

On Level 2, I load models that have been activated but not the rest. I get the string of activated models from level 1, split it at the commas, and instantiate the models by number. Insantiate model #6, #1, #4, #3, #19, #14, etc

 

So now on level 1, I have 2 arrays, array1 has the entries "6,1,4,3,19,14," array2 has entries 0,1,2,3,...,29,

 

I need to subtract matching entries between array1 and array2, then instantiate the models of the remaining entries, but not instantiate models that are already activated....

 

Any tips for what methods would help are appreciated. Do I loop through and make a comparison between all entries in both arrays, and subtract entries, or loop through and store non matching entries in a 3rd array? I got most of it done as far as parsing the string, adding activated numbers, etc but just not separating out the already activated from the large pool of available models to spawn them on level 1...

0

Share this post


Link to post
Share on other sites

I dont really know whats your goal, ...but if you just want to keep track of the activated/deactivated models then use a bool array.

0

Share this post


Link to post
Share on other sites
Before going into that, what are you doing or trying to do that has created this system?

Eh, I guess I can just express my suspicion and concern up front.

If you're looking to render a subset of models then you can just use a boolean property to mark which ones are active and skip rendering on the ones that aren't. Are your models held in their own objects or are they raw data that's being manipulated/used externally?

Also, why are you using strings for this? Edited by Khatharr
0

Share this post


Link to post
Share on other sites

What is your general objective on this code? 

 

[quote name='lmbarns' timestamp='1357347245' post='5017595']
So now on level 1, I have 2 arrays, array1 has the entries "6,1,4,3,19,14," array2 has entries 0,1,2,3,...,29,
 
I need to subtract matching entries between array1 and array2, then instantiate the models of the remaining entries, but not instantiate models that are already activated....
[/quote]

 

are you trying to add more models as you progres in game? 

0

Share this post


Link to post
Share on other sites
The OP describes IMHO: From a total of 30 different models a subset is to be picked during the run of level 1. This subset is to be re-used "as-is" during level 2 and perhaps following levels.

So the task is to pick n <= 30 (probably n < 30) models from the original set of 30 models, i.e. selection without putting back.

A solution would be to hold all IDs of still available models in an indexable storage (e.g. the array mentioned in the OP), generate a random integral number in the range [0, length(storage)-1], use that as index into the storage to read out the appropriate ID, remove it from the storage (i.e. in the case of an array by shifting all IDs with greater indices one index before and decrease the length of the storage by 1), and use the picked ID further for remembering and instantiation. Edited by haegarr
1

Share this post


Link to post
Share on other sites

Thanks for the responses.  I ended up with 2 arrays before coming back here, but should probably rewrite it to use a list and just add/remove the reference from the single list.

 

The array just holds 30 integers, 0-29, of the possible objects. If it's the first time the player loads the game it will load all 30 objects. As the player "activates" them, the number of that object is added to the second array, then I simply sort it, loop through and set that model's reference in the first array to null, then when it loads I simply loop through the first and for each model index that isn't null, instantiate the object.

 

So say i've activated activatedArray[ 5, 3, 8, 9,], then in the other array I go potentialArray[activatedArray[5]] = null, for each of 5,3,8,9.  ...seems to work. Maybe it's slow but it only runs once when the game is loaded only.

 

I am using a string so I can store the entire thing in 1 entry in either memory or xml, then I split it at the commas and int.Parse() it when I read it back into the game...is that really really really slow or just potential for it to mess up? This is for android.

 

Yesterday I got an xml storage working so I might switch to that, but I'm wondering if memory on mobiles is alright to use for storage...can users edit that like they can on a PC? I was under the impression the values stay in memory even if the app is uninstalled on mobile, so it's not likely for a player to delete/edit the values...??

Edited by lmbarns
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0