Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
7add4d09
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7add4d09
编写于
2月 22, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete game.h
上级
0e258304
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
63 deletion
+20
-63
stb_easy_font.h
stb_easy_font.h
+2
-2
tests/caveview/game.c
tests/caveview/game.c
+17
-17
tests/caveview/game.h
tests/caveview/game.h
+0
-43
tests/caveview/main.c
tests/caveview/main.c
+1
-1
未找到文件。
stb_easy_font.h
浏览文件 @
7add4d09
...
...
@@ -209,12 +209,12 @@ static int stb_easy_font_print(float x, float y, char *text, unsigned char color
static
int
stb_easy_font_width
(
char
*
text
)
{
in
t
len
=
0
;
floa
t
len
=
0
;
while
(
*
text
)
{
len
+=
stb_easy_font_charinfo
[
*
text
-
32
].
advance
&
15
;
len
+=
stb_easy_font_spacing_val
;
++
text
;
}
return
len
;
return
(
int
)
ceil
(
len
)
;
}
#endif
tests/caveview/game.c
浏览文件 @
7add4d09
#include <windows.h>
#include "game.h"
//
#include "game.h"
#include "stb.h"
#include "sdl.h"
...
...
@@ -118,15 +118,15 @@ void camera_to_worldspace(float world[3], float cam_x, float cam_y, float cam_z)
float
vec
[
3
]
=
{
cam_x
,
cam_y
,
cam_z
};
float
t
[
3
];
float
s
,
c
;
s
=
sin
(
camang
[
0
]
*
3
.
141592
/
180
);
c
=
cos
(
camang
[
0
]
*
3
.
141592
/
180
);
s
=
(
float
)
sin
(
camang
[
0
]
*
3
.
141592
/
180
);
c
=
(
float
)
cos
(
camang
[
0
]
*
3
.
141592
/
180
);
t
[
0
]
=
vec
[
0
];
t
[
1
]
=
c
*
vec
[
1
]
-
s
*
vec
[
2
];
t
[
2
]
=
s
*
vec
[
1
]
+
c
*
vec
[
2
];
s
=
sin
(
camang
[
2
]
*
3
.
141592
/
180
);
c
=
cos
(
camang
[
2
]
*
3
.
141592
/
180
);
s
=
(
float
)
sin
(
camang
[
2
]
*
3
.
141592
/
180
);
c
=
(
float
)
cos
(
camang
[
2
]
*
3
.
141592
/
180
);
world
[
0
]
=
c
*
t
[
0
]
-
s
*
t
[
1
];
world
[
1
]
=
s
*
t
[
0
]
+
c
*
t
[
1
];
world
[
2
]
=
t
[
2
];
...
...
@@ -137,9 +137,9 @@ float cam_vel[3];
int
controls
;
#define MAX_VEL 150 // blocks per second
#define ACCEL 6
#define DECEL 3
#define MAX_VEL 150
.0f
// blocks per second
#define ACCEL 6
.0f
#define DECEL 3
.0f
#define STATIC_FRICTION DECEL
#define EFFECTIVE_ACCEL (ACCEL+DECEL)
...
...
@@ -181,7 +181,7 @@ void process_tick_raw(float dt)
if
(
cam_vel
[
0
]
||
cam_vel
[
1
]
||
cam_vel
[
2
])
{
float
vel
=
sqrt
(
cam_vel
[
0
]
*
cam_vel
[
0
]
+
cam_vel
[
1
]
*
cam_vel
[
1
]
+
cam_vel
[
2
]
*
cam_vel
[
2
]);
float
vel
=
(
float
)
sqrt
(
cam_vel
[
0
]
*
cam_vel
[
0
]
+
cam_vel
[
1
]
*
cam_vel
[
1
]
+
cam_vel
[
2
]
*
cam_vel
[
2
]);
float
newvel
=
vel
;
float
dec
=
STATIC_FRICTION
+
DYNAMIC_FRICTION
*
vel
;
newvel
=
vel
-
dec
*
dt
;
...
...
@@ -196,8 +196,8 @@ void process_tick_raw(float dt)
camloc
[
1
]
+=
cam_vel
[
1
]
*
dt
;
camloc
[
2
]
+=
cam_vel
[
2
]
*
dt
;
view_x_vel
*=
pow
(
0
.
75
,
dt
);
view_z_vel
*=
pow
(
0
.
75
,
dt
);
view_x_vel
*=
(
float
)
pow
(
0
.
75
,
dt
);
view_z_vel
*=
(
float
)
pow
(
0
.
75
,
dt
);
view_x_vel
+=
(
pending_view_x
-
view_x_vel
)
*
dt
*
60
;
view_z_vel
+=
(
pending_view_z
-
view_z_vel
)
*
dt
*
60
;
...
...
@@ -207,14 +207,14 @@ void process_tick_raw(float dt)
camang
[
0
]
+=
view_x_vel
*
dt
;
camang
[
2
]
+=
view_z_vel
*
dt
;
camang
[
0
]
=
stb_clamp
(
camang
[
0
],
-
90
,
90
);
camang
[
2
]
=
fmod
(
camang
[
2
],
360
);
camang
[
2
]
=
(
float
)
fmod
(
camang
[
2
],
360
);
}
void
process_tick
(
float
dt
)
{
while
(
dt
>
1
.
0
/
60
)
{
process_tick_raw
(
1
.
0
/
60
);
dt
-=
1
.
0
/
60
;
while
(
dt
>
1
.
0
f
/
60
)
{
process_tick_raw
(
1
.
0
f
/
60
);
dt
-=
1
.
0
f
/
60
;
}
process_tick_raw
(
dt
);
}
...
...
@@ -256,7 +256,7 @@ void draw_stats(void)
chunk_server_pos
=
(
chunk_server_pos
+
1
)
%
32
;
for
(
i
=
0
;
i
<
32
;
++
i
)
chunk_server
+=
chunk_server_status
[
i
]
/
32
.
0
;
chunk_server
+=
chunk_server_status
[
i
]
/
32
.
0
f
;
stb_easy_font_spacing
(
-
0
.
75
);
pos_y
=
10
;
...
...
@@ -293,7 +293,7 @@ void draw_main(void)
#endif
glDepthMask
(
GL_TRUE
);
glDisable
(
GL_SCISSOR_TEST
);
glClearColor
(
0
.
6
,
0
.
7
,
0
.
9
,
0
);
glClearColor
(
0
.
6
f
,
0
.
7
f
,
0
.
9
f
,
0
.
0
f
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
...
...
tests/caveview/game.h
已删除
100644 → 0
浏览文件 @
0e258304
#ifndef INCLUDED_GAME_H
#define INCLUDED_GAME_H
#include <assert.h>
typedef
unsigned
int
uint32
;
typedef
signed
int
int32
;
typedef
unsigned
short
uint16
;
typedef
signed
short
int16
;
typedef
unsigned
char
uint8
;
typedef
signed
char
int8
;
#pragma warning(disable:4244; disable:4305; disable:4018)
// virtual screen size
#define SIZE_X 480
#define SIZE_Y 360
// main.c
extern
void
error
(
char
*
s
);
extern
void
ods
(
char
*
fmt
,
...);
// game.c
extern
void
init_game
(
void
);
extern
void
draw_main
(
void
);
extern
void
process_tick
(
float
dt
);
#define BUTTON_MAX 15
typedef
struct
{
int
id
;
uint8
buttons
[
BUTTON_MAX
];
float
axes
[
4
];
float
triggers
[
2
];
}
gamepad
;
extern
gamepad
pads
[
4
];
#endif
tests/caveview/main.c
浏览文件 @
7add4d09
...
...
@@ -10,7 +10,7 @@
#include <stdio.h>
#include <string.h>
#include "game.h"
//
#include "game.h"
#include <windows.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录