Getting started example needed

How do I draw a 2d box on the screen? Or even better a 2d circle.

I guess I should use DrawPrimitives but a little example would be nice..

After that I would like to draw some text, do I need to create a bitmapped font for that and draw using sprites?

/ Erik

[284 byte] By [eriklarsson] at [2007-12-23]
# 1
Since there is no fixed function support it is a lot harder to just draw some lines or boxes directly on the screen. Currently you can only draw sprites or do your own custom 3d stuff (see Graphics->3D for help, but there isn't much).

I wrote a line manager today (3d), but it was not very easy ..
Hopefully there will be more helper classes available to draw boxes, lines, and simple stuff directly without having to create custom formats, vertex buffers and doing all the low level stuff.

There is also no font support, not only single class will help you out with that. You have to do your own bitmapped font stuff, again not very easy right now. Need more helper classes ^^

abi at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

Microsoft has provided an awesome getting started tutorial inside the help for Visual C# Express. To access it, click on "Help" in Visual C#, now select

"Content". In the sidebar that appears on the left, you'll see an "XNA"

category. Expand that category.

Now you should see a sub-category titled "XNA Game Studio Express". Expand that category.

Below that category you'll see a sub-category titled "Getting Started with XNA". Expand that category.

You

will now see a sub-category title "Your First XNA Game", click on that

category and enjoy following the first tutorial to creating your first

XNA Game.

By the time you are done with their tutorial, you should be able to draw a 2D sprite on the screen and have it move around.

Also, look at this thread for some other tutorial advice and sites.

GeorgeClingerman at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3

I know it's harder than drawing a sprite, thats why I would like some help :)

I would like to use XNA for prototyping, and I think drawing boxes and circles is much better when the design isn't finished. You can scale them to any size and quickly add stuff from code. When you have a working fun game with boxes and have decided what size they need to be you can start drawing or hire an artist.

/ Erik

eriklarsson at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4
George Clingerman wrote:

Microsoft has provided an awesome getting started tutorial inside the help for Visual C# Express. To access it, click on "Help" in Visual C#, now select

"Content". In the sidebar that appears on the left, you'll see an "XNA"

category. Expand that category.

Now you should see a sub-category titled "XNA Game Studio Express". Expand that category.

Below that category you'll see a sub-category titled "Getting Started with XNA". Expand that category.

You

will now see a sub-category title "Your First XNA Game", click on that

category and enjoy following the first tutorial to creating your first

XNA Game.

By the time you are done with their tutorial, you should be able to draw a 2D sprite on the screen and have it move around.

Also, look at this thread for some other tutorial advice and sites.


Ohh man this is going to be awesome! Thanks George!
ryan31337 at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5

abi wrote:
There is also no font support, not only single class will help you out with that. You have to do your own bitmapped font stuff, again not very easy right now. Need more helper classes ^^

I just addressed this issue in another thread, so rather than repeat myself, I'll just point you at it:

Unicode and Bitmap Fonts

The long and the short of it is that I wrote a font helper class that you might find useful.

GaryKacmarcik at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 6
Ok, after starting my own thread asking "What is the XNA substitute for Microsoft.DirectX.Direct3D.Line"

I was re-directed back to this thread indicating mine was a duplicate. I found that odd since I thought I'd already responded in this thread, but now upon re-reading the original question I see that the forum moderator was indeed corrrect. So, I re-state.

I

was just looking through some of my old Managed DirectX projects trying

to convert various parts to XNA and figuring out how to draw a line in

XNA was one thing that I'm not having an easy time converting.

I

started to go down the path of using DrawPrimitives and was able to get

a line drawn on the screen but I had no control over. It seemed like

the fact that I got a line at all was more of a fluke than anything

because I was just setting parameters to see what they changed without

really understanding what each one meant.

Has anyone else been

playing around with drawing lines to the screen and want to share the

method they used? I'm going to keep playing with it, but I've gotten

about as far as I'm going to without discovering some new information

that makes a solution click for me, so feel free to offer up any advice

at all to point me in the right direction.

Thanks for any help or advice you can give.

GeorgeClingerman at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 7
I stumbled across this link earlier that has some info on drawing lines.

I haven't tried it but hopefully it's useful.

-Greg.

iNwFireFly at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 8

Thanks for the link, Greg. I wrote a little class for rendering lines (2d,3d), the BoundingBox and BoundingSphere from the XNA framework :

http://markus.rubicon-net.de/code/

VectorRenderer.cs, it just needs a reference to the GraphicsDevice and the view-projection matrix of your scene.

LittleSettler at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 9

Since the API does not yet support a simple static method

like DrawShapes.Line(point A, point B), what about drawing a basic sprite with

the proper rotation.

mySpriteBatch.Draw(mySprite,

picBox, picBox, Color.Red, rotationRad, vOrig,SpriteEffects.None, 0);

All you need is a tiny bit of trigonomic magic to calculate the rotation and

the dimensions of your rectangle.This

completely avoids the need for vertices and shading and matrixes and the like.(any help with trig magic is appreciated)
Here is what I have done so far.

  1. Basic

    sprite rendered and moving on the window with a background image.

  2. Change

    the dimensions of the sprite rectangle so that the height is one or two pixels.This will squish any image into a nice

    line.

  3. Use a

    version of the mySpriteBatch.Draw() method that includes the rotation

    parameter.So far I have just hard coded

    values.

To Do:

  1. Create

    a class that accepts two coordinates.

  2. Calculate

    the delta x and delta y between the coordinates.

  3. Calculate

    the length and rotation of my sprite rectangle. The height will be one or

    two pixels.

DavidSiegel at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...