Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c programming is hard

Name: Anonymous 2012-04-17 16:47

so for my game i figured i would need a function to put an thing in a certain position, i wanted to allow for multiple things at the same position so my get would need to return a list of things wait what there's no lists in C i'm stuck

programming is hard let's smoke a joint

Name: Anonymous 2012-04-18 14:29

Okay, you seem knowledgeable... I'll take your advice and go with linked lists[1]. For now, that would mean I would use two linked lists: the first one would maintain a mapping between coord -> entitylist and the second would be a list of entities. I could replace the first one later on with more time-efficient structure (octrees spring to mind though I've never used them). This would mean I expose the following API:


struct entity_list {
  struct entity_list * next;
  entity * ent;
};

void put(coords, *entity);
struct entity_list* get(coords);
int move(coords, new_coords, *entity);


Now for the real question, we do we use a "coord" type (is it a struct?) instead of two (u)ints?

[1] http://cslibrary.stanford.edu/103/

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List