Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error: expected primary-expression before '.' token  (Read 4794 times)

0 Members and 1 Guest are viewing this topic.

Eragon0605

  • Newbie
  • *
  • Posts: 5
    • View Profile
error: expected primary-expression before '.' token
« on: June 14, 2010, 01:00:16 am »
Alright, so I'm making a tic-tac-toe game. I want to make it so that if the user clicks the upper left-hand corner of the screen, a 'X' appears. I am trying to use the following code:
Code: [Select]
while (App.GetEvent(Event))
        {
            unsigned int MouseX = Input.GetMouseX(); // Error 1
            unsigned int MouseY = Input.GetMouseY(); // Error 2
            bool LeftButtonDown = Input.IsMouseButtonDown(sf::Mouse::Left); //Error 3

            if ((LeftButtonDown == true) && (MouseX << 50) && (MouseY << 50))
            {
                SprCross1.SetPosition(25.f, 25.f);
                X1 = 1;
            }
        }

When I try to compile I get three errors saying "error: expected primary-expression before '.' token". What is the problem? I am following the tutorial's example exactly. Oh, and yes, I did put "using sf::Input" at the beginning of the program. I am using GCC, Linux Ubuntu, and C++.

kitchen

  • Newbie
  • *
  • Posts: 14
    • View Profile
error: expected primary-expression before '.' token
« Reply #1 on: June 14, 2010, 01:07:06 am »
You'll need to put this outside of the loop somewhere:

Code: [Select]
const sf::Input& Input = App.GetInput();

Eragon0605

  • Newbie
  • *
  • Posts: 5
    • View Profile
error: expected primary-expression before '.' token
« Reply #2 on: June 14, 2010, 01:58:59 am »
Ah, thanks! The compiler error is gone! Doesn't do what I want, but there's probably just some other messed-up piece of code somewhere...

EDIT: Found and corrected error. Was totally unrelated. Thanks kitchen for fixing yet another error. (It was still very much in the early development stage)

kitchen

  • Newbie
  • *
  • Posts: 14
    • View Profile
error: expected primary-expression before '.' token
« Reply #3 on: June 14, 2010, 02:03:57 am »
Quote from: "Eragon0605"
Ah, thanks! The compiler error is gone! Doesn't do what I want, but there's probably just some other messed-up piece of code somewhere...


The error is right here:

Code: [Select]
(MouseX << 50) && (MouseY << 50)

You think you are doing a less-than comparison when you are in fact doing a left shift by 50 bits on MouseX and MouseY. Change it to this:

Code: [Select]
(MouseX < 50) && (MouseY < 50)