CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2013
    Posts
    2

    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

    Code:
    place ==
    works fine, it is the first

    Code:
    {
    that is giving a error.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  3. #3
    Join Date
    Oct 2013
    Posts
    2

    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}

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Looking for some help (Error: Expected a Expression) >> Allegro

    What is PLACE?
    And I need to repeat the question GCDEF already asked:
    Quote Originally Posted by GCDEF
    What are you trying to accomplish with that line? It makes no sense to me.
    Victor Nijegorodov

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    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
  •  





Click Here to Expand Forum to Full Width

Featured