我正在编写一个Pong游戏编码,但我在创建对象时遇到了麻烦.我有工作代码,但它没有包含类或任何对象,因为它是面向对象编程类,我需要修复它.但是,现在我收到了一堆不同的错误消息(它在100之后停止显示).他们中的大多数似乎正在处理我没有正确创建对象.
我从来没有使用过C++中的对象(可能应该这样,但是由于这个原因,我刚刚在这个课程中混淆了并获得了分数),但是由于这个学期正在逐渐减少,我真的需要在这个项目上做得很好.
更新 我已经设法摆脱了大多数错误,但仍然有一些让我难过.我编辑了我的代码以反映我所做的更改并更新了错误列表.
这是我的代码:
我的头文件:
#include "stdafx.h"
#include <string>
#include <Windows.h>
#include <iostream>
//#include <conio.h>
#include <sstream>
#include <math.h>
//#include <gl\gl.h>
//#include <gl\glu.h>
#include "GL/freeglut.h"
#pragma comment(lib, "Opengl32.lib")
#define VK_W 0x57
#define VK_S 0x53
using namespace std;
class Pong {
public:
Pong();
std::string int2str;
void drawText(float x, float y, std::string text);
void drawPaddle(float x, float y, float width, float height);
void draw();
void enable2D(int width, int height);
void keyboard();
void vec2_norm(float& x, float &y);
void updateBall();
void gameOverCheck();
void …Run Code Online (Sandbox Code Playgroud)