-
October 14th, 2013, 07:49 AM
#1
Looking for some help (Error: Expected a Expression) >> Allegro
Code:
#include "I:\Documents\Visual Studio 2010\Projects\Coding Club Game\Coding Club Game\blocks.h"
#include <allegro.h>
#include <string>
using namespace std;
blocks::blocks()
{
place == {{true, true, true, true}, {true, true, true, true}};
}
void blocks::draw(BITMAP* buffer, ball &bl, int &score, SAMPLE* sound)
{
functs f;
for(int j = 0; j < 4; j++)
{
for(int i = 0; i < 4; i++)
{
if(f.collision(bl.x, bl.y, 10, 10, i*100+5, j*40 + 40, 100, 20) == true && place[j][i] == true)
{
place[j][i] = false;
score++;
play_sample(sound, 255, 128, 1000, false);
if(bl.dir == "NE")
bl.dir = "SE";
else if(bl.dir == "NW")
bl.dir = "SW";
else if(bl.dir == "N")
bl.dir = "S";
else if(bl.dir == "S")
bl.dir = "N";
else if(bl.dir == "SE")
bl.dir = "NE";
else if(bl.dir == "SW")
bl.dir = "NW";
}
if(place[j][i] == true)
rectfill(buffer, i*100+5, j*40 + 40, i*100+100, j*40 + 60, makecol(0, 255, 0));
}
}
}
The error is Line 10:
Code:
place == {{true, true, true, true}, {true, true, true, true}};
The
works fine, it is the first
that is giving a error.
-
October 14th, 2013, 08:17 AM
#2
Re: Looking for some help (Error: Expected a Expression) >> Allegro
What are you trying to accomplish with that line? It makes no sense to me.
-
October 14th, 2013, 02:17 PM
#3
Re: Looking for some help (Error: Expected a Expression) >> Allegro
its basically setting PLACE to true to wherever I use it as default, otherwise, i would ahve to set it to false.
Also side note-
Does [4][4] mean {{true,true,true,true} , {true,true,true,true}}
or does it mean
{{true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true})
OR
{{true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true} , {true,true,true,true}
-
October 14th, 2013, 02:32 PM
#4
Re: Looking for some help (Error: Expected a Expression) >> Allegro
What is PLACE?
And I need to repeat the question GCDEF already asked:
Originally Posted by GCDEF
What are you trying to accomplish with that line? It makes no sense to me.
Victor Nijegorodov
-
October 14th, 2013, 02:40 PM
#5
Re: Looking for some help (Error: Expected a Expression) >> Allegro
Code:
place == {{true, true, true, true}, {true, true, true, true}};
When trying to initialise a variable, use = and not == (which is the conditional equality). Also, this form of initialisation is only valid for a variable definiton.
So you could write
Code:
bool place[2][4] = {{true, true, true, true}, {true, true, true, true}};
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|