Click here to Skip to main content
15,897,187 members
Articles / Programming Languages / C# 2.0

Sample Pamper Series - Part 4: 2/3D Space Game, Simple Sounds, and Threads

Rate me:
Please Sign up or sign in to vote.
4.67/5 (11 votes)
4 Apr 2012CPOL5 min read 39.7K   714   42  
This article is the final one in the series, and it will give you a 2/3D space game out of what we have learnt from previous articles. We will also apply simple sounds to it played in threads.
using System;
using Engine3DVP;

namespace Engine3D
{
	/// <summary>
	/// Summary description for Player.
	/// </summary>
	internal class Player: Object3D, IPlayer
	{
		private int mLazer;
		private double mLazerPosX;
		private double mLazerPosY;
		private int mSaveMouseX;
		private int mSaveMouseY;
		private int mSavePlayerX;
		private int mSavePlayerY;
		private int mChield;
		private double mCouX; //The position counter for the movements.
		private double mCouY; //..

		//Creating and placing, giving a rotation value.
		public Player(Poinx3D place, double rotX, double rotY, int energy)
		{
			this.Energy = energy;
			this.mLazer = 0;
			this.mLazerPosX = place.X;
			this.mLazerPosY = place.Y;
			this.ObjPos = place;
			this.SetRotX(rotX);
			this.SetRotY(rotY);
		}
		public int SaveMouseX
		{
			set
			{
				this.mSaveMouseX = value;
			}
			get
			{
				return this.mSaveMouseX;
			}
		}
		public int SaveMouseY
		{
			set
			{
				this.mSaveMouseY = value;
			}
			get
			{
				return this.mSaveMouseY;
			}
		}
		public int SavePlayerX
		{
			set
			{
				this.mSavePlayerX = value;
			}
			get
			{
				return this.mSavePlayerX;
			}
		}
		public int SavePlayerY
		{
			set
			{
				this.mSavePlayerY = value;
			}
			get
			{
				return this.mSavePlayerY;
			}
		}
		//Toggle chield on=1 off=0. 
		public int Chield
		{
			set
			{
				this.mChield = value;
			}
			get
			{
				return this.mChield;
			}
		}
		//Toggle laser on=1 off=0. 
		public int Lazer
		{
			set
			{
				this.mLazer = value;
			}
			get
			{
				return this.mLazer;
			}
		}
		public double LazerPosX
		{
			set
			{
				this.mLazerPosX = value;
			}
			get
			{
				return this.mLazerPosX;
			}
		}
		public double LazerPosY
		{
			set
			{
				this.mLazerPosY = value;
			}
			get
			{
				return this.mLazerPosY;
			}
		}
		//Get and set the new position counter
		public double CountX
		{
			set
			{
				this.mCouX = value;
			}
			get
			{
				return this.mCouX;
			}
		}
		public double CountY
		{
			set
			{
				this.mCouY = value;
			}
			get
			{
				return this.mCouY;
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Sweden Sweden
Professional programmer, degree in Informatics and Applied Systems Science.

Comments and Discussions