Now that I'm making a large game in C, I have tons of questions for you Very Happy

  1. Let's say I want to locate a stack $123456, which consists of 3-byte value, and in every 3-byte value, 3 seperate 1-byte values (type, x, y). How do I write/read them?
  2. Related to 1), is it more useful to have a pointer which reads only 1-byte values, or 3-byte values? (I need to access these values every frame, so speed is important)


(more are coming Smile)
1) Rather than asking these sort of questions, explain what you are trying to do. This doesn't make any sense :p
Oh hmm, okay. I want to build a stack with all the buildings in AoCE, and every building has 3 'arguments': the type, the x coordinate and the y-coordinate, all are 1-byte values. So I want a stack with all these values, and I need to read it :p
Okay; use a structure:


Code:
typedef struct {
    uint8_t type, x, y;
} building_t;


Then you can do something like:


Code:
building_t building[256];

// types of buildings
enum building_types { FARM_TYPE=1, ... , ... , };

// get address of current building
building_t *this_building = &building[0];

// store location and type
this_building->x = 0;
this_building->y = 0;
this_building->type = FARM_TYPE;
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement