Toribash
Well, the flickering is because you are redrawing the entire screen each time. Really you should be using a cursor
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

You can take a look in to it if you want, google something like "c cursor console tutorial". If you use a cursor then you only need to clear the screen and redraw when you change maps, after that you just tell it to change only the characters you need it to.
<Faint> the rules have been stated quite clearly 3 times now from high staff
I messed around with some code in a seperate file to get used to using the 3 console commands and it's fairly easy but using them in my code is another thing :'P

I reckon I'm just taking on way too much by trying to fix all the problems I'm creating for myself. At the moment the problem I've tried and failed to fix is this


The 2nd map just simply loads like this no matter how I load it through main or through the stairs :L
I dunno what's going on with that. Good luck with the debug :P
<Faint> the rules have been stated quite clearly 3 times now from high staff
Decided to change the way I make and display maps, going to use an array that runs off of constant defined variables.

So like, int currentMap[mapHeight][mapWidth];

I think I need to grab the #define from other libraries so I'm going to go find which library it comes from and include it.
So then I can #Define mapheight and mapwidth.

Then to make it more scaleable instead of using cases I'll use arrays to build my map. So a 0 could be nothing and 1 could be a wall and 2 could be a door

I thought of this idea before but I didn't know how to apply it until I came across this http://www.kathekonta.com/rlguide/article2.html

Just interested in the mapping, I can handle the rest I hope
#define is a preprocessor directive so it shouldn't be a part of any library.

You could also use strings to build your map, eg if 0 is nothing, 1 is a wall, 2 is a door, maybe Z is 'new line' so you can build your map like;

1111Z1001Z1002Z1111

Then you don't have to worry about arrays and whatever, you just make your render map function parse the string.


If you did that I suggest making a map editor program too :P
<Faint> the rules have been stated quite clearly 3 times now from high staff
Originally Posted by ImmortalPig View Post
#define is a preprocessor directive so it shouldn't be a part of any library.

You could also use strings to build your map, eg if 0 is nothing, 1 is a wall, 2 is a door, maybe Z is 'new line' so you can build your map like;

1111Z1001Z1002Z1111

Then you don't have to worry about arrays and whatever, you just make your render map function parse the string.


If you did that I suggest making a map editor program too :P

HAHAHAHAHAHAHA

I wish.

I can't even fix my current program forget being able to make another x(

Turns out I don't have "console.h" and I can't be bothered going through the hassle of trying to get it, I tried code::blocks to see if that would make a difference but after finally managing to make the program understand I just wanted a basic .cpp file to build and run it gave me the same "nope dude console.h isn't a thing" error.

So I guess it's back to fixing my original program.

So this string method would be something like this?
each tile eg
#define SPACE 0
#define WALL_TILE 1
#define POOP 2
#define SOMETHING 3

void drawMap()
{
{
define what each tile is with switch statements or something
}
cout << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 0 << endl;
cout << 1 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << endl;
cout << 1 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << endl;
cout << 1 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << endl;
cout << 1 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << endl;
}

cout << drawMap;


Meh, it's a bit too much for me to grasp with just ideas as you can see ;P
Think I'll stick to fixing this and if I fail I'll just try again with a cleaner approach :'P
are you doing <console.h> ? I dunno I never used that library honestly.


yeah but you'd use a for loop like;

for(int i=0;i<width;i++) {
switch(map[i]) {
case '0': cout<<' '; break;
case '1': cout<<'#'; break;
case '2': cout<<'/'; break;
case 'Z': cout<<endl; break;
}}


needs more forloops.

Well, it's good to just get things working, then change things around :P

A big part of programming is making small prototype programs to test out ideas and whatever, so if you end up with 50 small programs, that's good for learning!
<Faint> the rules have been stated quite clearly 3 times now from high staff
Nah it turns out I don't have that library on my comp :S
I'm going to give that idea a whirl!
However I'm thinking of how I'm going to make movement work if I am no longer in an array and rather just in a bunch of different characters that are cout'd to the console.

It's a bit hard to check blocks around him if I can't define the location of the player relative to the map. I'll give it a think over and have a go at it :')
Guess I better start from scratch on this one

Haha yeah ^^ I have about 8 different programs when I have one of those "I think I got it!" moments and then it turns out to be useful but not for what I'm intending to use it for :')
-----
Code code:
#include <iostream>
#include "windows.h"
using namespace std;

int height = 7;

void map1()
{
"1111000000000Z1001000000000Z1001000000000Z1001000000000Z1101000000000Z0000000000000Z0000000000000";
}

void drawMap1()
{
for(int i=0; i<height; i++)
{
switch(uhwhatdoIputhere)
{
case '0':
cout << ' ';
break;
case '1':
cout << '#';
break;
case '2':
cout << '/';
break;
case 'Z':
cout << endl;
break;
}
}
}

int main()
{
drawMap1();
}


What would I put in the switch statement? I think I misunderstood your method as I don't think would work even if it ran >.<
Last edited by souldevilj; Feb 18, 2014 at 04:14 PM. Reason: <24 hour edit/bump
uh, I think you need to change map1() to be some kind of variable? like a char array?

Then you can do;

char map[] = "1111z1001z1001z1111x";

void drawmap() {
    int i=0;
    for(;;) {
        switch(map[i]) {
            case '0': cout << ' '; break;
            case '1': cout << '#'; break;
            case '2': cout << '/'; break;
            case 'z': cout << endl; break;
            defauilt: break; } } }
Switch is the same as
switch i {
case 1: ...
case 2: ...
}

// is the same as

if(i == 1) ...
else if(i ==2) ...
I used an infinite loop and some other random stuff in that top example, but maybe you can get the idea? I'm not great at explaining things :x
<Faint> the rules have been stated quite clearly 3 times now from high staff
Oh I didn't know you could make an array without specifying the amount of contents inside it with [something]

asdas code:

int i=0;
for(;;) {


Um.. I take it that is the infinite loop?
I'll give it a go, inside the switch statement you have
asdas code:

switch(map)[i]


So my guessing is mine will be
asdas code:

switch(map1[i])


To be honest I'm only used to putting input into the switch brackets, so I can use the variable as different input from the user to make a choice. So I understand that it is taking something from the map1 array that I'll create, I just don't understand the part in square brackets []. What is this square bracketed part used for? If you could make it sound simple like you did when you just explained how the switch statement worked that'd be real nice and cool ^^

I'd just like to understand my commands properly so I can use them properly haha ^^'
-----
Hahaha, there is hope yet!

Tested it out using this line
"1111000010000Z1001000000000Z1001000000000Z1001000 000000Z1101000000000Z0000000000000Z0000000000000"

random 1 thrown in the first row to let me see if spaces worked correctly. Instead after running I just get the first 4 and nothing more. Swapped around the first 4 characters to see if the change worked correctly and it does so it seems it's a matter of making it do a complete line then output the next line. Unsure why it only displays 4, rather odd. But I'll try figure it out :')
-----

Post getting too big now


-----

Success!



And now I refined it :')

Improved


Success! ^^
Much cleaner than last time ^^'
Last edited by souldevilj; Feb 19, 2014 at 01:29 AM. Reason: <24 hour edit/bump