Giter VIP home page Giter VIP logo

games-pong's Introduction

简单碰撞小游戏(SDL2 + C++开发)


游戏描述

游戏中这样两个玩家,一个是电脑玩家另一个是用户玩家,电脑玩家和用户玩家分别操作属于自己的板来碰撞小球,如果没有碰撞到小球,则对方得分增加。

游戏特点

游戏中用户玩家通过左右方向键来操作板,而电脑玩家设置成智能模式,电脑玩家能根据小球的移动方向来改变自己的位置。

开发环境与依赖

实现效果图

俄罗斯方块游戏实现效果图

公共引用文件描述

  • res/目录下是程序中使用的资源文件,比如背景图片等;
  • Defines.h文件中定义的是const values,比如游戏区域的位置等信息;
  • Enums.h文件中定义的是enum const values,比如定义方向等;

类文件描述

GameObject类

GameObject类表示游戏中的对象,比如说小球和两个板。

Window类

Window主要负责我们窗口的绘制、资源文件的加载、初始化我们的游戏对象,负责游戏中游戏对象的管理,处理游戏逻辑部分,比如碰撞检测等,以及进入到窗口循环中来接收键盘事件、鼠标事件等。 在Window类中我们设计了Start方法,一旦调用该方法就会进入游戏循环,在循环中不断检测事件的发生、更新我们窗口中游戏资源的位置等信息以及将我们的游戏资源绘制到窗口中。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.