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

Pseudo_Code

lookup

13 posts in this topic

Lookup tables are just pre-computed arrays that you use instead of computing everything in real-time. For example, you could create an array of 360 floats and fill it in with sin(0), sin(1), etc. and instead of having to call the sin function when you need it, you just reference this array.

Simple lookup tables like this can be created when your program starts, but more complicated lookup tables are usually stored on a file somewhere and read in.
0

Share this post


Link to post
Share on other sites
Say you wanted to create a lookup table for sin values from
0 - 360 it would be something like this(BTW this is in java but it's almost the same as C++)..

sinus = new float[360];
deg2rad = Math.PI/180;

for(int i=0; i<360; i++){
Sinus = (float)Math.sin(i*deg2rad);
}

where deg2rad is assinged as a float also.
What this does is fill an array full of cosine values. the only thing you would need to do to find the cos(15) would be to use cos[15]. It's actually pretty slick cause it saves alot of computation time if you are doing a lot of trig.
Anyway I hope this helps.. if you need me to do something like this in C++ I could give you an example too.


Edited by - Wrathnut on 2/13/00 1:24:14 PM
0

Share this post


Link to post
Share on other sites
Sorry about that the above:
Sinus = (float)Math.sin(i*deg2rad);

should read
Sinus[j] = (float)Math.sin(i*deg2rad);

where j = i ..
the damn thing here wants to make my source code an html tag... grr

Edited by - Wrathnut on 2/13/00 1:31:36 PM
0

Share this post


Link to post
Share on other sites
Use whatever file type is easiest for you. I''ve seen nearly 10,000 normal vectors defined in an array in a header file before.
0

Share this post


Link to post
Share on other sites
float* sin_table = new float[360];
float deg2rad = 3.1415927/180;

for(int i=0; i<360; i++)
{
sin_table = sin(i*deg2rad);
}
0

Share this post


Link to post
Share on other sites
Whoa. The thing removed my subscripts in the "for" loop. Should have read Wrathnut''s post

float* sin_table = new float[360];
float deg2rad = 3.1415927/180;

for(int x=0; i<360; i++)
{
sin_table[z] = sin(x*deg2rad);
}
0

Share this post


Link to post
Share on other sites
Okay, if at first you don''t succeed...this was supposed to be a simple post

float* sin_table = new float[360];
float deg2rad = 3.1415927/180;

for(int z=0; z<360; z++)
{
sin_table[z] = sin(z*deg2rad);
}
0

Share this post


Link to post
Share on other sites
use the code tags to display your examples.

like this.  everything is mono spaced and nothing disapears on you. 


0

Share this post


Link to post
Share on other sites
ok, but what about when you are using fractions and such and you want precision? i want to make a lookup table for sines of distances to a point. the distance function will frequently return a fraction. so how would i create a lookup table for fractions (e.g. sin(.88624132))?


_________________Gecko___
0

Share this post


Link to post
Share on other sites
In practice you wouldn''t create a lookup that would match .88624132 exactly. You''d have a lookup for .886 or .8862 maybe. Then when you''d want to index .886 you''d multiply the .886 by say a 1000 to get 886. And use the 886 to index your lookup table. How closely you want to match your fractions depends on how large you want your lookup-tables. The alternative would be to use a hash-table that accepted floating point arguments.
0

Share this post


Link to post
Share on other sites

If you want a little more precision at the cost
of a little speed, consider interpolating your
answer from the two closest lookup in the table.

For example, if you have a result that is 1.4 and
your lookup only shows answers for 1 and 2, your
result should be


lookup[1] + ((lookup[2] - lookup[1]) * 0.4)


This assumes that your functions is a "continuous"
function, but sine and cosine are.

0

Share this post


Link to post
Share on other sites