C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #31  
Old November 7th, 2008, 07:39 AM
curtcoll08 curtcoll08 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 22 curtcoll08 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 56 m 52 sec
Reputation Power: 0
ok mate gotta learn somewhere im trying to figure out why its giving me 2 grids instead of one if postioned the x in the middle whih was easy lmao just cant see where its loopong it twice

Reply With Quote
  #32  
Old November 7th, 2008, 07:45 AM
curtcoll08 curtcoll08 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 22 curtcoll08 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 56 m 52 sec
Reputation Power: 0
grrh cant see why its giving me 2 grids well im of out now so ill try later see why its doing this

Reply With Quote
  #33  
Old November 7th, 2008, 07:49 AM
jasonlang jasonlang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 164 jasonlang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 3 h 13 m 21 sec
Reputation Power: 10
it's looping the grid twice due to the sloppy way we are doing keyboard reading. i have this problem too

using getch like I originally suggested gets rid of this problem ( i checked this and it works)


replace the line :

#include <stdio.h>

with :

#include <conio.h>

// (not every system has conio and getch, though !)


replace

suchAndsuch = getchar()

with

suchAndsuch = getch()

Reply With Quote
  #34  
Old November 7th, 2008, 11:36 AM
curtcoll08 curtcoll08 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 22 curtcoll08 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 56 m 52 sec
Reputation Power: 0
that is quite cool that allows me to enter the num pad and instead of actually pressing enter it does it just as if u was using up and down on the keypad

Reply With Quote
  #35  
Old November 7th, 2008, 11:46 AM
jasonlang jasonlang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 164 jasonlang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 3 h 13 m 21 sec
Reputation Power: 10
yeah and once you are using getch(), you can make it completely real-time for games by doing this simple improvement :

instead of just

Code:
key = getch();

you write something along the lines of :-

Code:
if( kbhit() ) // kbhit() is also from <conio.h>, by the way
    key = getch();
else
    key = 0;


you see, getch() will pause the program waiting for a key.

kbhit() returns true if a key is waiting to be read, otherwise returning false.

so the above this method will let your program run animated, and will only try and read a key when you have already hit one.

so, you could make an enemy to chase the player now if you wanted.

Although, with console it can be hard to see the animation clearly

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Urgent help with loops


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap