moving a line in videomode 320*200

This is a discussion on moving a line in videomode 320*200 within the Game Programming forums, part of the General Programming Boards category; I dont know if this is the right place to ask this question but anyway. ive got a function called ...

  1. #1
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109

    moving a line in videomode 320*200

    I dont know if this is the right place to ask this question but anyway.
    ive got a function called setpix(color,x,y);
    this plots one pixel at the x and y co-ordinate with a certain colour

    Now the only thing i can come up with to let a line move is this way
    Code:
    int i,x=140,y=199;
    do{
          x=x-1;
          paddle(15,x,y);
          /*wait some millisec*/
          paddle(0,x,y);
          }
          while(getch()=='q');
    this is only a part of the whole coded but i guess you already figured how what im trying to do here
    Note that this way will only work if the background is also color=0;
    Now i just wanna know if this is a "good" way to move something accros the screen or not....
    I just know there has to be a better way because now there are small periods where u only see black and no line at all (this is when the loop restarts.....

    ::edit::
    can somebody help me out cause ive been thinking about this a while and with my little bit of knowledge i was only able to come up with this
    IF you ppl need more code to actually see what im trying to say then ill post it (just ask for it).
    Last edited by GanglyLamb; 12-25-2002 at 11:34 AM.

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    Hmmm was this a bad question or m i sortof banned on this forum...

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by GanglyLamb
    Hmmm was this a bad question or m i sortof banned on this forum...
    You're not banned but your question isn't the best.

    Are you trying to write a game loop? If so, maybe try the game board, as this one is for C only. Let me know if you want this thread moved.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109

    If you could move this thread to the game board :-)

    heres some more code .....
    Code:
    int setpix(int color, int x,int y)
    {
    	union REGS regs;
    	regs.h.ah = 0x0C;  /*  pixel plot */
    	regs.h.al = color;
    	regs.x.cx = x;     /* x location   0..319  */
    	regs.x.dx = y;     /* y location  0..199  */
    	int86(0x10, &regs, &regs);
    	return 0;
    	}
    int paddle(int color,int x,int y)
    {
    	int i;
    	for(i=0;i<40;i++){
    							x+=1;
    							setpix(color,x,y);
    							}
    	return 0;
    	}
    int main()
    {
    	int i;
    	int x=140,y=199;
    	paddle(15,x,y);
    	do{
    		/*to move the paddle tothe left*/
    		if(getch()=='q'){
    							 do{
    								 x=x-4;
    								 paddle(15,x,y);            /*paddle white color middle screen*/
    								 delay(50);
    								 paddle(0,x,y);             /*paddle blackcolor (else theres a line instead of justthe paddle*/
    								 }
    								while(getch()=='q');
    								 }
    	  }
    	  while(getch()!='b');                           /*press Btoexitthe app*/
    settext();
    return 0;
    
    	}
    I hope ive cleared things out a bit for now if there are anymore questions about the code just ask..<
    ::edit:: sry bout the wrong indentations (got mixed up while copying pieces of the code)

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>If you could move this thread to the game board
    Done.

    You might want to consider sorting out your tabs in your code, it doesn't display too well. Personally, I don't use a tab, instead my editor inserts 4 spaces when I hit the tab button. [/OT] [edit] Oops, I didn't see your edit re tabs.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving cursor to the end of line
    By behzad_shabani in forum C Programming
    Replies: 5
    Last Post: 05-30-2008, 12:41 PM
  2. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  3. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 06:58 AM
  4. Trouble replacing line of file
    By Rpog in forum C Programming
    Replies: 4
    Last Post: 04-19-2004, 10:22 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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