Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SSJCORY

I have a question on a map for a game.

This topic is 5859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Say you had a map like so: ***** ***** ***** o**** o being the player. When the player moves it does this: ***** ***** ***** o**** ***** ***** ***** *o*** If the player moved to the right how could i display that without displaying another screen? Please help i'm stumped. Cory Fisher [edited by - ssjcory on November 30, 2002 11:10:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
I''m... not quite sure what you''re talking about here...

What do you mean by "without displaying an other screen"? You mean loading an other bitmap...? How''s your map actually done, for that matter? Is it tile-based, a background bitmap...?

When you move the player''s sprite around, just redraw the original location he/she was on and re-plot the sprite at the new location. You don''t have to actually reload the whole screen, just the section that the player was on.

Share this post


Link to post
Share on other sites
Ok, I''m going to make the assumption that you want the player to go RIGHT, not LEFT (i.e. You''re not talking about him going off the edge of the map, which he would if he went left.)

I''m guessing your root problem is that when you move him, you get THIS display after the move[sic]:

*****
*****
*****
o****

*****
*****
*****
*o***

... as opposed to THIS:

*****
*****
*****
*o***

... am I right? In that case you might want to check out windows.h, it has some nice functions for writing a buffer to the screen. Let me know if I got what you were talking about and I''ll fill you in.

Share this post


Link to post
Share on other sites
Snippit with moronic code formatting
that may help

#include "iostream.h"
#include "windows.h" // for system call

int turncount; // the new turncount counter
char input; // the entry for movement
int posx = 1; // set starting pos
int posy = 1; // ditto
int oldposx = 1;
int oldposy = 1;
int map[8][8] = // our map
{
{35,35,35,35,35,35,35,35}, // 35 is ascii ''#'' (pound) wall
{35,46,46,46,46,46,46,35}, // 46 is ''.'' (period) floor
{35,46,46,46,46,46,46,35}, // player icon is ''@''
{35,46,46,46,46,46,46,35},
{35,46,46,46,46,46,46,35},
{35,46,46,46,46,46,46,35},
{35,35,35,35,35,35,35,35},
};
int x = 0, y = 0; // for map drawing purposes

int main()
{
system("cls"); // re-set the map
map[posx][posy] = 64; // draw the player icon
while (x < 8) // loop through the map x cordnates
{
while (y < 8) // ditto but for the y''s
{
cout << (char)map[x][y];// draw the stuff after conversion to ''pictures''
y++; // advance to the nextchar
}

cout << "\n"; y = 0; x++; // next line and reset the y to zero
}
cout << "Turn: " << turncount << " w,a,s,d to move: "; // the "command" line with turncount
cin >> input; // get input values
x = 0; // reset everything to zero for the next draw
y = 0;
if (input == ''d'') // right
{
oldposx = posx; oldposy = posy; // set the old values to the new values
posy++; // move the position
map[posx][posy] = 64;// set the location to the player icon
map[oldposx][oldposy] = 46;// set the old position to the floor icon
turncount++;
main();
}
if (input == ''a'') // down
{
oldposx = posx; oldposy = posy;
posy--;
map[posx][posy] = 64;
map[oldposx][oldposy] = 46;
turncount++;
main();
}
if (input == ''w'') // up
{
oldposx = posx; oldposy = posy;
posx--;
map[posx][posy] = 64;
map[oldposx][oldposy] = 46;
turncount++;
main();
}
if (input == ''s'') // left
{
oldposx = posx; oldposy = posy;
posx++;
map[posx][posy] = 64;
map[oldposx][oldposy] = 46;
turncount++;
main();
}
if (input == ''q'') //''q'' for quit
{
return 0;
}
main(); // back to main for the next draw unless q
}



-shadow

Share this post


Link to post
Share on other sites
I think basically, the command you were looking for was:

system("cls");

I think it''s under conio.h , not sure though. Check the headers. The command clears the screen. Only problem is it might flicker a bit, but that shouldn''t be too much of a problem.

Share this post


Link to post
Share on other sites
It''s under windows.h
Yes the command is system("cls");
You should use windows.h for GetTickCount() which is useful with random numbers via: srand(GetTickCount)
There are other system calls that I have forgotten

-shadow

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!