Staying within a window
I'm curious to figure this out, could you post your code. (cpp file that the error is in)
I don't wanna post the whole soucre but here is most of that part of code starting with a few #defines
#define SCREEN_WIDTH 640;
#define SCREEN_HEIGHT 480;
The function is:
The errors all put to line 74 which is this line:
if (xpos => LEVEL_WIDTH)
And the 5 errors are:
expected primary-expression before '>' token
expected primary-expression before '=' token
expected `)' before ';' token
expected primary-expression before ')' token
expected `;' before ')' token
#define SCREEN_WIDTH 640;
#define SCREEN_HEIGHT 480;
The function is:
void CheckBounds() {if (xpos => LEVEL_WIDTH){ {xpos = LEVEL_WIDTH - ship_WIDTH;} if (ypso => LEVEL_HEIGHT) {ypos = LEVEL_HEIGHT - ship_HEIGHT;}}}
The errors all put to line 74 which is this line:
if (xpos => LEVEL_WIDTH)
And the 5 errors are:
expected primary-expression before '>' token
expected primary-expression before '=' token
expected `)' before ';' token
expected primary-expression before ')' token
expected `;' before ')' token
I'm still thinking about the errors, but I was just curious about your defines. Do you have ";" and the end of them like what you posted?
If so remove the ";" from the define statements.
Quote:#define SCREEN_WIDTH 640;
#define SCREEN_HEIGHT 480;
If so remove the ";" from the define statements.
I did have it for a few of the things. I took them out and I still get the errors. I actually get more now b/c it says the same 5 errors for the line:
if (ypso => LEVEL_HEIGHT)
It doesn't like these 2 lines:
if (xpos => LEVEL_WIDTH)
and
if (ypso => LEVEL_HEIGHT)
but I don't really see what's wrong with them.
if (ypso => LEVEL_HEIGHT)
It doesn't like these 2 lines:
if (xpos => LEVEL_WIDTH)
and
if (ypso => LEVEL_HEIGHT)
but I don't really see what's wrong with them.
I created a function like the one in your code and just made some variables so that I wouldn't get errors for the code, but I got errors. When looking through the code, you have two "{" that you don't need. And I change the "=>" to ">=" and it compiled fine.
Edit: the "//{" are the two "{" that shouldn't be there
void CheckBounds() { if (xpos >= LEVEL_WIDTH) { //{ xpos = LEVEL_WIDTH - ship_WIDTH; } if (ypos >= LEVEL_HEIGHT) { ypos = LEVEL_HEIGHT - ship_HEIGHT; }//}}
Edit: the "//{" are the two "{" that shouldn't be there
Also note that you will probably need to do a similar test for the other two sides of the window (xpos <= 0 and ypos <= 0) if such behaviour isn't already present in your program.
Hmmm.....I changed it to like you said and I still got that same error about expecting primary expression.
I am gonna have to mess around with it tomorrow I guess. Thanks for the help. I don't know if I have an extra } in there that's causing it or what. I'll post or look here tomorrow to see if anything else has changed.
I am gonna have to mess around with it tomorrow I guess. Thanks for the help. I don't know if I have an extra } in there that's causing it or what. I'll post or look here tomorrow to see if anything else has changed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement