Creating a 2D Contra or Zelda like game

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 10511 Views - Last Post: 03 July 2012 - 01:59 PM Rate Topic: -----

#1 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 12:07 AM

Okay so I have a whole summer off and i would like to start on some kind of project. I was thinking of maybe a basic 2D game like Contra, or Zelda. I would use basic shapes as the 2d sprites and work on the art part after.

I've taken : intro to programming(C++), Object Oriented programming, and advanced programming with data structures. The problem is, all the programming assignments i have done are like "Toy" assignments, they look nothing like code that is being used in actual programs (like the ones in open source project code). My Prof says that the first step to transition from an academic programmer to a productive programmer is learn the c++ standard template libraries.
What would i need to know or learn to get a basic working game?

Thank you all in advance for your help.

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a 2D Contra or Zelda like game

#2 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 12:10 AM

1. Basic Enemy AI
2. Screen scrolling
3. Animated avatars
4. Textures
5. Object intersection
6. A health system

It's a rather large task. But it can be done!
Was This Post Helpful? 0
  • +
  • -

#3 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 12:23 AM

View PostDimitriV, on 06 May 2012 - 11:10 PM, said:

1. Basic Enemy AI
2. Screen scrolling
3. Animated avatars
4. Textures
5. Object intersection
6. A health system

It's a rather large task. But it can be done!


It's ok if it's a large task. It can be an ongoing project. Just something to work on during down time from school.

I think the first 2 important things that i should start on is object intersection and screen scrolling. By searching object intersection, it shows that c++ has a built in STL set_intersection. I think i will need to read a book on C++ STL before starting on something like this huh?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6079
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 03:43 AM

Moved to Game Programming.
Was This Post Helpful? 0
  • +
  • -

#5 blindstone  Icon User is offline

  • D.I.C Head

Reputation: 21
  • View blog
  • Posts: 175
  • Joined: 17-August 11

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 07:55 AM

probably start off by learning about the two main options for graphics handling (OpenGL & DirectX)
Then just play around with drawing and moving graphics that have been drawn. Start maybe by doing a pong or tic tac toe before jumping right into your project otherwise you will fall on your face alot.
Was This Post Helpful? 0
  • +
  • -

#6 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 09:20 AM

View Postjaay5389, on 07 May 2012 - 07:23 AM, said:

View PostDimitriV, on 06 May 2012 - 11:10 PM, said:

1. Basic Enemy AI
2. Screen scrolling
3. Animated avatars
4. Textures
5. Object intersection
6. A health system

It's a rather large task. But it can be done!


It's ok if it's a large task. It can be an ongoing project. Just something to work on during down time from school.

I think the first 2 important things that i should start on is object intersection and screen scrolling. By searching object intersection, it shows that c++ has a built in STL set_intersection. I think i will need to read a book on C++ STL before starting on something like this huh?



You are putting the horse wayyyy before the cart starting with collisions and scrolling the screen. At the very least, you have to get something on the screen first! set_intersection doesn't do what you think it does either. It is about taking two datasets ( as iterators ) and creating a third dataset as a result based on equality between the two sets. This is not how you would determine collisions.

If I could make a simple suggestion, I will echo what blindstone said. Start small, much smaller than you have. For a Contra style game, the list DimitriV provided literally represents about 10% of what you would actually need to do. Level editing, loading, state management, audio, IO, animation, spritesheets ( both authoring and code ), etc etc etc...

Start smaller, like Pong small. Get yourself familiar with the most common 2D gaming libraries for your chosen language. Getting up to speed with the likes of SFML or SDL will take you a number of weeks alone!
Was This Post Helpful? 0
  • +
  • -

#7 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 12:13 PM

Hmm okay. a pong style game first would be a good idea. All the coding i have done so far has been simple algorithms that already existed!(data structures) and some basic class implementations.

I think i will get this book for understanding c++ STL

C++ STL

and then this one for understanding what needs to be done, it also covers some of the things
others have said i should learn(direct x, sprite stuff, animation stuff)

Advanced 2d Game Developmentp

Thanks for all the advice and direction!
Was This Post Helpful? 0
  • +
  • -

#8 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Re: Creating a 2D Contra or Zelda like game

Posted 07 May 2012 - 12:27 PM

View Postjaay5389, on 07 May 2012 - 12:13 PM, said:

Hmm okay. a pong style game first would be a good idea. All the coding i have done so far has been simple algorithms that already existed!(data structures) and some basic class implementations.

I think i will get this book for understanding c++ STL

C++ STL

and then this one for understanding what needs to be done, it also covers some of the things
others have said i should learn(direct x, sprite stuff, animation stuff)

Advanced 2d Game Developmentp

Thanks for all the advice and direction!



scratch that, i think i will pick up the beginners game development book first.
Beginning Game Programming

is there a way to edit a post?
Was This Post Helpful? 0
  • +
  • -

#9 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: Creating a 2D Contra or Zelda like game

Posted 08 May 2012 - 04:55 AM

You could take a look at my tutorials linked in my signature. They should be a good starting point for you.
Was This Post Helpful? 2
  • +
  • -

#10 Galaxy_Stranger  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 100
  • Joined: 07-February 06

Re: Creating a 2D Contra or Zelda like game

Posted 16 May 2012 - 06:48 PM

@jaay5389 - Yeah, listen to staycrisp. I wouldn't grab those gaming books just yet. Books are real hit and miss. I decided not to get that book when I saw it at the store. Because it looked like a bunch of marketing crap where they show you a few pages of code and leave out the rest of the engine for you to study. They are really expecting you to have more experience - they're rarely written for people with no experience.

You might want to go to the SDL site and check out how to use a 3rd party library to get your feet wet. SDL is awesome for 2D platformers as well as other stuff. As well, the site has lots of great tutorials that get you used to using the library in a gaming context. Plus, it's multiplatform.

If you're adventurous, you could check out something like Panda3D, which also has a large community and many tutorials.

This post has been edited by Galaxy_Stranger: 16 May 2012 - 06:49 PM

Was This Post Helpful? 0
  • +
  • -

#11 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Creating a 2D Contra or Zelda like game

Posted 17 May 2012 - 11:43 AM

Absolutely nothing beats ToyMaker.
Was This Post Helpful? 0
  • +
  • -

#12 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 581
  • View blog
  • Posts: 1,292
  • Joined: 24-April 12

Re: Creating a 2D Contra or Zelda like game

Posted 21 May 2012 - 02:24 PM

View Postjaay5389, on 07 May 2012 - 12:07 AM, said:

Okay so I have a whole summer off and i would like to start on some kind of project. I was thinking of maybe a basic 2D game like Contra, or Zelda. I would use basic shapes as the 2d sprites and work on the art part after.

I've taken : intro to programming(C++), Object Oriented programming, and advanced programming with data structures. The problem is, all the programming assignments i have done are like "Toy" assignments, they look nothing like code that is being used in actual programs (like the ones in open source project code). My Prof says that the first step to transition from an academic programmer to a productive programmer is learn the c++ standard template libraries.
What would i need to know or learn to get a basic working game?

Thank you all in advance for your help.


I started doing a 2D game in C++ with DirectX a couple of years ago. My advice, for what it's worth is "take a step back" and get into XNA.

Sounds like you can code in C pretty well, and understand the basic OOP stuff. C# is the language of XNA and if you haven't coded in C#.Net you're pretty much going to find that you already know how to code in it. It's basically just C programming with an extensive system of libraries. Super easy if you do C++. And XNA is built on top of that.

Now, this may seem to be a huge step backwards for you, since you're coming from the world of C++, but if you want to learn game programming -trust me- it's not. Game programming is amazingly complicated and approaching it through XNA allows you to get started without worrying about really low level stuff like initializing a graphics card and hardware issues that have nothing to do with YOUR game.

But the biggest reason for the beginning C++ game programmer to start with XNA is that there is "relatively speaking" a whole lot of tutorials and info and help out there on how to do it.

If you're like me you're probably skeptical. I wanted to build a game in C++ with DirectX and had to try XNA before warming up to it. Once I did, I've forgotten about C++ and DirectX. I'm working on 3D projects and haven't run into significant performance problems with XNA. Plus, it's one of those situations where 90% of what you learn programming games in XNA will transfer over to C++/DirectX game programming where everything is more difficult including getting help.

Microsoft has a free version of Visual Studio for C# and you can download XNA for free. So it doesn't cost anything to get started. One thing you need to be aware of though is that there were some pretty major changes to the drawing methods between the old XNA 3.1 and the latest XNA 4.0. So code written for one won't run on the other without modifications. You can still download either version, I think. 3.1 works with Visual Studio 2008 and 4.0 works with VS2010, but -again- you can download either for free. There are more books written teaching 3.0/3.1 but other than that it's probably better to just go to 4.0. Code not related to drawing on the screen seems mostly portable between versions. So the old books aren't "entirely" useless.

Plus, if you're willing to do 2D game development, that's what XNA is really all about. I'm using it to learn 3D, but I think Microsoft mainly wanted it to allow budding game developers to write 2D games for XBox and Windows Phone. Which brings up another point that some people like and that's that there is a built in market for games on that platform. But personally I only care about Windows development and it does that even better.

And don't get the idea that this is some game engine or level editor where you aren't going to "learn" anything about actual game development. Especially, in 3D XNA can be pretty "thin". For example, there's no built in capability to annimate 3D models and you have to write your own. I think it supports 2D better than 3D. Anyway, what I'm trying to say is it's mostly just a wrapper for DirectX and gives you enough library functions to get you going pretty well, but you're going to actually learn about game programming doing this. This is low level programming - not a level editor. You actually have to learn programming to do this. So for you, it sounds perfect.

And I really think XNA is a great place to start for people who one day want to learn to write games in DirectX with C++. There's just so much that you will learn in XNA that you'll use in your DirectX games that it's not even funny.

So, to me it sounds like you're pretty much the perfect candidate to start playing around with game development in XNA.

This post has been edited by BBeck: 21 May 2012 - 02:33 PM

Was This Post Helpful? 1
  • +
  • -

#13 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Re: Creating a 2D Contra or Zelda like game

Posted 03 July 2012 - 09:42 AM

Hello guys and thanks for the wonderful suggestions. I haven't come back to this thread in a while, but just an update, i've actually read the beginning programming book.I have ended up sticking with DirectX. The reason why is because since C++ is fresh in my mind, it would expand on what I learned in C++ and I wouldn't have to worry about forgetting the basics of C++ before studying DirectX. I plan to go into C# and XNA after I learn the concepts of DirectX though.

I've gone through Surfaces,Drawing/Animating/transforming sprites, sprite collision, and next is scrolling the background(which I am very excited for). I used what i learned so far and created a 1 player pong game (ball bounces on every wall except players). It works fine but it seems like its very unorganized and could have been coded with better methods than using a bunch of if statements. Please look it over and critique what ever sticks out to you. I still have to learn more about drawing sprites before I can use them so i had to use Surface. Thanks.

void Game_Run(HWND window)
{
    //make sure the Direct3D device is valid
    if (!d3ddev) return;

    //update input devices
    DirectInput_Update();

	//Game Code HERE
ball.posX =(ball.posX + directionX);
ball.posY = (ball.posY + directionY);

//width and height for contact with paddle
int cy = paddle1.posY + 120;
int bx = paddle1.posX + 12;
int by = paddle1.posY - 60;
int cx = paddle1.posX + 24;

	

//If ball reaches edges of the screen or player paddle, bounce
if (ball.posY > (SCREENH - 60) || ball.posY <33) directionY = directionY *-1;
if (ball.posX > (SCREENW - 20))directionX = directionX *-1;

if (ball.posY > by && ball.posY < cy && ball.posX > bx && ball.posX <cx) directionX = directionX *-1;


//if up and down arrow, move paddle
  if (Key_Down(DIK_DOWN)&& cy < SCREENH-45) paddle1.posY += 6.0f;
  if (Key_Down(DIK_UP)&& paddle1.posY > 38) paddle1.posY -= 6.0f;


//Reset game if ball reaches end of screen
if (ball.posX < 0) ball.reset();
    
    //clear the backbuffer
    d3ddev->ColorFill(backbuffer, NULL, D3DCOLOR_XRGB(255,255,255));

    //start rendering
    if (d3ddev->BeginScene())
    {

		//Draw the top and bottom border
		DrawSurface(backbuffer,10,8,border_surface);
		DrawSurface(backbuffer,10,985,border_surface);

		//draw the Paddles
		DrawSurface(backbuffer, paddle1.posX, paddle1.posY, paddle_surface);
		DrawSurface(backbuffer, paddle2.posX, paddle2.posY, paddle_surface);
        //draw the ball
        DrawSurface(backbuffer, ball.posX, ball.posY, ball_surface);
    
        //stop rendering
        d3ddev->EndScene();
        d3ddev->Present(NULL, NULL, NULL, NULL);
    }


After learning about scrolling background and sprites, I will try and create a simple Mario or R-Type game.
Was This Post Helpful? 0
  • +
  • -

#14 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Creating a 2D Contra or Zelda like game

Posted 03 July 2012 - 12:38 PM

You're going to find A LOT of if statements when you're doing game programming. You have to make so many decisions in a game during each frame that there isn't really much of an alternative, with the occaisional switch thrown in. You've seen even for a simple game like Pong, with a few objects, there a number of if statements. You seem to have the idea down though. Check to see if the ball collides with the walls, a series of if statements. Check to see if the ball collides with the paddles, more if statements. Check to see if the ball is out of bounds, even more if statements. Check to see what keys are currently being pressed, surprise, surprise, more if statements.
Was This Post Helpful? 0
  • +
  • -

#15 jaay5389  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 16-December 09

Re: Creating a 2D Contra or Zelda like game

Posted 03 July 2012 - 01:38 PM

Yeah, i can only imagine how many if statements would be in full scale 2d game. I was just curious if there was a better way to handle it. I should probably worry about getting the hang of things first before worrying about optimization.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2