Hi i'm writing a basic tetris with ascii output
and I have a Block Object that I want to move around
How would I change the Character at a certain Position in my Field from my method?
but VisualStudio tells me
1>------ Build started: Project: Tetris, Configuration: Debug Win32 ------
1>Tetris.cpp
1>e:\dateien\uni\c++\tetris\tetris\tetris.cpp(48): warning C4244: '=': conversion from 'int' to 'float', possible loss of data
1>e:\dateien\uni\c++\tetris\tetris\tetris.cpp(49): warning C4244: '=': conversion from 'int' to 'float', possible loss of data
1>e:\dateien\uni\c++\tetris\tetris\tetris.cpp(50): error C2108: subscript is not of integral type
1>e:\dateien\uni\c++\tetris\tetris\tetris.cpp(91): warning C4305: '+=': truncation from 'double' to 'float'
1>Done building project "Tetris.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
code:
#include <iostream>
using namespace std;
int main()
{
const int FieldY = 20;
const int FieldX = 11;
char TetrisField[FieldY][FieldX] =
{
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
"__________",
};
class Block {
public:
float posX;
float posY;
char Character = 'A';
void setPos( int x, int y)
{
posX = x;
posY = y;
TetrisField[posY][posX] = Character;
};
};
while (true)
{
Block B1;
B1.setPos(0, 5);
for (int n = 0; n < FieldY; n = n + 1)
{
cout << TetrisField[n][0] << TetrisField[n][1] << TetrisField[n][2] << TetrisField[n][3] << TetrisField[n][4]
<< TetrisField[n][5] << TetrisField[n][6] << TetrisField[n][7] << TetrisField[n][8] << TetrisField[n][9] << endl;
};
};
return 0;
};
I know the output method is bad but thats just for testing
ok now im writig random stuff so that the stack overflow editor allowes me to post this question because apparently I have not jet written enaugh normal words, that are not Code. ah finally ;-)
thx