Re: XCode annoyance :-\
Re: XCode annoyance :-\
- Subject: Re: XCode annoyance :-\
- From: Andersen Studley <email@hidden>
- Date: Fri, 23 Jan 2004 12:53:48 -0800
David,
I believe the only time you can initialize the array like that at the
time of instantiation; if it already exists you have to iterate through
its indices. A couple of thoughts on how to do it :
1) separately define each of the piece types : (typed in mail)
int piece1[4][4] = {{ 0, 0 , 0, 0},
{ 1, 1 , 1, 1},
{ 2, 2, 2, 2},
{ 3, 3, 3, 3}};
2) Have your function return the array you want, e.g. have your case
statement's create a temporary array and return that
Hope that helps
Andersen Studley
On Jan 23, 2004, at 11:48 AM, David Cairns wrote:
the array is defined in the class' header file as
int array[4][4];
-- david
On Jan 23, 2004, at 12:15 PM, Oglesby, David (MN65) wrote:
How is array defined?
-----Original Message-----
From: David Cairns [mailto:email@hidden]
Sent: Friday, January 23, 2004 10:54 AM
To: Oglesby, David (MN65)
Subject: Re: XCode annoyance :-\
i had that before, and i tried it without, and it didnt
really seem to
make any difference. good gravy this is making me so angry...
-- david
On Jan 23, 2004, at 11:06 AM, Oglesby, David (MN65) wrote:
No one's said this yet, so maybe I'm wrong. Don't you need extra
braces for a 2 dimensional array, or is that not what
you meant by 4x4 array?
array = {{1, 1, 0, 0},
{0, 1, 0, 0},
{0, 1, 0, 0},
{0, 0, 0, 0}};
David
-----Original Message-----
From: David Cairns [mailto:email@hidden]
Sent: Thursday, January 22, 2004 5:12 PM
To: email@hidden
Subject: XCode annoyance :-\
hey all, im trying to make a little tetris clone (my first real run
with openGL ;-))
anyhoo, the project is sort of half-objC/half-c++ (my preferred
language). i have plenty of experience using the two languages
together and mixing them in source code, but this silly
little problem
is really annoying the heck out of me. Basically, I have a
Piece class
(C++ class), which contains a 4x4 array "array" of ints, specifying
which spaces will contain blocks in my game.
long story short ;-), this one constructor doesnt work
and i have no
idea why:
// in header:
Piece(int theType);
// in .cpp:
Piece::Piece(int theType)
{
myShape = theType;
myColor = theType;
switch (theType)
{
case kLShapeLeft:
array = {1, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 0,
0, 0, 0, 0}; // Piece.cpp:24: error: parse
error before `{' token
break;
case kLShapeRight: // Piece.cpp:30: error: case label
`kLShapeRight'
not within a switch statement
array = {1, 1, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0,
0, 0, 0, 0}; // Piece.cpp:31: error: parse
error before `{' token
break; // Piece.cpp:28: error: break statement not
within loop or
switch
case kBox:
array = {1, 1, 0, 0,
1, 1, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0};
break;
case kStraight:
array = {1, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0};
break;
case kMulti:
array = {0, 1, 0, 0,
1, 1, 0, 0,
0, 1, 0, 0,
0, 0, 0, 0};
break;
case kZigR:
array = {0, 1, 0, 0,
1, 1, 0, 0,
1, 0, 0, 0,
0, 0, 0, 0};
break;
case kZigL:
array = {1, 0, 0, 0,
1, 1, 0, 0,
0, 1, 0, 0,
0, 0, 0, 0};
break;
default:
cout << "SOME SHIT'S BROKEN, YO!";
} // switch
} // Piece::Piece()
kZigL, zBox, etc are enum'ed constants representing which piece is
which.
i have written the errors im getting as comments on the
corresponding
lines -- if anyone can help me with any of them, i would really
appreciate it...
thanx in advance
-- david
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/st> udentdev
Do not
post admin requests to the list. They will
be ignored.
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.