bouncing ball project

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2006
Posts: 15
Reputation: henks is an unknown quantity at this point 
Solved Threads: 0
henks henks is offline Offline
Newbie Poster

bouncing ball project

 
0
  #1
Oct 5th, 2008
first of all, I wanna say hi to u all as I'm new to daniweb. I'm a freshman in a college so I don't know much of c yet. So please be understanding in case that I will ask some n00b question later on
So this is my problem...first one
I was using this code to get input from player to move the pad right and left
  1. while(i<10)
  2. {i++;
  3. clrscr();
  4. mov='s'; //supposed to be null, need more knowledge about \0
  5. y=10;
  6. gotoxy(x,y);puts(pad);/*supposed to remove the cursor if it's possible. Ended up using puts to make the cursor less noticeable*/
  7. mov==getch();
  8. if(mov='d')//supposed to be right arrow, don't know how to
  9. {x=x+1;
  10. clrscr();
  11. gotoxy(x,y);puts(pad);
  12. }
  13. else if(mov='a')//supposed to be left arrow
  14. {x=x-1;
  15. clrscr();
  16. gotoxy(x,y);puts(pad);
but I ended up getting right movement with anykey pressed

also another problem is getting the ball move as the time passed (I have no idea how to)
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: bouncing ball project

 
0
  #2
Oct 5th, 2008
> mov==getch();
> if(mov='d')//supposed to be right arrow, don't know how to
You got them both wrong
= is for assignment (the first one)
== is for comparison (the second one)
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 15
Reputation: henks is an unknown quantity at this point 
Solved Threads: 0
henks henks is offline Offline
Newbie Poster

Re: bouncing ball project

 
0
  #3
Oct 5th, 2008
Yay...thanks, Salem
New things for me

but how about my second question about time-based movement? or rather I called GUI in C? is it even possible? if it is, please refer me to the materials.

thanks a bunch though ^^
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: bouncing ball project

 
0
  #4
Oct 5th, 2008
Which OS / Compiler are you using?

Sure it's possible, but it won't be standard C anymore.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 15
Reputation: henks is an unknown quantity at this point 
Solved Threads: 0
henks henks is offline Offline
Newbie Poster

Re: bouncing ball project

 
0
  #5
Oct 6th, 2008
I'm using Borland C++ 5.0 in windows xp
I'm not sure which version my compiler is though...
What do you mean about not standard C anymore? Is it about making and using custom library? I've downloaded a source of snake game and I saw some custom *.h files included in it...what I'm curious about is how to produce our own library, I mean what kind of IDE supports making of *.h library? Can you provide me some simple examples of *.h source?
I'm sorry for asking so much question XD
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: bouncing ball project

 
0
  #6
Oct 6th, 2008
> What do you mean about not standard C anymore?
Meaning you can no longer pick a random C compiler (say for your Cray supercomputer or your mobile phone), and have your program work on all of them.

> Is it about making and using custom library?
Not necessarily. It could just be using the header files which describe the API of the OS you happen to be using. The Win32 API for example has many useful things which could be used to solve this problem.

Check out the console tutorials here
http://www.adrianxw.dk/SoftwareSite/index.html
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 15
Reputation: henks is an unknown quantity at this point 
Solved Threads: 0
henks henks is offline Offline
Newbie Poster

Re: bouncing ball project

 
0
  #7
Oct 7th, 2008
LoL
I almost got headache. No doubt it is not standard C anymore. I haven't solved my problem yet, but as it's too advanced for me to solve, let's suppose it's solved. At least I know where to find tutorial if I confuse myself with this kind of problem in the future.

Again, Tons of Thanks to Salem

-Problem's solved-
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC