Jump to content
Phishing - Beware of identity theft... ×
  • 0

C - a character moving in a matrix


Tasho

Question

Hi guys, could someone help me make ca caracter move in a matrix.

Code: 

 

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <time.h>


#define MAX_X 60
#define MAX_Y 20


using namespace std;
char base[MAX_Y][MAX_X]; // Base


// Prototypes




void init();
void display();
char player = 189;


void init()
{
int y, x;


/*           Base              */
for (y = 0; y < MAX_Y; y++) {
for (x = 0; x < MAX_X; x++) {
base[y][x] = ' ';
}
}
/* --------------------------- */


/*           Frame            */
for (y = 1; y < MAX_Y - 1; y++) {
base[y][0] = 186;
base[y][MAX_X - 1] = 186;
}


for (x = 1; x < MAX_X - 1; x++) {
base[0][x] = 205;
base[MAX_Y - 1][x] = 205;
}


base[0][0] = 201;
base[0][MAX_X - 1] = 187;
base[MAX_Y - 1][0] = 200;
base[MAX_Y - 1][MAX_X - 1] = 188;
/* --------------------------- */


base[18][30] = player;
}


void display()
{


int y, x;


for (y = 0; y < MAX_Y; y++) {
printf("t");
for (x = 0; x < MAX_X; x++) {
printf("%c", base[y][x]);
}
printf("n");
}


}






void main()
{ 
init();
display();
getch();


}

I want to point out that I'm a beginer so don't be hard on me :)

 

After that could someone explaine how double buffering works? :)

 

 

Link to comment
Share on other sites

  • Answers 0
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.