Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / cannot convert from 'bool' to 'bool [10]

Author
Message
Shwat
15
Years of Service
User Offline
Joined: 9th Aug 2009
Location:
Posted: 6th Sep 2009 12:10 Edited at: 6th Sep 2009 13:04
Hi everyone, been lurking the forums since I started a game dev course a few months ago...

I seem to have hit a problem... first off, I'm creating a 2d platform game, and I've been borrowing a bit of the Dark Invaders code.

what I'm trying to do is create my enemies by cloning them however many times I set int my

const int MAX_ENEMY

and I have used the bool array that dark invaders uses to check if the enemy is dead or alive.

I only want to spawn a single line of enemies off screen to walk in from the right.

here is a snip of my code:

the constants I'm using in this piece of code are





and the compiler gives me the error message

Quote: "error C2440: 'initializing' : cannot convert from 'bool' to 'bool [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays"


thanks to anyone that helps a n00b lol...
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 6th Sep 2009 15:21
If you double-click the error message, the cursor should jump to the line where the compiler detected the problem. (Note, however: it can happen that the error was in a line before the one where the compiler eventually gives up. In simple cases, it can find the faulty line exactly.) I'm pretty sure it will jump to this line:



You can't initialize a complete array with one single value. There is a way to initialize an array by listing all its values in {} brackets, or you can use for loops to initialize them, but it's hardly necessary in this case. A boolean will be by default false, and you are setting the values to true one by one when you create the enemies in your enemiesSpawn function, so the values will be initialized.
Shwat
15
Years of Service
User Offline
Joined: 9th Aug 2009
Location:
Posted: 7th Sep 2009 00:17
Thanks Mireben! that worked.

Login to post a reply

Server time is: 2024-10-01 12:27:57
Your offset time is: 2024-10-01 12:27:57