Jump to content
  • Advertisement
Sign in to follow this  
Crazyfool

Simple 2d Graphics

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I did not know a decent title for this BUT here goes: I am working on a multiplayer card game similiar to Magic: The Gathering. If you don't know what that is, that;s fine, I'll do my best to explain. 1) Is there a "loose" requirement on dimensions of 2d graphics meaning, is it easier to display graphics in increments of 32 pixels or does it really not matter? If this is API specific, sorry to post here, but I'm very bad with graphics. 2) Look below first: SAD ATTEMPT AT A CARD:
 ____________________
|CARD NAME       COST|
| -----------------  |
| |                | |
| |                | |
| |    PICTURE     | |
| |        BOX     | |
| |                | |
| |________________| |
|CARD_TYPE_________  |
| |                | |
| |                | |
| |   TEXT         | |
| |      BOX       | |
| |                | |
| |                | |
| |________________| |
|__________EXTRA_DATA|
Ok, now, the background (outter edge) is going to be 1of 8 or so constant backgrounds ALL cards will have. My plan was to render the designated background (each card is color, and the background is that color, which a more stylish approach, so it is a image). Then I planned to render the picture box by loading and displaying whaterver picture is associated with that card, and then displaying the text, card type, name and extra data the same way (but by actually displaying words, not making graphics FOR the words). Now for the cost, I plan to do it the same way as textbut use symbols that represent things. HOPEFULLY that made sense, so my question is, is this a reasonable approach to this?

Share this post


Link to post
Share on other sites
Advertisement
Sounds quite reasonable to me.

Afaik there's no dimension requirement for displaying graphics. If you use textures in a 3D API (which would be used to display 2D content in your case=, however, there might be the restriction to power-of-2 textures. In this case you could still have non-power-of-2 images that are embedded into power-of-2 textures.

For the cost symbols you could use a different font which encodes digits as symbols. Lets say you need 3 swamps and 2 plains (IIRC what I know of Magic) you could display the number 22211 with 2 encoded as swamp symbol and 1 encoded as plain sysmbol in your font.

If you're not using a 3D API like OpenGL or D3D (where you're likely to use texture mapped fonts) but using a 2D Graphics API like the one that ships with Java, it won't be that easy to create fonts of your own. In this case you could just use some fixed symbol size, determine the number of symbols on the card, start at card-width - (number-of-symbols * symbol-size + left-margin-from-card-border), draw a symbol, move the position by symbol-size to the right, draw the next symbol, ... until you've drawn all the symbols.

Alternatively you could use UI widgets like buttons for your pictures and texts, have them rendered in "flat" style (at least in Java), and provide some functionality like an info screen if the user clicks on it.

Share this post


Link to post
Share on other sites
For a board game I have created I use OpenGL for rendering also the cards. I take an image of the card and render its value as text in its correct location, so that I only need one image for the cards.

As noted above the size restrictions should not realy be a problem for you. When using OpenGL or DirectX for rendering I would recommend using textures with a power of 2 size. I noticed that the texture rectangle extension of OpenGL is not widely supported yet. You can easily calculate the correct texture coordinates for you card (inside the power-of-two image) by hand or using a simple algorithm.

Share this post


Link to post
Share on other sites
Woa thanks for the replies.

As to what graphics engine, I was leaning towards directX but I have to look into it more. I havent started the graphics part because I'm sorting out a lot of the server stuff, and yes that is bad of me to keep putting it off. Also, I'm programming this in C++.

As for the fiorst response: I planned the cost to be symbols like images, of small dimensions, like say a little circle with a bone through it or something. Power of 2 images wouldnt be an issue, but I wasnt sure if I had to do a strict ratio like 1:1.

And for Possumdude0, why'd you stop?! MTG is a timeless game :)

Thanks ahgain!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!