克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

My World

C语言实现游戏场景(地图)查看,使用SDL2图形库。

图形库

运行依赖

  • 字体文件msyh.ttf,以显示文本
  • 动态链接库SDL2.dll,SDL2_ttf.dll

编译环境

以下编译环境都可以,需要将include、lib分别拷贝到编译器能找到的目录里;或者加上编译参数,使能找到头文件与库文件。

  • Visual Studio 2019 + SDL2 VC版
  • Dev C++ 5.11 + SDL2 mingw版

场景设计

场景数据结构及API定义在场景设计.xlsx,需要实现以下定义或函数。

/* pixel size of tile */
#define TILE_SIZE 20
/* total number of tiles, with NONE as the first, LAST the last type */
#define NUM_TILES (LAST + 1)
/* windows size, unit of tiles */ 
#define WINDOW_WIDTH 40
#define WINDOW_HEIGHT 30
/* world size, unit of tiles */ 
#define WORLD_WIDTH 80
#define WORLD_HEIGHT 60
/* initialize the scene */
void world_init();
/* calculate which tile on window position (tx, ty) */
void * window_tile(int tx, int ty);
/* render tile on (tx, ty), unit of tile,
   origin point is the top-left of the window */
_Bool window_render(int tx, int ty);
/* move window with unit of offset (dx, dy) */
void window_move(int dx, int dy);
/* move the window to the world position (wx, wy) */ 
void window_moveto(int wx, int wy);

需要在mario.c里实现以上函数。

键盘ASDW,上下左右方向键,可在场景中浏览,该功能已在world.c里实现。

MIT License Copyright (c) 2022 郑贵锋 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

面向C语言编程初学者,从零开始创造一个虚拟的新世界,英文名”My World“,中文”迷界“。 展开 收起
C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化