Jump to content
• 0

# C - a character moving in a matrix

## 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?

• Answers 0
• Created
• Last Reply

## 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

1. 4

2. 1

3. 50

4. 4

5. 4

6. 4

7. 0

8. 3

9. 1

• ### Recently Browsing

• No registered users viewing this page.
×
×
• 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.