Umm this is probably a very dumb question, but how do you draw a circle??
I know how to draw things like triangles and rectangles, but I haven't come across a circle as of yet.
Umm this is probably a very dumb question, but how do you draw a circle??
I know how to draw things like triangles and rectangles, but I haven't come across a circle as of yet.
PuterPaul.co.uk - Portfolio site
I'm not really too sure how to go about this, basically I'm trying to program a breakout clone. I've already made a series of bitmaps for the game to use, i.e. the blocks, paddle and the ball.
Reading around I have come to the impression that even though this is a 2d game that I have to use vertices and matrices.
I had originally thought that what happened was bitmaps were loaded into the game and used as the objects, but it seems that the shapes are created and then the bitmaps are textured onto them!!!!
Also is there some sort of layering system, as in photoshop i.e. where the background of the D3D app can be set and then layers of objects can be put on top???
Someone please give me a good explanation cos I am mega confused right now!!!!
PuterPaul.co.uk - Portfolio site
well, I don't know directx, so there might be a function to draw a circle, but here is another way...using putpixel.
for (degrees=0;degrees<360;degrees++)
{
x=cos(degrees*PI/180)*radius;
y=sin(degrees*PI/180)*radius;
putpixel(x,y);
}
multiplying degrees by PI/180 converts it to radians, which is what all the trig functions in C use. Radius is the radius of your circle, obviously, and I just used a psuedo putpixel (: You can obviously optimize that a little bit...but that is probably good enough for a 2D game
Away.
Assuming you're using something like ID3DXSprite, this is what happens : You define a primitive ( a rectangle, consisting of 2 triangles ) and then texture your bitmap on it.I had originally thought that what happened was bitmaps were loaded into the game and used as the objects, but it seems that the shapes are created and then the bitmaps are textured onto them!!!!
To draw a circle, you can :
1 - Use a bitmap
2 - Make a loop like the one blackrat wrote, but instead of plotting pixels, store the x & y values in a vertex array/buffer and then render the array/buffer as a linestrip using DrawPrimitiveUP/DrawPrimitive
You can achieve that by :Also is there some sort of layering system, as in photoshop i.e. where the background of the D3D app can be set and then layers of objects can be put on top???
1 - Rendering ( drawing ) your objects in order : The background first, and then the objects. That'd require you to classify your objects to layers, and then render the layers in order.
2 - Use Z buffer : That means you will have to enable z buffering.
I'm not sure if it works with transformed and lit ( 2D ) vertices ( I think it does, since TL vertices have a z member ), but if it doesn't, you can use untransformed vertices along with orthogonal projection. Orthogonal projection gives you a means to do 2D graphics in DirectGraphics with all the features of 3D graphics ( like doing rotations using matrices ).
Muhammad Haggag