Jump to content
  • Advertisement
Sign in to follow this  
PulsarSL

Best type of game to start with

This topic is 4925 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

Hey, I'm new to game programming. I want to use C# and I was wondering what was the best type of game to start with. I know 2D, but what sort of game should I make? I.e. pong, platform game, etc.

Share this post


Link to post
Share on other sites
Advertisement
Create something that will keep you interested. If you're not interested in the project, there is a greater chance you won't finish it. :)

That said, I'm almost finished my version Frogger before moving on to a side scrolling shooter. :)

Share this post


Link to post
Share on other sites
Pong takes about 4 hours (for me, in C++, programming ~2 yrs purely self-taught). Try and make it so that is is easily modifiable (it is easy to change the length and width of the paddle, the radius of the ball, the dimensions of the court, and how much everything is offset from the corner of the window). Then, expand on it and make breakout, a game that is actually fun :)

Share this post


Link to post
Share on other sites
pong is mandatory since it will teach you basic collision detection and bounds checking(making sure ball,paddle don't leave screen) and tons of other stuff not to mention that it's not too hard and not too easy to write.
then I'd suggest:
tetris clone
space invaders type game
then finally
basic 2d side scroller game
etc

Share this post


Link to post
Share on other sites
Why not start with 3D pong? :)
It shouldn`t be much more work, but it will be much more fun...

Share this post


Link to post
Share on other sites
Quote:
Original post by Bulma
Why not start with 3D pong? :)
It shouldn`t be much more work, but it will be much more fun...


3D pong is much more complex than a 2D version. If he's already comfortable with working in 2D and really wants to work on 3D it might be an idea, but as a basic learning excersise it's better to keep it in 2D so you can focus on the game mechanics rather than having to set up 3D rendering.

Share this post


Link to post
Share on other sites
I don`t think so... I don`t have much experiences with pong, but this version:

Image Hosted by ImageShack.us

was done in less than 3 hours, and has a little more than 200 lines of code... I don`t think you can do 2D pong in much less code... [cool]


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using DInput=Microsoft.DirectX.DirectInput;
using DSound=Microsoft.DirectX.DirectSound;

namespace Pong3D
{
public partial class Pong3D : Form
{
private Mesh box;
private Mesh table;
private Mesh ball;
private Microsoft.DirectX.Direct3D.Font font;
private Device device;
private DInput.Device keyboard;
private DSound.Device soundDevice;
private DSound.SecondaryBuffer hitSound;
private const float FieldLength = 100;
private const float FieldSize = 100;
private const float TableSize = 10;
private const float Ballradius = 2;

private Vector3 ballPosition;
private Vector3 ballDirection;
private Vector3 table1Position;
private Vector3 table2Position;

private int score1 = 0;
private int score2 = 0;

private Material m = new Material();

public Pong3D()
{
InitializeComponent();

// init 3D
PresentParameters pres = new PresentParameters();
pres.SwapEffect = SwapEffect.Discard;
pres.Windowed = true;
pres.AutoDepthStencilFormat = DepthFormat.D24X8;
pres.EnableAutoDepthStencil = true;

device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, pres);

keyboard = new DInput.Device(DInput.SystemGuid.Keyboard);
keyboard.SetCooperativeLevel(this, DInput.CooperativeLevelFlags.Background | DInput.CooperativeLevelFlags.NonExclusive);
keyboard.Acquire();

soundDevice = new DSound.Device();
soundDevice.SetCooperativeLevel(this, DSound.CooperativeLevel.Normal);
hitSound = new DSound.SecondaryBuffer("hit.wav", soundDevice);

box = Mesh.Box(device, FieldSize, 2, FieldLength );
table = Mesh.Box(device, TableSize, TableSize, 1);
ball = Mesh.Sphere(device, Ballradius, 30, 30);

font = new Microsoft.DirectX.Direct3D.Font(device, new System.Drawing.Font(FontFamily.GenericSerif, 20));



ReStart();
}

public void ReStart()
{
ballPosition = new Vector3(FieldSize / 2, FieldSize / 2, FieldLength / 2);
ballDirection = new Vector3(0.2f, 0.1f, -0.7f);
table1Position = new Vector3(FieldSize / 2, FieldSize / 2, FieldLength);
table2Position = new Vector3(FieldSize / 2, FieldSize / 2, 0);
}

public void Draw()
{
// set lights
device.RenderState.CullMode = Cull.Clockwise;
device.RenderState.Lighting = true;
device.RenderState.Ambient = Color.DimGray;
device.Lights[0].Type = LightType.Directional;
device.Lights[0].Diffuse = Color.WhiteSmoke;
device.Lights[0].Direction = new Vector3(-0.8f, 0.3f, -1);
device.Lights[0].Enabled = true;

device.Transform.World = Matrix.Identity;
device.Transform.View = Matrix.LookAtRH(new Vector3(FieldSize*2, -FieldSize*2, FieldLength*2),
new Vector3(FieldSize / 2, FieldSize / 2, FieldLength / 2), new Vector3(0, 0, 1));
device.Transform.Projection = Matrix.PerspectiveFovRH(0.5f, (float)this.Size.Width / this.Size.Height, 1, 1000);

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);
device.BeginScene();

// draw walls
m.Diffuse = Color.Red;
m.Ambient = Color.Red;
device.Material = m;
device.Transform.World = Matrix.Translation(FieldSize / 2, FieldSize, FieldLength / 2);
box.DrawSubset(0);
device.Transform.World = Matrix.RotationZ((float)Math.PI/2)*Matrix.Translation(0, FieldSize/2, FieldLength / 2);
box.DrawSubset(0);
m.Diffuse = Color.White;
m.Ambient = Color.White;
device.Material = m;
device.RenderState.FillMode = FillMode.WireFrame;
device.Transform.World = Matrix.Translation(FieldSize / 2, 0, FieldLength / 2);
box.DrawSubset(0);
device.Transform.World = Matrix.RotationZ((float)Math.PI / 2) * Matrix.Translation(FieldSize, FieldSize / 2, FieldLength / 2);
box.DrawSubset(0);
device.RenderState.FillMode = FillMode.Solid;


// draw ball
m.Diffuse = Color.SteelBlue;
m.Ambient = Color.SteelBlue;
device.Material = m;
device.Transform.World = Matrix.Translation(ballPosition);
ball.DrawSubset(0);
// draw shadow
Matrix shadow = new Matrix();
Plane plane = new Plane(0, 0, 1, 0);
shadow.Shadow(new Vector4(0, 0, 1, 0), plane);
Matrix shadowWorld = Matrix.Translation(ballPosition) * shadow;
device.Transform.World = shadowWorld;
ball.DrawSubset(0);
plane = new Plane(0, 0, 1, -FieldLength);
shadow.Shadow(new Vector4(0, 0, 1, 0), plane);
shadowWorld = Matrix.Translation(ballPosition) * shadow;
device.Transform.World = shadowWorld;
ball.DrawSubset(0);


// draw tables
m.Diffuse = Color.Yellow;
m.Ambient = Color.Yellow;
device.Material = m;
device.Transform.World = Matrix.Translation(table1Position);
table.DrawSubset(0);
device.Transform.World = Matrix.Translation(table2Position);
table.DrawSubset(0);

font.DrawText(null, string.Format("Score: {0}:{1}", score1, score2), 10, 10, Color.White);

device.EndScene();
device.Present();
}

public void Process()
{
// move tables
DInput.KeyboardState state = keyboard.GetCurrentKeyboardState();
if (state[DInput.Key.A])
{
if (table1Position.X > 0 + TableSize/2) table1Position.X -= 1;
}
if (state[DInput.Key.D])
{
if (table1Position.X < FieldSize - TableSize / 2) table1Position.X += 1;
}
if (state[DInput.Key.S])
{
if (table1Position.Y > 0 + TableSize / 2) table1Position.Y -= 1;
}
if (state[DInput.Key.W])
{
if (table1Position.Y < FieldSize - TableSize / 2) table1Position.Y += 1;
}

if (state[DInput.Key.NumPad4])
{
if (table2Position.X > 0 + TableSize / 2) table2Position.X -= 1;
}
if (state[DInput.Key.NumPad6])
{
if (table2Position.X < FieldSize - TableSize / 2) table2Position.X += 1;
}
if (state[DInput.Key.NumPad5])
{
if (table2Position.Y > 0 + TableSize / 2) table2Position.Y -= 1;
}
if (state[DInput.Key.NumPad8])
{
if (table2Position.Y < FieldSize - TableSize / 2) table2Position.Y += 1;
}

// process ball
ballPosition += ballDirection;

// check end
if (ballPosition.Z < 0)
{
score2++;
ReStart();
return;
}
if (ballPosition.Z > FieldLength)
{
score1++;
ReStart();
return;
}

// check panel hit
if (ballPosition.Z < 1)
{
if ((ballPosition.X > table2Position.X - TableSize/2 && ballPosition.X < table2Position.X + TableSize/2) &&
(ballPosition.Y > table2Position.Y - TableSize/2 && ballPosition.Y < table2Position.Y + TableSize/2))
{

ballDirection = Reflect(ballDirection, new Vector3(0, 0, 1) );
}
}
if (ballPosition.Z > FieldLength-1)
{
if ((ballPosition.X > table1Position.X - TableSize / 2 && ballPosition.X < table1Position.X + TableSize / 2) &&
(ballPosition.Y > table1Position.Y - TableSize / 2 && ballPosition.Y < table1Position.Y + TableSize / 2))
{

ballDirection = Reflect(ballDirection, new Vector3(0, 0, -1));
}
}
// check wall hit
if (ballPosition.X < 0) ballDirection = Reflect(ballDirection, new Vector3(1, 0, 0));
if (ballPosition.X > FieldSize) ballDirection = Reflect(ballDirection, new Vector3(-1, 0, 0));
if (ballPosition.Y < 0) ballDirection = Reflect(ballDirection, new Vector3(0, 1, 0));
if (ballPosition.Y > FieldSize) ballDirection = Reflect(ballDirection, new Vector3(0, -1, 0));

}

private Vector3 Reflect(Vector3 input, Vector3 normal)
{
// play sound
hitSound.Play(0, DSound.BufferPlayFlags.Default);

return input - 2 * Vector3.Dot(input, normal) * normal;
}
}
}



Share this post


Link to post
Share on other sites
You need a good understanding of maths to do the 3d stuff, and to do that in such a small amount of code means you'd need to be a very tidy programmer too.

I think if you're new to programming / problem solving then something slightly simpler would be more helpful in letting you develop the foundation skills you need.

Share this post


Link to post
Share on other sites
Pong's a fair enough response, but perhaps after it you'll want to think about doing a Mario clone. Lots of different components and interactive things knocking about - orders of magnitude more complex than Pong.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!