Jump to content

Simple 2D Example

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
OutcastOrange

OutcastOrange

    Newbie

  • Members
  • Pip
  • 5 posts
This is a pretty simple request, I hope.

I have Visual C++ (Which I've gotten rather good at)
and DirectX SDK.

I've programmed a bunch of 2D stuff in other languages, but so far I've only been capable of text-based games in C++.
I learned that C++ doesn't do graphics on its own, and DirectX is required.

So I was browsing the samples that came with it, hoping to dissect one of them, and learn how it worked.
The only problem is that the "simple sample" they included, consisted of over 15 different components (.cpp, .h, .etc)


I would just like a program that uses DirectX and draws a basic window on screen, and then a sprite in that window.

The more simple the better, I want bare minimum, just so I can pick it apart line for line and learn how it works.

#2
brownhead

brownhead

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
If you're using Visual C++ than you might as well just use Window's GDI+ since your not worried about cross platform compatibility.

Check out the example on this page to get started.

Note: The reason I'm suggesting GDI+ over DirectX is because DirectX is mainly for 3D graphics, it can still draw 2D graphics really well, but it's a lot harder. GDI+ on the other hand is strictly for 2D graphics (I think).

#3
OutcastOrange

OutcastOrange

    Newbie

  • Members
  • Pip
  • 5 posts
If you help me out this one time, you very well may save my future!
Please dear friend, how do I follow this new GDI+ path?
It sounds so new and shiny.

Perhaps you know a better way to bridge the gap?
I long for a clear reply.

PS: Don't worry, I've just had a few perspective realizations and now reality seems to be fleeting from me.

#4
brownhead

brownhead

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
What are you having trouble with specifically? The example and references on MSDN should be pretty helpful, but perhaps you're having difficulty with the actual language?

#5
OutcastOrange

OutcastOrange

    Newbie

  • Members
  • Pip
  • 5 posts
I know how to make loops and use headers and reference libraries for my text based games.

I need to learn which libraries I will need for 2d programming, and then some basic commands for:
-Creating Sprites
-Hide/Show Sprites
-Change Sprite Image
-Change Sprite Position

Then I can really throw down some awesome.
Thank you for all of your help, I intend to learn more about GDI+ today.

#6
SolidState

SolidState

    Learning Programmer

  • Members
  • PipPipPip
  • 38 posts
For 2D stuff I like SDL which has quite a bit of community support. The software library is open source and Lazy Foo' Productions has a good tutorial for setting it up and getting to blit surfaces and render fonts as images, amongst other things.

There are a many SDL tutorials out there to affiliate you with its basic concepts.

#7
brownhead

brownhead

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
This is a guide to GDI+ using Visual C++ that does an excellent job at explaining everything. Read through it all and you should get a start.

Visual C++ GDI: Introduction

Look under the heading GDI Fundamentals and all other subjects in that row.

#8
OutcastOrange

OutcastOrange

    Newbie

  • Members
  • Pip
  • 5 posts
I've been browsing the stuff you guys suggested, and I've learned quite a bit.

I found this at brownhead's link:

Quote

1.Start a new project and name it Bitmap1

2.Create it as a Single Document application based on CView

3.In the Class View, expand everything and access the CMainFrame::PreCreateWindow() method.

What am I supposed to get out of "single document application based in CView"? That means gibberish to me.

Please advise.

#9
brownhead

brownhead

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
I'm guessing it's a project template. Hit New Project and then see if you can find something that sounds like that in the list of templates. But I'm not positive.

#10
OutcastOrange

OutcastOrange

    Newbie

  • Members
  • Pip
  • 5 posts
That's what I thought too. I tried a few different templates that sounded similar, and didn't get anything like what it describes...

I wish there was a step-by-step out there somewhere.
I did search extensively before posting on this forum the first time though.

#11
brownhead

brownhead

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
Keep looking through MSDN and google I suppose. You should find some other examples. But I'm afraid I don't have any good examples on my computer to give you :(.