Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

if and array checking

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
8 replies to this topic

#1 phil67rpg   Members   

404
Like
0Likes
Like

Posted 16 December 2012 - 10:46 PM

bool bricks[3][5]={false};

I am trying to check a Boolean array.

the error I am getting is that bricks has to be an lvalue.

if(bricks[2][5]=true)

I know this is very simple, but google is not working very well.


#2 JTippetts   Moderators   

12629
Like
1Likes
Like

Posted 16 December 2012 - 10:50 PM

if(bricks[2][5]==true)

#3 phil67rpg   Members   

404
Like
0Likes
Like

Posted 16 December 2012 - 10:53 PM

thanks a lot


#4 phil67rpg   Members   

404
Like
0Likes
Like

Posted 16 December 2012 - 11:00 PM

now I get an == error bool * and bool are not compatible.

#5 JTippetts   Moderators   

12629
Like
0Likes
Like

Posted 16 December 2012 - 11:04 PM

Can you show actual code, as typed?

It sounds like your array might be declared as bool *bricks[3][5] or you are doing something like if(bricks[2]==true), in which case you are comparing a bool (true) with a pointer to bool.

#6 phil67rpg   Members   

404
Like
0Likes
Like

Posted 16 December 2012 - 11:08 PM

bool bricks[3][5]={{false,false,false,false,false},{false,false,false,false,false},{false,false,false,false,false}};
void brick_collision()
{
	if(bricks[2,4]==true)
	{
	
	}
	

}
here is some of my code


#7 JTippetts   Moderators   

12629
Like
1Likes
Like

Posted 16 December 2012 - 11:16 PM

bricks[2,4] isn't how you index a multi-dimensional array in C++.
bricks[2][4], however, is.

#8 phil67rpg   Members   

404
Like
0Likes
Like

Posted 16 December 2012 - 11:28 PM

cool thanks duh stupid question hehe

#9 rnlf   Members   

1860
Like
2Likes
Like

Posted 17 December 2012 - 02:57 AM

To elaborate a bit: bricks[2,4] is still valid C++, take a look at http://en.wikipedia.org/wiki/Comma_operator.

What it actually does is discard the value of 2 and use 4 as the array subscript. As a result, bricks[2,4] evaluates to bricks[4], which is of type bool[5], thus the incompatibility error.

Edited by rnlf, 17 December 2012 - 02:57 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.