1.PSP ç软件å¼åç¨ä»ä¹è¯è¨
2.åä¸å
«çç徽设计å¾
PSP ç软件å¼åç¨ä»ä¹è¯è¨
游æä¸è¬é½æ¯ C++å¼åç
ä¸è¿æ¸¸æ ä¸»æº å¼åä¸è¬é½æ¯éè¦ç¸å ³å¥ä»¶
èä¸å¨æè¾é¿ ä¸ä¸ªäººå¾é¾åå¾æ¥
PSPç¨åºå¼åä¾å解æ(äº)Images-- :第äºä¸ªä¾åç¨åºæ¼ç¤ºäºå¦ä½å¨å±å¹ä¸ç»å¶å¾ç éä¸æºç ååä¸å¤§ å¾ç®åçå å¥ä»£ç æå®äº
1.头æ件GameApp.h
#ifndef _GAMEAPP_H_
#define _GAMEAPP_H_
#include <JApp.h>
class JQuad;//JQuadå®ä¹äºå¾çä¸çæ¾ç¤ºèå´ æ¯å¦å¾å¤çå°å¾çå为äºä¸ä¸ªå¤§å¾ç å¨å¤§å¾çä¸æå®æ¾ç¤ºçåæ
class JSprite;//å¨ç» ä¼¼ä¹æ²¡ç¨å°
class JTexture;//æä¸ä¸ªå¾ç读æäºä¸ä¸ªJTexture = =!éé¢ä¸æå¾æä»ä¹å 容 没ædocå¯ç
class GameApp: public JApp
{
private:
JTexture* mBgTex;//æ´ä¸ªèæ¯çå¾ç
JTexture* mSpriteTex;//2个人ç©çå¾ç
JQuad* mBg;//å®ä¹äºæ´ä¸ªèæ¯ç大å°
JQuad* mBoy;//ç·å©å¨äººç©å¾çä¸ç大å°
JQuad* mGirl;//女å©å¨äººç©å¾çä¸ç大å°
public:
GameApp();
virtual ~GameApp();
virtual void Create();
virtual void Destroy();
virtual void Update();
virtual void Render();
virtual void Pause();
virtual void Resume();
};
#endif
2.æºç æ件GameApp.cpp
#include <stdio.h>
#include <JGE.h>
#include <JRenderer.h>
#include <JLBFont.h>
#include <JSprite.h>
#include <JFileSystem.h>
#include "GameApp.h"
GameApp::GameApp()
{
mBgTex = NULL;
mBg = NULL;
mSpriteTex = NULL;
mBoy = NULL;
mGirl = NULL;//é½ç»å®è®¾æNULLå¹²å¥ æ²¡ææä¹å
GameApp::~GameApp()
{
}
//ç¨åºå¯å¨
void GameApp::Create()
{
JRenderer* renderer = JRenderer::GetInstance();
// Load background texture (texture format can be PNG,番号番号备用域名界面源码 JPG or GIF)
mBgTex = renderer->LoadTexture("bg.jpg");//åå§åå è½½èæ¯å¾ç å¯ä»¥PNG JPG GIFç å¼åçAPIå°è£ çå¾å¥½ é½æä¾çäºé«å±çAPI 没ææ´é²ä»ä¹åºå±çä¸è¥¿= =! çæ¥ä¹åæ对å¾çå¤ççèèæç¹å¤èäº è½è¿è¡ä¸Mç3D游æ åºè¯¥ä¸ä¼å¤ªå¨ä¹å åæ¶è ä¸æ³é²å°±è¡
// Load texture for the characters (use TEX_TYPE_USE_VRAM to load texture into VRAM on PSP and this can speed up the rendering)
mSpriteTex = renderer->LoadTexture("planet.png", TEX_TYPE_USE_VRAM);//ç¨è¿ä¸ªåæ°æ¥å é
//JQuadå®ä¹äºä¸ä¸ªèå´ å¨æ²¡BgTexä¸ ä»å·¦ä¸è§å°å³ä¸è§ ç代ç ç¥éäºPSPå±å¹ç尺寸为
*mBg = new JQuad(mBgTex, 0, 0, , ); // Create background quad for rendering.
// Now let's create the image quads for the characters. The two characters are stored in one texture
// so we have to know the location and size of each one to make the quads.
mBoy = new JQuad(mSpriteTex, 0, 0, , );//åæ ·å¯¹ç·å©çåºåå®ä¹èå´
mBoy->SetHotSpot(.5f, .0f); // Set the pivot point to the middle.å®ä¹äºè¿ä¸ªå¾ççæ ¸å¿åæ è¿éå®ä¹ä¸ºä¸å¿ å¨æ转çæ¶åå´ç»ä¸å¿æ转 æ©
mGirl = new JQuad(mSpriteTex, , 0, , );//女å©çå¾çä»å¼å§è¶è¿äºç·å©çå¾ç
mGirl->SetHotSpot(.0f, .0f);//åæ ·è®¾ç½®ä¸å¿ä¸ºHotSpot
}
void GameApp::Destroy()
{
SAFE_DELETE(mBgTex);//è°ç¨äºä¸ä¸ªå® å¨JTypes.héé¢:#define SAFE_DELETE(x) if (x) { delete x; x = NULL; } å¦ææç« è¯´éæ¾JTextureéè¦ç¨ä»ä¹engine.ä»ä¹ åºè¯¥æææ¯ä¸æ ·çmEngine->FreeMusic(mMusic);
SAFE_DELETE(mBg);
SAFE_DELETE(mSpriteTex);
SAFE_DELETE(mBoy);
SAFE_DELETE(mGirl);
}
//Updateæ¹æ³æ²¡æåå
void GameApp::Update()
{
JGE* engine = JGE::GetInstance();
if (engine->GetButtonClick(PSP_CTRL_TRIANGLE)) // Do a screen shot when the TRIANGLE button is pressed
{
char s[];
sprintf(s, "ms0:/screenshot.png");
JRenderer::GetInstance()->ScreenShot(s);
}
if (engine->GetButtonClick(PSP_CTRL_CROSS)) // Exit when the CROSS button is pressed
{
engine->End();
return;
}
}
void GameApp::Render()
{
JRenderer* renderer = JRenderer::GetInstance();
renderer->RenderQuad(mBg, 0, 0);//å ·ä½ç»å±å¹äº ç»å¶æ´ä¸ªèæ¯ ç»mBgçèå´JQuad
renderer->RenderQuad(mBoy, .5, , 0.0f, 1.0f, 1.0f); // Scale down the characters a little bit when rendering.
renderer->RenderQuad(mGirl, , , 0.0f, 0.7f, 0.7f);//åæ°åå«ä¸ºxç¹ yç¹ å·¦ä¸è§å¼å§è®¡ç® 0.0f为æ转è§åº¦ 没å¼æç½è¿ä¸ªåä½æ¯ä»ä¹ 0.7f å0.7fæ¯xè½´åyè½´ç缩æ¾æ¯ä¾1æ¯æç §å大å°0.7fæ¯ç¼©å°äº
Sleep(1);//èªå·±å ç 纯粹æ¯ä¸ºäºåå°CPUå ç¨ å¦åä¸è¿è¡CPUå°±æ»¡äº ä¼¼ä¹è¿ä¸ªå½æ°å¨PSPä¸ä¸æ¯æ
}
void GameApp::Pause()
{
}
void GameApp::Resume()
åä¸å «çç徽设计å¾
å ³äºè¿ä¸ªï¼ç½é¡µå¾åºå¯ä»¥æ¾å°å¾å¤è¿æ¹é¢çç´ æãè¿ä¸ªèªå·±å¤ççç¨å¿ä½ä¼æ好~ 设计çå¾½ä¸è¦å¤ªå¤æï¼å¤ªå¤æç让人çä¸æï¼é£å°±ä¸è½åå°å®£ä¼ çææãè¦ä»ç级ççªå·èè设计ï¼å¦é«ä¸å «çï¼åºè¯¥ä»å «ååæç« ï¼çåºè¯¥ä»è¿ä¸ªæ°åä¸åæç« ï¼å¦ç们å¯ä»¥æ ¹æ®éè¦å°æ°å转æ¢æå¤ç§å¡éçå½¢ç¶ã