944,088 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 6283
  • C++ RSS
Dec 31st, 2006
0

Moving Objects in Turbo C++

Expand Post »
How do you make an object, say a rectangle, move in turbo c++, using right and left arrow keys?

I want the object to move when a user presses right or left arrow keys.

Please reply ASAP either here or at my email <<email address snipped>>
Last edited by ~s.o.s~; Dec 31st, 2006 at 9:56 pm. Reason: Email address snipped according to site policy.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
joydsouza90 is offline Offline
25 posts
since Dec 2006
Dec 31st, 2006
0

Re: Moving Objects in Turbo C++

Use the nonstandard getch() to handle your keyboard input - but beware, it's not supported on all compilers and the input is non-buffered. That being said, there's no C/C++ standard for asynchronous input as far as I know, so using getch() is your best bet.

Using variables to keep track of the object's location, you can then draw it using Turbo's graphics.h file. There's more information about Turbo graphics here:
http://www.onecore.net/turbo-c-graphics-programming.htm

Hope this helps
Last edited by John A; Dec 31st, 2006 at 6:28 pm. Reason: fixed link
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Jan 1st, 2007
0

Re: Moving Objects in Turbo C++

hey thanx...but i want to know the exact syntax i need to write to make a rectangle move when a user presses the right or left key. I'm new to Turbo c++ and i would really need all the help i can get.

Thanx a lot
Reputation Points: 10
Solved Threads: 0
Light Poster
joydsouza90 is offline Offline
25 posts
since Dec 2006
Jan 1st, 2007
0

Re: Moving Objects in Turbo C++

No one will write the exact code for you.

So do some reading and write it yourself.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jan 1st, 2007
0

Re: Moving Objects in Turbo C++

hey thanx...but i want to know the exact syntax i need to write to make a rectangle move when a user presses the right or left key. I'm new to Turbo c++ and i would really need all the help i can get.

Thanx a lot
Start with something a bit more trivial - Learn how to manipulate user input, and how to generate output first. then you'll be one step towards creating a program which combines input/output.

There is no "exact" syntax for doing what you want.. How you accomplish it is entirely up to you, although you need to learn the basics first, then you'll know what options you have available to you.
Reputation Points: 307
Solved Threads: 62
Posting Pro
Bench is offline Offline
565 posts
since Feb 2006
Mar 22nd, 2010
-1

HELP ME!!!!

everybody can help me?????
i want to know how to do the output moving in coding c++....
HELP ME!!!!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kingkong01 is offline Offline
1 posts
since Mar 2010
Mar 22nd, 2010
0

here's your solution

you can use function getkey() for getting integer for that key
C++ Syntax (Toggle Plain Text)
  1. {
  2. int ch;
  3. if(kbhit())
  4. {
  5. ch=getkey();
  6. }
  7.  
  8. switch(ch)
  9. {
  10. //for right errow key
  11. case 77:
  12. // type your code here i.e. if you press the right errow key this will happen
  13. //gotoxy(x,y) function can help you here
  14.  
  15. //for left errow key
  16. case 75:
  17. // type your code here
  18.  
  19. //for up errow key
  20. case 72:
  21. // type your code here
  22.  
  23. //for down errow key
  24. case 80:
  25. // type your code here
  26.  
  27. }

you can make you own program which will let you know the integer value that getkey() returns for all keys..try it yourself

if u get some error like " function getkey should have a prototype " paste goto.c attached with solution file in bin of your turbo cpp compiler.

hope this will hlp ...
Attached Files
File Type: c GOTO.C (609 Bytes, 127 views)
Last edited by kirit275; Mar 22nd, 2010 at 7:25 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kirit275 is offline Offline
13 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: pass vector by value or by reference?
Next Thread in C++ Forum Timeline: inputting a polynomial





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC