游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3492|回复: 9

请问一下游戏的程序的大体框架是什么样的?

[复制链接]

1

主题

7

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2005-3-2 19:50:00 | 显示全部楼层 |阅读模式
我这几天在学习游戏编程


我总结的大体框架是这个样子 不知对不对

WinMain(){


Game_Init( );
while ( )
{
    if ( )
    {
    }
    else
    {
        Update( );
        Render( );
    }
}


然后那个Render(负责游戏的绘制的函数)

是不是就是大家说的Frame  ?

如果是的话  我看到书上说在一个Frame里通过两次取系统时间  
然后得到的差就是FrameTime  这个值是用来做什么的呢?


谢谢

31

主题

630

帖子

635

积分

高级会员

Rank: 4

积分
635
发表于 2005-3-2 20:28:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

这种框架是组件级的。

31

主题

630

帖子

635

积分

高级会员

Rank: 4

积分
635
发表于 2005-3-2 20:33:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

主循环可以这样:
while(frm.Created)
{
        dosomthing();
        render();
        Application.DoEvents();
}

1

主题

7

帖子

9

积分

新手上路

Rank: 1

积分
9
 楼主| 发表于 2005-3-2 20:49:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

我不是很懂组件级是什么意思  我觉得好象两者差不多... -_-



另外我想问FrameTime是用来做什么的?  我在很多地方都看到了

FrameTime=GetTime()-LastTime;

31

主题

630

帖子

635

积分

高级会员

Rank: 4

积分
635
发表于 2005-3-2 21:44:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

FrameTime是刷新一桢用的时间。求出来的值可能不会很准确。
框架是个大的概念。组件可以包含多个类,类可以包含多个过程。
其实采取什么样的结构无所谓,不同的游戏应该有不同的结构,关键是适不适合。我觉得是这样,没有定法。

1

主题

7

帖子

9

积分

新手上路

Rank: 1

积分
9
 楼主| 发表于 2005-3-2 22:59:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

我是想做一个网络的小型动作游戏    我的设想是做成一个小球在屏幕上运动 通过上下左右来控制        

我在一篇资料里看到  它说的服务器和客户端的构架是这样说的 (用到了FrameTime)



Figure 1:  General Client / Server Architecture

For this discussion, all of the messaging and coordination needed to start up the connection between client and server is omitted.  The client’s frame loop looks something like the following:

{Sample clock to find start time

Sample user input (mouse, keyboard, joystick)

Package up and send movement command using simulation time

Read any packets from the server from the network system

Use packets to determine visible objects and their state
Render Scene

Sample clock to find end time

End time minus start time is the simulation time for the next frame}

Each time the client makes a full pass through this loop, the “frametime” is used for determining how much simulation is needed on the next frame.  If your framerate is totally constant then frametime will be a correct measure.  Otherwise, the frametimes will be incorrect, but there isn’t really a solution to this (unless you could deterministically figure out exactly how long it was going to take to run the next frame loop iteration before running it…).

The server has a somewhat similar loop:

{Sample clock to find start time

Read client user input messages from network

Execute client user input messages

Simulate server-controlled objects using simulation time from last full pass

For each connected client, package up visible objects/world state and send to client

Sample clock to find end time

End time minus start time is the simulation time for the next frame}

In this model, non-player objects run purely on the server, while player objects drive their movements based on incoming packets.  Of course, this is not the only possible way to accomplish this task, but it does make sense.


我就搞不懂它说的  simulation time   是怎么用的?

31

主题

630

帖子

635

积分

高级会员

Rank: 4

积分
635
发表于 2005-3-3 09:51:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

怎么回事,我查找了一下,文中没有找到simulation time?!
不过应该先学会编游戏,之后再试着编网络游戏。
一般的游戏可以分为模型、视图、控制这三层。

1

主题

7

帖子

9

积分

新手上路

Rank: 1

积分
9
 楼主| 发表于 2005-3-4 23:45:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

Package up and send movement command using simulation time

我不懂这句话是什么意思      另外  单机的小球移动模型 我做出来了  ..

simulation Time 似乎就是Frametime  不懂..

59

主题

1104

帖子

1199

积分

金牌会员

Rank: 6Rank: 6

积分
1199
发表于 2005-3-5 19:20:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

呵呵,这个是偶的本行,同步里面的东西,simulation time是根据网络延迟预测之后的时间。

31

主题

630

帖子

635

积分

高级会员

Rank: 4

积分
635
发表于 2005-3-6 12:06:00 | 显示全部楼层

Re:请问一下游戏的程序的大体框架是什么样的?

应该是预测的时间。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-24 17:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表