# 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. ## 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).

2. Hmmm was this a bad question or m i sortof banned on this forum...

3. 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.

4. ## 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. >>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]  Oops, I didn't see your edit re tabs.

Popular pages Recent additions