Graphics and DX question, for beginners

Started by
6 comments, last by sirGustav 18 years, 7 months ago
Hey! I've read the article for beginners that say "first make Tetris, then Breakout, then Pacman..." etc. So I thought; OK! But... I don't know anything about how to make grahpics. (Background info: I've attended a computer science program for one year and I've only used Java, but I'm pretty good at the basics of OOP) So, my question is, what is a good way to start when it comes to graphics, and what would be suitable for the games mentioned? Also, can DirectX only be used with C++? I'm thinking about learning C++ because that seems to be what everyone is using, in that case would DirectX be a good place to start (same question if it can be used with Java)? If not, then what? Any help is greatly appreciated!
Advertisement
I've you've never done graphics, I'd advise to not start with DirectX. OpenGL is easier to learn, and you can use Java. What language you use doesn't matter when you're just learning. Choose one that you're comfortable with, and learn with that. C++ is always good to know, but learning a new programming language and graphics at the same time will make things unneccessarily difficult.

If you want to do C++ and DX, I'd advise Intro to 3D Game Programming with DX 9.0 by Frank Luna.
If you mean graphics as in images, you are about to discover the joy of programmer art :D

Don't worry too much about graphics initially, it is a skill that takes time to master. Obviously no-one likes bad art in their games, but you can draw some basic placeholder stuff (tetris - a load of squares, breakout, a load of rectangles and a circle, pacman - a circle with a bit cut out & some squares for ghosts...). The graphics of a game are generally loaded from normal image files, (bitmaps, .jpgs, .tga etc) so you can replace them with better ones at any time. Concentrate on making the game work first and then come back to worrying about graphics.

Alternatively if you really want nice graphics straight away you could always rip the art from other peoples versions of those games, or use internet clipart. As long as you're not planning on distributing or making money from your creations & are doing them as a learning experience I see no problem with this.
However (& this is important), if you want to sell them or even give them away, you will have to make your own art. Using other people's art and passing it off as your own is not a good idea & is intellectual property theft, the legal implications of which will cost you a lot of cash.

Other than that, have fun & let your imagination run wild. MS Paint comes with windows, so you've got a free, (very) basic tool that will get you started making graphics. If you're on linux you can go one better & use The Gimp.
Paint Shop Pro or Photoshop are two more advanced packages to look at.
"I must not fear. Fear is the mindkiller. Fear is the little death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past me I will turn to see fear's path. Where the fear has gone there will be nothing. Only I will remain." ~Frank Herbert, DuneMy slice of the web
I meant how to show things on the screen in the first place, not how to draw nice pictures :)

And are there any thorough, good OpenGL guides, or would you recommend books? In that case what book? Thanks!
Hi!

Nehe is a great place to start with OpenGL. You should also check out SDL

Hope this helps!
Hope I was helpful. And thank you if you were!
NeHe (for Open GL) (edit: beaten)
C++ book: The cs program I attended to used "C++ Direkt" by Jan Skansholm. I really haven't read it, but my fellow students says it was good(I only read it for reference).
I know people have made games with java, perhaps with the Java 2D API, don't know about it's speed though?
Thanks for the replys, but maybe learning OpenGL is a bit excessive at this point. Basically what I want is 2D graphics, to be able to make games like the ones mentioned in the first post. Or is OpenGL good for that too? Maybe I should just use Java's 2D API?

Question about grahpics with Java 2D (probably goes for many other APIs as well):
As I mentioned I've tryed the Java 2D API a little, just playing around with it. But, lets say I want to make any 2D game. Take Pacman for example. So, I draw a Pacman on the screen, on a black background. Then, when I want to move the Pacman I must of course draw him again. But the old one stays unless I paint that area black again. So far that's fine.

But let's say I want a background with some background image or texture. Then I could not simply paint the area black - I want the background back. If the texture or background image is bigger than that little packman, I could not redraw the whole background of course because then anything on top of it would visually disappear.

I must somehow remember what was behind the pacman and redraw that. Fine, I could do that, just have a little field for that in the Pacman class and the same thing for monsters. The ideal thing would be to have something like different layers and then not worry about it anymore. I could create this the way I have partly explained here, but since it's a beginner's first attempt there may be better, more commonly used, ways to do this. Is there? Or is it already in some kind of API I could use?

And, back to the first question, now that you know what kind of graphics I want to create, is OpenGL excessive or good for this?
The game could be something like this:
void draw() {  drawBkg();  drawLevel();  drawEnemies();  drawPlayer();}void main() {  // gameloop, needs a better one  while(true) {    if( keyDown(ESCAPE) ) break;    else {      update();      draw();    }  }}

drawBkg - draws the background image
drawLevel - draws the levels, it could be as easy as a for loop throguh some array
drawEnemies - draws the enemies, again it could be as easy as a for loop throguh some array
drawPlayer - draw the player
A better gameloop

Quote:And, back to the first question, now that you know what kind of graphics I want to create, is OpenGL excessive or good for this?

I use OpenGL for 2d graphics. I had a link that I used when I started OpenGL in 2d I used this. Maybe that will help you too ;)

This topic is closed to new replies.

Advertisement