Here ya go Smile

http://sourceforge.net/projects/daemons-rpg/files/Daemons.zip/download
HOMER-16 wrote:


Can you release the source? I just realized that you compiled this for windows when I saw the exe. It would also be nice if you had some build instructions too.
Ah, ok. I included the source code however it needs SFML to compile. I'll upload a file with that info.
SFML? Standard Flubbering Markup Language?

EDIT: nvm. google++
Small Fast Multimedia Library
I have a small question because I'm running into a bit of a wall.

As of right now the way the main character spawns on the map is that it looks at the NPC map and spawns the character when it finds a 0.

The problem is, no matter where you enter the map at, it spawns you there where it ought to spawn you elsewhere. Say for instance you enter a house from a city then exit. The 0 could be at the main entrance to the city so it looks like you entered the city again instead of exited the house.

So basically there's only one spawn to multiple potential entrances.

My question is what is the best method of detecting where the character should spawn based on what map he transitioned from?
How are you storing tile data? If you don't have too many tiles, you could assign a number to every map. So something like numbers over 256 link to a map. Just my take..
HOMER-16 wrote:
So basically there's only one spawn to multiple potential entrances.

My question is what is the best method of detecting where the character should spawn based on what map he transitioned from?


So, from what you said, it seems you're using tiles as spawn points, which I think is definitely a bad idea. I say when you leave a map, set the position of the "spawn area" before the other map even pops up. Perhaps have rooms structured in a node-to-node type of organization:


Code:
struct portal {        // a bounding-box struct that is a rectangle
   int x; int y; int w; int h; // with a room pointer to the room it leads
   room*next;                   // to and the position it sets you to
   int setx; int sety;
};

struct room {
   //blah all the stuff you already have
   int portaln;  // amount of portals
   portal**connections;  // an array of pointers of portaln length that
};                                   // lets you quickly check if the player is in
                                      // bounds to "teleport" to another room


then, to check if the player is in bounds of a portal and then teleport is quite simple (pretend you have a player struct with x and y elements, and a room variable based on the above struct that holds the pointer to the current room):


Code:
for(int i = 0; i < cur_room->portaln; i++) {
   if(player->x>=*(cur_room->connections+i)->x &&
      player->y>=*(cur_room->connections+i)->y &&
      player->x<=*(cur_room->connections+i)->x+*(room->connections+i)->w) &&
      player->y<=*(cur_room->connections+i)->y+*(room->connections+i)->h)) {
      cur_room = *(cur_room->connections+i)->next;
      player->x=*(cur_room->connections+i)->setx;
      player->y=*(cur_room->connections+i)->sety;
      break;
   }
}


It's in C, sorry, I realized that you'd be doing it in C++ when I was 90% through, but I hope it helps anyways Smile
Ah, I see what you are saying. What I'm doing right now to find where to spawn is that I have a vector of values purely for transition data. When you end up on a tile that's not -1 it takes the number and finds that element in a vector of map names and loads the map. When it loads the map it keeps the name of the previous map and searches in a new vector of map names and finds the name of the previous map.

When it finds it it takes the position it was at and searches the transition data map for that value and places the character there. If it does not find the map name or a corresponding value it places the character at a default spawn within the NPC data.

I've never figured out how to make a node-to-node map. Else I'd probably use that and make my life a bit easier. Razz

Why is using tiles for the other data a bad idea?
HOMER-16 wrote:
I've never figured out how to make a node-to-node map. Else I'd probably use that and make my life a bit easier. Razz


Good idea to learn Wink very helpful in a variety of situations, especially this one. From what I've searched online, this seems to be the best one for the job: http://www.cprogramming.com/tutorial/lesson15.html

Quote:
Why is using tiles for the other data a bad idea?


For what other data? I think it's only bad for NCPs, Enemies, Items, and Spawn/event points, really.
  
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 2 of 2
» 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