LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2006, 01:47 PM   #1
RHLinuxGUY
Member
 
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Rep: Reputation: 30
Question about SDL_Keysym and my program.


I have integrated SDL_Keysym into my text game, but I am having problems and I think I know what it is, just want to know for sure.

If I have this piece of code:

do {
while(SDL_PollEvent(&event)){
switch(event.type){
case SDL_KEYDOWN:
if(event.key.keysym.sym==SDLK_LEFT){
mpa.MoveChar(x, y);
break;}
else if(event.key.keysym.sym==SDLK_RIGHT){
mpa.MoveChar(+x, y);
break;}
else if(event.key.keysym.sym==SDLK_UP){
mpa.MoveChar(x, +y);
break;}
else if(event.key.keysym.sym==SDLK_DOWN){
mpa.MoveChar(x, -y);
break;}
case SDL_KEYUP:
break;}
}
}while(go == 0);

Does c++ understand incremented, decremented variables? Such as -x, or +y?

--EDIT--
It compiles just fine with my make file, so maybe its one of those bugs that aren't seen during compilation?

If want the actual source code, please ask, and I'll send it up to my server and post the address.
 
Old 02-26-2006, 01:58 PM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
mpa.MoveChar(x, +y); and
mpa.MoveChar(x, -y);

are both valid, but they are not doing what i think you want.
+ and + = +
+ and - = -

so if y = 10 the above lines equal
mpa.MoveChar(x, 10); and
mpa.MoveChar(x, -10);

I think you are looking for the pre increment and decrement. ie ++y and --y;

Last edited by dmail; 02-26-2006 at 02:01 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program Installation Question. swamprat Linux - Newbie 14 09-30-2005 04:13 PM
question about compiling program. Davno Linux - Software 3 07-15-2004 12:48 AM
Question regarding the screen program. nostrum Linux - Newbie 5 06-22-2004 09:17 PM
Graphics program question libranikki Linux - General 9 02-01-2004 01:41 AM
program startup question BajaNick Linux - General 2 01-11-2004 12:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration