• 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.

Tac-Tics

Pointers again =-)

9 posts in this topic

OK, I have a realatively decent understanding of what pointers are now, and how they work. But here''s one question I don''t understand yet. What are they actually good for (besides making arrays the fancy way)? It might be nice if someone could give me a little code snippet demonstrating some real-world use of pointers. "I''''m not evil... I just use the power of good in evil ways."
0

Share this post


Link to post
Share on other sites
I actually did do a search on it, but I didn''t find anything. I obviously didn''t look hard enough.

"I''''m not evil... I just use the power of good in evil ways."
0

Share this post


Link to post
Share on other sites
Here's an example of changing a variable remotely.

    

void main (void)
{
int a=2;
printf("before %d\n",a); //before changing the value of a


//give the function the address of the variable a

ChangeVarable(&a);

printf("after %d\n",a);//after changing the value remotely

}

void ChangeVarable(int *changed)
{
//the function takes the address of the variable passed and is able to change it remotely


*changed=5;
}





See? You didn't need to return anything and you didn't use any global variables. It's quite powerful.

Edited by - Nazrix on January 28, 2002 7:48:16 PM
0

Share this post


Link to post
Share on other sites
Dynamically allocating memory:

if you want a char array with 100 elements, you'd do this, right?
char a[100];


well what if you don't know how much you'll need? Let's say in the middle of your program you want to only allocate as much as you need and you don't know how much that'll be ahead of time?

        
int num;
char *a;

printf("enter in the number of letters in the string:\n");
scanf("%d",&num);

a= new char[num+1]; //dynamically allocate the number of characters entered by the user (num)




I didn't test this so please correct me if I messed up. The idea is that the variable a is the beginning of that array so you're saying "I want this much space and let a hold the beginning of that space"

I hope I was of some help.


A CRPG in development...

Need help? Well, go FAQ yourself.



Edited by - Nazrix on January 28, 2002 8:03:18 PM
0

Share this post


Link to post
Share on other sites
Here's another example of how you can use pointers with structures or classes...

      

// just a test structure

struct Test
{
int blah;
};


void main (void)
{
//this dynamically allocates space for the test structure

Test *test_var=new Test;

Change(test_var);

printf("value: %d",test_var->blah);
}

void Change ( Test *var)
{
// this takes in a pointer that is the type of our structure and changes it remotely

var->blah=5; //you always use -> instead of period (.) when it's a pointer of a type struct or class

}



Edited by - Nazrix on January 28, 2002 8:23:59 PM
0

Share this post


Link to post
Share on other sites
pointers are wonderful..umm...thingies! now lets use some logic here. you have a function. you want to pass a huge class to it as an arguement. now what would you think to be quicker? copying the entire class? or just sending a 32 bit variable that points to it''s location?
0

Share this post


Link to post
Share on other sites
Just a little addition to the chat :o)

you can also pass lots of function arguments into a function, all at once, by putting them inside a structure and then passing a pointer to the structure into your function....instead of passing each individual parameter in....which is actually slower (someone will almost definatley argue not that slow...bu this is games so speed is paramount)...just saves "pushing" and "popping" stuff on an off the stack...especially in tight loops...

... just a little point I like to remember...

:oD
0

Share this post


Link to post
Share on other sites
also saves having to allocate stuff, you can allocate it only when needed, for example you don''t want you class to initialize all data on startup, only when its needed, but if those other types are complex classes, well you get the point
0

Share this post


Link to post
Share on other sites