|
|
大家好。我是一个游戏程序员初学者,同时也是北大青鸟第二学期的学员。
我从小就很喜欢游戏,虽然那时候只知道去玩。到了初中就开始在想为什么按前,游戏里的人物就会向前走这之类的问题~接着慢慢的想自己做游戏,于是进入了漫长而曲折的弯路。初中由于成绩差~高中上了职高,学计算机网络(硬件),这个时候才开始真正的接触电脑,慢慢的发现和游戏没什么关系,于是晚上就参加培训班学Photoshop只类的绘图,那时候游戏看上去认为也就是图片而已。接着学3DMAX,觉得以为这个能做三维只类的游戏,那时高中几乎是在学校混的。学校让成绩差的不能参加考试,只要参加了考试就拿不到毕业证的~于是高二完了之后看见报纸上的蓝天学院有视觉传达专业。学的都是影视的~那时候以为这个可以入游戏行业,学到一半才知道,又一次选错了专业,慢慢的开始有些失望了。。。
大专毕业后,父母要我去了一家小的广告公司应聘,很顺利的就通过了,他们说我想来的话明天就能来上班,但第二天我还是没去,我怕如果去做广告的话以后也许就永远不能从事游戏开发的工作了。过了几天。去新大地的四方软件看到一个游戏《恋爱游戏制作大师》(其实是软件),当时就毫不忧郁的买下了,回去之后研究了一个星期,自己也能做AVG游戏了,当时兴奋的几乎晚上都睡不着。但那个软件似乎并不让人满意,做了实验品那去给同学试试,莫名其妙的打不开,当时挺郁闷的。慢慢的在网上发现了一个叫幻想森林的论坛。里面介绍了一个Nscripter的游戏引擎,在CountD(斑竹)的帮助下。很快的就掌握了这个游戏引擎,而且非常的棒(和恋爱游戏制作大师相比)。但这个似乎也只能做AVG,3D游戏的话。。。
慢慢的知道了C、C++,JAVA这些编程语言,于是在网上找资料,终于知道了是用这些来做游戏的,但听说学编程需要很好的英语和数学,而我高中大专几乎都没接触这些,现在和没学过的人区别不大。但自己又很想做这行,突然想起了这里有个学程序的北大青鸟,于是下定了决心~数学英语不好可以在学,当时第一学期去读的时候还是插班生~一去刚好在上C语言,那时候非常努力的在学,C语言考了98分和班长并列全班第一。发现英语和数学并不那么重要,后来第一学期最后的JAVA,当自己能建立第一个窗体的时候~我在次激动的一晚没睡。因为之前做的AVG游戏也是这样窗体里显示的,三个月过去了~第一学期结束后感觉很好,重要的是学了C和OOP的知识,第二学期开始了一个月不到就放假过年,那时候在网上找了些资料,终于比较清楚的知道C\C++用来开发游戏最好。学校里学的C是基础,假期就去买了谭浩强的C语言书和C++书,一个月里把这两本书都看完了,觉得又充实了不少。学了C++之后觉得第二学期的C#非常容易。
同学去书店买书的时候,他看到了一本叫《3D游戏编程大师技巧》的书,买来后刚开始看的很费劲,花了很长时间才看完了第三章,那之后终于知道一个WINDOWS的程序是怎么运行的,通过消息循环,并且也知道游戏的结构了,但还有很多知识不知道,比如COM、DLL等。于是跑到新华书店去看书,看的饭都忘了吃,直到晚上9点关门我才走的,后来大专里的一个同学把GameRes的这个网站告诉了我(他在深圳的游戏公司做建模),之后终于确定了自己的目标C,DirectX ,WIN32~。当看第四章的时候....我终于知道数学对游戏编程的重要性了,那章几乎是看不懂。。跑去问在自考的同学接了套高等数学。。看起来也费劲,不过还好能看懂。
这个时候学校的C#也学完了,老师要我们做个打字游戏。要求用控件和线程做,而我的是根据那本游戏书上的例子,字是自己用Graphics画的。完成之后感觉不错,算是自己做的第一个小游戏吧,后来学JSP,B/S架构的程序我完全不感兴趣。。在加上JSP里还有我最讨厌的HTML。。慢慢的开始对学校的课程产生了厌学的情绪,但不学又觉得对不起父母(学费不便宜)。慢慢的压力也越来越大,弄的家里的游戏编程书也没心思看了。现在第二学期快结束了,问了下第二学年的课程。结果几乎都是WEB企业集的开发。和游戏开发一点帮助都没有。。
现在我又一次陷入了迷茫中。目前只有两个选择,继续读下去(第二学年最后一学期,学费要10000多)。还有就是想在家里专心自学关于游戏开发的,而且如果确定了学游戏开发的话,打算去补英语和数学,这两个现在才知道多重要(这方面的资料几乎都是英文的)。但我也知道游戏编程对于我来说还需要走很长的路,我现在也已经20岁了(87年的)。
希望大家能指点一下我。谢谢。
以下是那个C#打字游戏的代码
AppMain.cs
using System;
namespace Curriculum_8__1
{
public class AppMain
{
static void Main()
{
System.Windows.Forms.Application.Run(new MainForm());
}
}
}
GameSystem.cs
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
namespace Curriculum_8__1
{
public class GameSystem
{
private MainForm m;
private const int airshipCount=12;
private const int in_Phase=1000/60;
private enum MES{WM_CREATE,WM_STRAT,WM_QUIT};
private MES mes=MES.WM_STRAT;
private static Image tempI=new Bitmap(640,480);
private static Graphics temp=Graphics.FromImage(tempI);
private Airship[] air=new Airship[airshipCount];
public GameSystem(MainForm m)
{
this.m=m;
m.timeIn_Phase.Enabled=true;
m.timeIn_Phase.Interval=in_Phase;
m.KeyPress+=new KeyPressEventHandler(m_KeyPress);
m.timeIn_Phase.Tick+=new EventHandler(timeIn_Phase_Tick);
for (int i=0;i<airshipCount;i++)
{
air=new Airship(DateTime.Now.Millisecond/(i+4));
}
}
public void gameMain(Graphics grap)
{
switch(mes)
{
case MES.WM_CREATE:
break;
case MES.WM_STRAT:
gameStart(grap);
break;
case MES.WM_QUIT:
break;
default:
break;
}
}
private void gameStart(Graphics grap)
{
for (int i=0;i<airshipCount;i++)
{
air.romanceAirship(temp);
}
grap.DrawImage(tempI,0,0);
}
private void m_KeyPress(object sender, KeyPressEventArgs e)
{
for (int i=0;i<airshipCount;i++)
{
if (e.KeyChar==air.Fonts[0])
{
air.stateKey=true;
}
}
}
private void timeIn_Phase_Tick(object sender, EventArgs e)
{
gameMain(m.CreateGraphics());
}
}
}
MainForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
namespace Curriculum_8__1
{
public class MainForm : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
public System.Windows.Forms.Timer timeIn_Phase;
private GameSystem game;
public MainForm()
{
InitializeComponent();
game=new GameSystem(this);
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timeIn_Phase = new System.Windows.Forms.Timer(this.components);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(640, 480);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.KeyPreview = true;
this.MaximizeBox = false;
this.Name = "MainForm";
this.Text = "打字游戏";
}
#endregion
}
}
Airship.cs
using System;
using System.Windows.Forms;
using System.Drawing;
namespace Curriculum_8__1
{
public class Airship
{
private struct Point
{
public int x,y;
}
private struct Line
{
public int vs,ve;
}
private const int pointCount=10;
private const int lineCount=10;
private const int fontX=5;
private const int fontY=4;
private const int blastMaxCount=20;
private Font font=new Font("宋体",10);
private Pen penN=new Pen(Color.Red);
private SolidBrush solidN=new SolidBrush(Color.Red);
private Pen penL=new Pen(Color.Black);
private SolidBrush solidL=new SolidBrush(Color.Black);
private Random ran;
private static string charAll="";
public bool state;
public bool stateKey;
private int speed;
private int airshipX;
private int airshipY;
private string fonts;
private int shotX;
private int shotY;
private int countBlast;
private int[] blastX1;
private int[] blastX2;
private int[] blastY1;
private int[] blastY2;
private Point[] airshipAcme=new Point[pointCount];
private Line[] airshipFrame=new Line[lineCount];
public string Fonts{get{return fonts;}}
private void createAcme()
{
airshipAcme[0].x=0;
airshipAcme[0].y=0;
airshipAcme[1].x=0;
airshipAcme[1].y=10;
airshipAcme[2].x=0;
airshipAcme[2].y=20;
airshipAcme[3].x=2;
airshipAcme[3].y=10;
airshipAcme[4].x=18;
airshipAcme[4].y=10;
airshipAcme[5].x=10;
airshipAcme[5].y=2;
airshipAcme[6].x=10;
airshipAcme[6].y=18;
airshipAcme[7].x=20;
airshipAcme[7].y=0;
airshipAcme[8].x=20;
airshipAcme[8].y=10;
airshipAcme[9].x=20;
airshipAcme[9].y=20;
}
private void createframe()
{
airshipFrame[0].vs=1;
airshipFrame[0].ve=2;
airshipFrame[1].vs=2;
airshipFrame[1].ve=3;
airshipFrame[2].vs=2;
airshipFrame[2].ve=4;
airshipFrame[3].vs=4;
airshipFrame[3].ve=6;
airshipFrame[4].vs=4;
airshipFrame[4].ve=7;
airshipFrame[5].vs=6;
airshipFrame[5].ve=5;
airshipFrame[6].vs=7;
airshipFrame[6].ve=5;
airshipFrame[7].vs=5;
airshipFrame[7].ve=9;
airshipFrame[8].vs=8;
airshipFrame[8].ve=9;
airshipFrame[9].vs=9;
airshipFrame[9].ve=10;
}
private string randFont()
{
string fon=null;
int count=0;
for(;;)
{
if (ran.Next(100)>50)
fon=((char)ran.Next(65,65+25)).ToString();
else
fon=((char)ran.Next(97,97+25)).ToString();
count=0;
for(int i=0;i<charAll.Length;i++)
{
if (fon[0]!=charAll)
count++;
}
if (count==charAll.Length)
break;
}
return fon;
}
public Airship(int rand)
{
ran=new Random(rand);
initAir();
}
private void initAir()
{
createAcme();
createframe();
airshipX=ran.Next(620);
airshipY=ran.Next(-100,0);
shotX=airshipX+7;
shotY=480;
speed=ran.Next(2)+1;
charAll+=(fonts=randFont());
state=true;
stateKey=false;
countBlast=1;
blastX1=new int[blastMaxCount];
blastX2=new int[blastMaxCount];
blastY1=new int[blastMaxCount];
blastY2=new int[blastMaxCount];
}
public void romanceAirship(Graphics grap)
{
if (airshipY<=480 && state)
{
if (!(airshipY<-20))
{
for (int i=0;i<lineCount;i++)
{
grap.DrawLine(penL,
airshipAcme[airshipFrame.vs-1].x+airshipX,
airshipAcme[airshipFrame.vs-1].y+airshipY,
airshipAcme[airshipFrame.ve-1].x+airshipX,
airshipAcme[airshipFrame.ve-1].y+airshipY);
grap.DrawString(fonts,font,solidL,fontX+airshipX,fontY+airshipY);
}
airshipY+=speed;
for (int i=0;i<lineCount;i++)
{
grap.DrawLine(penN,
airshipAcme[airshipFrame.vs-1].x+airshipX,
airshipAcme[airshipFrame.vs-1].y+airshipY,
airshipAcme[airshipFrame.ve-1].x+airshipX,
airshipAcme[airshipFrame.ve-1].y+airshipY);
grap.DrawString(fonts,font,solidN,fontX+airshipX,fontY+airshipY);
}
}
else if (state)
airshipY+=speed;
}
else if (airshipY>480)
{
charAll=charAll.Remove(charAll.IndexOf(fonts),1);
initAir();
}
if (stateKey)
{
if (shotY-10>airshipY+20)
{
grap.DrawLine(penL,3+shotX,0+shotY,0+shotX,3+shotY);
grap.DrawLine(penL,3+shotX,0+shotY,6+shotX,3+shotY);
grap.DrawLine(penL,3+shotX,0+shotY,3+shotX,9+shotY);
shotY-=30;
grap.DrawLine(penN,3+shotX,0+shotY,0+shotX,3+shotY);
grap.DrawLine(penN,3+shotX,0+shotY,6+shotX,3+shotY);
grap.DrawLine(penN,3+shotX,0+shotY,3+shotX,9+shotY);
}
else if (countBlast<=blastMaxCount)
{
state=false;
if (countBlast==1)
{
grap.DrawString(fonts,font,solidL,fontX+airshipX,fontY+airshipY-speed);
grap.DrawLine(penL,3+shotX,0+shotY,0+shotX,3+shotY);
grap.DrawLine(penL,3+shotX,0+shotY,6+shotX,3+shotY);
grap.DrawLine(penL,3+shotX,0+shotY,3+shotX,9+shotY);
}
for (int i=0;i<lineCount && countBlast>1;i++)
{
grap.IntersectClip(new Rectangle(airshipX-5,airshipY-5,28,28));
grap.Clear(Color.Black);
}
for (int i=0;i<lineCount && countBlast<blastMaxCount;i++)
{
Random rand=new Random(DateTime.Now.Millisecond/(i+1));
grap.DrawLine(penN,
airshipAcme[airshipFrame.vs-1].x+airshipX+(blastX1=rand.Next(-3,3)),
airshipAcme[airshipFrame.vs-1].y+airshipY+(blastX2=rand.Next(-3,3)),
airshipAcme[airshipFrame.ve-1].x+airshipX+(blastY1=rand.Next(-3,3)),
airshipAcme[airshipFrame.ve-1].y+airshipY+(blastY2=rand.Next(-3,3)));
}
countBlast++;
}
else
{
charAll=charAll.Remove(charAll.IndexOf(fonts),1);
initAir();
}
}
grap.ResetClip();
}
}
}
|
|