游戏开发论坛

 找回密码
 立即注册
搜索
查看: 5038|回复: 1

入门那个实例编译不过

[复制链接]

1

主题

5

帖子

13

积分

新手上路

Rank: 1

积分
13
发表于 2009-10-6 12:43:00 | 显示全部楼层 |阅读模式
   下载的那个教程,你的第一个游戏。。这个代码编译不过。。错误很多。。

#include <windows.h>

#include <stdio.h>

#include "D:\\light3\\include\\light.h"

#pragma comment( lib, "d:\\light3\\lib\\light.lib" )

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

{

     LightEngine *engine;

     LightText   *text;

     // 初始化光线引擎

     engine = InitialLightEngine(); // 获取引擎指针

     text = engine->NewText();      // 获取文字指针   

     engine->SetWindowMode(200, 150, 400, 300, 0); // 设置显示模式为窗口模式   

     engine->Disable( LIGHT_SWAP_INTERVAL );      // 关闭垂直同步,这样可以使你的游戏跑得更快
     do

     {

         // 清除窗口内容

         engine->Clear( LIGHT_COLOR_BUFFER_BIT | LIGHT_DEPTH_BUFFER_BIT );

         // 显示欢迎信息

         text->Color( 0, 255, 0 );              // 设置文字颜色

         text->SetTextPos( 150, 122 );          // 设置光标位置      

         text->DrawText( "欢迎来到游戏世界!" ); // 显示文字
         // 显示帧速(FPS)

         char fps[100];

         sprintf( fps, "帧速: %d 帧/秒", engine->GetFramePerSecond() );

         text->Color( 0, 255, 0 );

         text->SetTextPos( 20, 245 );

         text->DrawText( fps );

         // 更新显示

         engine->SwapBuffers();

     }

     // 监听消息,直到玩家关闭游戏窗口

     while( engine->DispatchMessage() );
     return 0;

}

error C2039: “NewText” : 不是“LightEngine”的成员 d:\light3\include\engine.h(215) : 参见“LightEngine”的声明

error C2039: “SetWindowMode” : 不是“LightEngine”的成员  d:\light3\include\engine.h(215) : 参见“LightEngine”的声明

11

主题

37

帖子

37

积分

注册会员

Rank: 2

积分
37
发表于 2009-10-8 18:48:00 | 显示全部楼层

Re:入门那个实例编译不过

你在用2.0版本的代码 在3.0引擎中编译,应为版本升级部分代码编写方式发生了改变.
// 显示文字演示程序
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
        LightEngine *engine;
        LightText   *text;

        // 创建光线引擎实例
        LightEngineDesc engineDesc;
        engineDesc.displayMode.mode           = LIGHT_WINDOW_MODE;  // 窗口显示模式
        engineDesc.displayMode.window.x       = 200;                // 窗口左上角 x 坐标
        engineDesc.displayMode.window.y       = 150;                // 窗口左上角 y 坐标
        engineDesc.displayMode.window.width   = 640;                // 窗口宽度
        engineDesc.displayMode.window.height  = 480;                // 窗口高度
        engine = LightEngineCreate( engineDesc );

        // 创建文字实例
        LightTextDesc textDesc;
        text = engine->createText( textDesc );

        // 缺省字体
        // 设置文字颜色
        text->color( 0, 255, 0 );
        // 设置光标位置
        text->setTextPos( 20, 20 );
        // 显示文字
        text->drawText("欢迎使用光线游戏引擎");

        // 文字背景
        /* 设置字体 */
        text->setFont( "华文彩云",     // 指定字体
                         24,          // 指定字体高度
                             0,           // 指定字体宽度
                                 0,           // 指定字体的重量(FW_BOLD=700)
                                 0,           // 指定角度(1/10度)                                 
                                 0,           // 指定是否斜体
                                 0,           // 指定是否有下划线
                                 0,           // 指定是否是StrikeOut字体
                                 0            // 指定输出质量
                                 );
        text->color( 255, 255, 0 );
        // 设置文字背景色
        text->backColor( 0, 0, 255 );
        // 设置文字背景模式为不透明
        text->setBackMode( LIGHT_OPAQUE );
        text->setTextPos( 20, 55 );
        text->drawText("欢迎使用光线游戏引擎");

        // 斜体
        text->setFont( "隶书", 28, 0, 0, 0, 1, 0, 0, 0 );                                 
        text->color( 255, 0, 0 );
        text->setBackMode( LIGHT_TRANSPARENT );
        text->setTextPos( 20, 90 );
        text->drawText("欢迎使用光线游戏引擎");

        // 下划线
        text->setFont( "宋体", 28, 0, 0, 0, 0, 1, 0, 0 );                                 
        text->color( 255, 255, 0 );
        text->setTextPos( 20, 128 );
        text->drawText("欢迎使用光线游戏引擎");

        // 删除线
        text->setFont( "方正姚体", 28, 0, 0, 0, 0, 0, 1, 0 );                                 
        text->color( 0, 0, 255 );
        text->setTextPos( 20, 170 );
        text->drawText("欢迎使用光线游戏引擎");

        // 旋转
        text->setFont( "方正舒体", 28, 0, 0, 0, 1, 0, 0, 0 );                                 
        text->color( 255, 0, 255 );
        text->setTextPos( 20, 210 );
        text->drawText("欢迎使用光线游戏引擎");

        // 字间距
        text->setFont( "黑体", 24, 0, 0, 0, 0, 0, 0, 0 );                                 
        text->color( 255, 255, 255 );
        // 设置字间距
        text->setCharSpace( 10 );
        text->setTextPos( 20, 245 );
        text->drawText("欢迎使用光线游戏引擎");

        // 更新显示
        engine->swapBuffers();

        // 配送消息
        while( engine->dispatchMessage() );

        // 释放文字对象
        engine->releaseText( text );

        // 释放光线引擎实例
        LightEngineRelease( engine );

        return 0;
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-5-17 18:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表