Looking for some help (Error: Expected a Expression) >> Allegro
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

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

  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,204

    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
    Wallisellen (ZH), Switzerland
    Posts
    17,529

    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
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,746

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center