PSP程序开发例子解析(五)Shapes

 绘制各种形状 无话可说
#include <stdio.h>

#include <JGE.h>
#include <JRenderer.h>
#include <JLBFont.h>
#include "JAssert.h"

#include "GameApp.h"


//-------------------------------------------------------------------------------------
// Constructor. Variables can be initialized here.
//
//-------------------------------------------------------------------------------------
GameApp::GameApp()
{
mAngle = 0.0f;

}


//-------------------------------------------------------------------------------------
// Destructor.
//
//-------------------------------------------------------------------------------------
GameApp::~GameApp()
{

}


//-------------------------------------------------------------------------------------
// This is the init callback function. You should load and create your in-game 
// resources here.
// 
//-------------------------------------------------------------------------------------
void GameApp::Create()
{


}


//-------------------------------------------------------------------------------------
// This is the clean up callback function. You should delete all your in-game 
// resources, for example texture and quads, here.
// 
//-------------------------------------------------------------------------------------
void GameApp::Destroy()
{

}


//-------------------------------------------------------------------------------------
// This is the update callback function and is called at each update frame
// before rendering. You should update the game logic here.
//
//-------------------------------------------------------------------------------------
void GameApp::Update()
{

JGE* engine = JGE::GetInstance();

// do a screen shot when the TRIANGLE button is pressed
if (engine->GetButtonClick(PSP_CTRL_TRIANGLE))  
{
   char s[80];

   // save screen shot to root of Memory Stick 
   sprintf(s, "ms0:/screenshot.png");    
   JRenderer::GetInstance()->ScreenShot(s);
}

// exit when the CROSS button is pressed
if (engine->GetButtonClick(PSP_CTRL_CROSS)) 
{
   engine->End();
   return;
}

float dt = engine->GetDelta();   // Get time elapsed since last update.

mAngle += 2.0f*dt;
if (mAngle >= M_PI*2)
   mAngle = 0;
}


//-------------------------------------------------------------------------------------
// All rendering operations should be done in Render() only.
// 
//-------------------------------------------------------------------------------------
void GameApp::Render()
{

// get JRenderer instance
JRenderer* renderer = JRenderer::GetInstance();  

// clear screen to black
renderer->ClearScreen(ARGB(0,0,0,0));

float xList[] =
{
   10, 100, 120, 80, 50, 10
};

float yList[] = 
{
   100, 100, 60, 30, 10, 10
};

renderer->DrawPolygon(xList, yList, 6, ARGB(255,0,0,255));     // Draw polygon with 6 vertices.

renderer->DrawLine(120, 100, 320, 250, 5, ARGB(255,255,0,0));    

renderer->FillCircle(400, 180, 50, ARGB(255,123,60,200));

   renderer->DrawPolygon(130, 200, 40, 4, mAngle, ARGB(255,0,0,255));   // Draw a symmetric polygon with 4 sides.

   renderer->FillPolygon(80, 200, 40, 4, mAngle, ARGB(255,0,0,255));   // Draw a symmetric polygon with 6 sides.

renderer->DrawRect(250, 100, 40, 60, ARGB(255,255,255,255));

renderer->DrawRoundRect(340, 30, 30, 20, 5, ARGB(255,255,255,255));

renderer->FillRoundRect(200, 20, 40, 40, 8, ARGB(255,255,255,64));
Sleep(1);
}


//-------------------------------------------------------------------------------------
// This function is called when the system wants to pause the game. You can set a flag
// here to stop the update loop and audio playback.
//
//-------------------------------------------------------------------------------------
void GameApp::Pause()
{

}


//-------------------------------------------------------------------------------------
// This function is called when the game returns from the pause state.
//
//-------------------------------------------------------------------------------------
void GameApp::Resume()
{

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值