Text Maps
ok i want to be able to type something like
000000000000000000000
011111111131111111110
000000000000000000000
and it be intepreted as a map
so like if he moves forward if he hits 0 that is a wall and can''t move any farther and if he moves over like 3 he gets an item
how would i do this ?
thanx if u need more info on what i am trying to do i cna provide it
YOu wouldnt want to type it you want to load it from a file. Your going to need an array like this (i am assuming language is c)
int map[width][height]
then store the posistion of the player like this
struct
{
int x, y;
} player;
the x and the y are indices into the map array that tell where they player is. you can then write functions to tell if the player is on a certain type of tile. a word of advice, it will be easier to make certain tiles so you can move over them if you check it before you move the plyaer.
if(key_up)
{
if(map[player.x][player.y] == CANTPASS)
{
//dont do anything
}
else
{
player.y--;
}
//now call function to check if they get an item
}
this should be enough to get you started.
int map[width][height]
then store the posistion of the player like this
struct
{
int x, y;
} player;
the x and the y are indices into the map array that tell where they player is. you can then write functions to tell if the player is on a certain type of tile. a word of advice, it will be easier to make certain tiles so you can move over them if you check it before you move the plyaer.
if(key_up)
{
if(map[player.x][player.y] == CANTPASS)
{
//dont do anything
}
else
{
player.y--;
}
//now call function to check if they get an item
}
this should be enough to get you started.
quote:
Original post by atchon
ok i want to be able to type something like
000000000000000000000
011111111131111111110
000000000000000000000
and it be intepreted as a map
so like if he moves forward if he hits 0 that is a wall and can''t move any farther and if he moves over like 3 he gets an item
how would i do this ?
thanx if u need more info on what i am trying to do i cna provide it
I have a small bit of advice which you should take into concideration in order for us to be able to answer your questions with more precision, when you post a question, you need to mention what language you''re using, if you''re using an API( which one is it ), etc. You see, it makes it easier for us to help you out. Anyhow, as for your question, as it was already pointed out to you, use a text file, and load your file. As for the rest, it should be easy for you to do it. If you don''t know how, start by learning what ever language you''re using and then come back with your questions. BTW, make yourself a map editor, if you don''t know how, I can send you the beta version of mine( although I don''t include the sources for it, it might give you an Idea of how to code one, oh and as most of my tools, it''s made in VB no other APIs but the standard WinAPI ). Although, it saves in binary format and not text.... Anyhow, e-mail me if you want me to send the editor. It''s not that big, as far as I know, it''s less than 2Mb.
"And that''s the bottom line cause I said so!"
Cyberdrek
danielc@iquebec.com
Founder
Laval Linux
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
[Cyberdrek | ]
May 23, 2002 11:01 AM
char map[][] = {"#######################", "# ~~~~~~#", "# ^ ~~~~#", "# + ~~~~~~#", "# ? ~~~~#", "# ~~~#", "# ) ~~~#", "# $ $ ~~~~#", "# $ ~~~~~~~#", "# ~~~~~ ~~~#", "# ~~~~~~~ * ~~~#", "#######################"};// find out what stuff is:switch(map[x][y]) { case ''~'': // water break; case '' '': // open space break; case ''#'': // wall of some sort. break; default: // pick up some item switch(map[x][y]) { case ''*'': // pointy start thingy. makes people die. break; case ''+'': // cross. keeps vampires away. break; case '')'': // bannana break; case ''$'': // money break; case ''?'': // quesion mark of protection. keeps newbies away. break; default: // you screwed something up. } map[x][y] = '' ''; // picked up what ever it was. make it open space. }
Probably a bad idea, anyway.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement