I have a question on a map for a game.
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]
Favorite Quotes:Gandalf: You cannot pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|
well... how''s ur map actually displayed?
*****
*****
*****
*o***
would be the result, right?
*****
*****
*****
*o***
would be the result, right?
---- sig coming soon
That is actually how it is displayed. Yes that would be the end result.
Cory Fisher
Cory Fisher
Favorite Quotes:Gandalf: You cannot pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|
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.
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.
I''m not loading a bitmap at all, i''m just using cout.
Cory Fisher
Cory Fisher
Favorite Quotes:Gandalf: You cannot pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|
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.
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.
Yes that is exactly what i was trying to say.
Cory Fisher
Cory Fisher
Favorite Quotes:Gandalf: You cannot pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|
Snippit with moronic code formatting
that may help
-shadow
that may help
#include "iostream.h"#include "windows.h" // for system callint turncount; // the new turncount counterchar input; // the entry for movementint posx = 1; // set starting posint posy = 1; // dittoint 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 purposesint 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
-shadow
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement