Construction system2 min read

construction system feature image

Development Log: Building System for Pixel Game

After extensive research and study of tile-based resource solutions for pixel games, I have successfully implemented a Building System with unique features that set it apart from traditional approaches.

Key Features

Tile Placement Logic

  • Walls and Wall Attachments:
    Unlike common pixel games where walls and objects occupy entire grid cells, our system places walls and wall attachments (such as doors, windows, curtains, and wall-mounted paintings) along grid edges.
  • Furniture and Objects:
    Furniture and other objects are placed to occupy entire or multiple grid cells, providing a more flexible and realistic building experience.

Physics and Rendering Layers

We have resolved the layer ordering issues in both physics and rendering layers. Specific solutions include:

  • Walls:
    • Walls are treated as physical collision entities.
  • Doors:
    • The collision state of doors is dynamically controlled based on their open/closed state, affecting the attached wall's collision properties.
  • Windows:
    • Windows always have open collision but require cut-out rendering when open, similar to doors, to visually align with the attached wall.

Challenges and Solutions

  1. Tile Edge Detection:

    • Walls and floor tiles require edge detection to handle scenarios like indoor and outdoor spaces. For example, indoor tiles should not be treated as connected to adjacent outdoor tiles of the same type but rather as separated by walls.
    • This ensures proper visual and logical segmentation between different areas.
  2. Dynamic Object Loading:

    • Dynamically adding buildings and furniture items poses challenges in loading and rendering.
    • We implemented efficient mechanisms to handle the rendering order and resource management for dynamically placed objects.

This Building System introduces a fresh approach to pixel game construction, offering players more creative freedom while maintaining a seamless and immersive experience. Stay tuned for more updates as I continue to refine and expand the system!




开发日志:像素游戏的建造系统

经过对像素游戏瓦片资源方案的深入研究和学习,我们成功实现了一套独特的 建造系统,其功能与传统方案有所不同。

核心功能

瓦片放置逻辑

  • 墙体和墙体挂件
    与常见的像素游戏不同,系统中 墙体墙体挂件(如门、窗、窗帘和墙上挂的画)是 基于网格边缘放置 的。
  • 家具和物品
    家具和其他物品则占用 整个或多个网格,提供了更灵活和真实的建造体验。

物理和渲染层

我解决了物理层和渲染层的 分层顺序问题,具体方案包括:

  • 墙体
    • 墙体被视为 物理碰撞实体
    • 门的碰撞状态根据其开关状态动态控制,影响所依附墙体的碰撞属性。
    • 窗的碰撞状态始终为 开启,但在渲染时需要像门一样对依附的墙体进行 挖空处理,以确保视觉效果一致。

挑战与解决方案

  1. 瓦片边缘检测

    • 墙体和地面瓦片需要边缘检测来处理室内外空间的场景。例如,室内瓦片不应被视为与相邻的相同类型室外瓦片相连,而是 被墙体分割的独立状态
    • 这确保了不同区域之间的视觉和逻辑分割正确。
  2. 动态物体加载

    • 动态添加的建筑和家具物品在 加载和渲染 方面提出了挑战。
    • 实现了高效的机制来处理动态放置物体的渲染顺序和资源管理。

这套建造系统为像素游戏带来了全新的建造方式,为玩家提供了更多的创作自由,同时保持了无缝且沉浸的体验。敬请期待更多更新,我将继续优化和扩展系统功能!