Like Tree2Likes
  • 1 Post By Shakti
  • 1 Post By nvoigt

Creating moving object. is any way to do it in other way?

This is a discussion on Creating moving object. is any way to do it in other way? within the C++ Programming forums, part of the General Programming Boards category; Hey, I get a problem with "graphics". I wrote code, where u can just move certain object( f.x. an object ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    9

    Creating moving object. is any way to do it in other way?

    Hey,

    I get a problem with "graphics".

    I wrote code, where u can just move certain object( f.x. an object is a symbol like a "@"), and i used getchar() to move it with keyboard buttons, i also used COUT to update my area, where is my object. The problem is, that every time i move my object (it doest matter in which direction) there refreshed all map (it's like a blink). And i understood that getchar() and COUT didnt suit to my idea to create game.

    question: is any other way to create it ? It's better that windows.h will not included.

    I drag my game here, u can check it, that all the time u move object, it REFRESH.
    here:
    Zippyshare.com - game.rar

    THANKS

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    I also thought about windows.h HANDLE functions with STD_OUT. (it's bad ,that it demands windows.h )

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    You may want to look up SetConsoleCursorPosition and related functions (for MS Windows), so you can set the cursor and redraw only those characters that have changed.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    Yes, that's nice, but what about compatibility with f.x. linux? i want to create program which can be run on platforms: ms windows & linux. there's anything else without windows.h?

    But nice, i will check this function, u got it what i mean and u really help. By the way, if is any other way to AVOID the windows.h library, please, reply to me.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    1,198
    Not tried it myself but you could give PDCurses a try: PDCurses - Public Domain Curses
    Salem likes this.

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    Why do you want to avoid including Windows.h?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    Yes, i know NCURSES, but well i tried to make it with SetConsoleCursorPosition, and now i have no ideas how to create it by using this function. Can anyone tell me the right path how to do that using SetConsoleCursorPoasition? Thanks. Btw, i haven't a lot of expierence in WINDOWS environment, only half-basics knowledge. T_T

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,176
    Can anyone tell me the right path how to do that using SetConsoleCursorPoasition?
    O_o

    We probably could if you posted how you are using it.

    [Edit]
    I'm not going to download your archive.

    If it is there, it is invisible to me.
    [/Edit]

    Soma

  9. #9
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    I didn't create right program with this function and to sum up it's a crap, not a program, so i'm asking u how to use it in my situation? In internet i hadn't find any information linked with my purpose.

  10. #10
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Post your code and your problem with it. We can't help you without it.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  11. #11
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    Actually, i need simple example how to use SetConsoleCursorPosition with objects controlling by kb keys.

  12. #12
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Putting your whole post into google gave me this as first result. Not bad for a start. NCurses will be more portable. It probably has great tutorials, too.
    Grouw Patter likes this.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  13. #13
    Registered User
    Join Date
    Oct 2012
    Posts
    9
    Thanks, it helps a lot. Like it! And i solved my problem. GJ.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving Object(s) Simulation
    By Distort in forum C++ Programming
    Replies: 10
    Last Post: 06-15-2011, 11:51 PM
  2. Object not moving to angle
    By mike_g in forum C Programming
    Replies: 1
    Last Post: 06-22-2007, 09:30 AM
  3. Replies: 4
    Last Post: 11-14-2006, 10:52 AM
  4. Moving a 3d object
    By Crossbow in forum Game Programming
    Replies: 4
    Last Post: 08-05-2002, 06:39 PM
  5. Moving the object '@' x and y?
    By bluehead in forum C++ Programming
    Replies: 4
    Last Post: 11-06-2001, 04:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21