Game programming

Moderators: None (Apply to moderate this forum)
Number of posts: 5361

This Forum Only

HURRAY I got mode13h VGA to work , but... a new problem Posted by MRuthless on 7 Dec 2004 at 6:10 PM
I am trying to draw simple geomtric shapes. I can get a rectangel to work, but wierd things happen when I do diagonal lines.
The following is the proto for the diaganol lines:

void dline(int x,int y, int len, int col);
void dline1(int x,int y, int len, int col);

Here is the definitons:

void dline(int x, int y, int len, int col)
{
for (int k=0; k<len; k++)
{
video_buffer[y*321+x+k*321] = col;
}

}
void dline1(int x, int y, int len, int col)
{
for (int k=0; k<len; k++)
{
video_buffer[y*319+x+k*319] = col;
}

Each work correctly individually when I draw them on a blank screen.
but when I use the follwing protoype and function to combine them into a shape the diaganol lines do not get placed in the appropriate place on the screen.

void shape(int xco, int yco, int xlen,int ylenr, int ylenl, int col);

void shapetest()
{
wall ( 0,0,20,40,40,blu);
}

void shape(int xco, int yco, int xlen, int ylenr, int ylenl,int col)
{
dline(xco, yco, xlen, col);
dline1(xco, yco+ylenr, xlen, col);
vline(xco, yco+(xlen/2), ylenl/2, col);
vline(xco +xlen, yco, ylenr, col);
}

If the following were an outline of the screen, this would be an example of my results:

--------------------------------
| \ <- (at 0,0)diagonal starts at 0,0 and the 2
| \ vertical lines are in the the upper right corner also
|
| \ <- at 0,30, I would think the diagonal would begin at 0,30
| \ but it doesn't. Both vertical lines in the shape shift lower
| and right and the diagonal appears to start at 40,40
--------------------------------
Any ideas? Because I wnated to be able to show the shape anywhere by changing the xco and yco, but when I do that the rectangles are okay, but the diaganol lines are now strewn all over the screen.

Re: HURRAY I got mode13h VGA to work , but... a new problem Posted by Johnny13 on 15 Dec 2004 at 8:41 AM
: I am trying to draw simple geometric shapes. I can get a rectangle to work, but weird things happen when I do diagonal lines.
Seems like you're reinventing the wheel and writing lowlevel drawing routine in C...look at GS_LINE() in the old version of GS (2years ago..) http://pheaven.com/c/MsgBoard/read.asp?Board=1&MsgID=269136 and other examples here http://pheaven.com/zone10/cat458/

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic