* Update for linux support.
This commit is contained in:
jean.chalard
2008-11-05 13:38:39 +00:00
parent 89dae65237
commit ddf04e14e8
39 changed files with 975 additions and 786 deletions

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _FILE_SYSTEM_H_
@@ -16,7 +16,7 @@
#include <map>
#include <string>
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
#else
#include <pspiofilemgr.h>
@@ -47,58 +47,58 @@ public:
static void Destroy();
//////////////////////////////////////////////////////////////////////////
/// Attach ZIP archive to the file system.
///
/// @param zipfile - Name of ZIP archive.
/// @param password - Password for the ZIP archive. Default is NULL.
///
///
/// @return Status of the attach operation.
///
///
//////////////////////////////////////////////////////////////////////////
bool AttachZipFile(const string &zipfile, char *password = NULL);
//////////////////////////////////////////////////////////////////////////
/// Release the attached ZIP archive.
///
///
//////////////////////////////////////////////////////////////////////////
void DetachZipFile();
//////////////////////////////////////////////////////////////////////////
/// Open file for reading.
///
///
//////////////////////////////////////////////////////////////////////////
bool OpenFile(const string &filename);
//////////////////////////////////////////////////////////////////////////
/// Read data from file.
///
///
/// @param buffer - Buffer for reading.
/// @param size - Number of bytes to read.
///
///
/// @return Number of bytes read.
///
///
//////////////////////////////////////////////////////////////////////////
int ReadFile(void *buffer, int size);
//////////////////////////////////////////////////////////////////////////
/// Get size of file.
///
///
//////////////////////////////////////////////////////////////////////////
int GetFileSize();
//////////////////////////////////////////////////////////////////////////
/// Close file.
///
///
//////////////////////////////////////////////////////////////////////////
void CloseFile();
//////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations
///
///
/// @resourceRoot - New root.
///
///
//////////////////////////////////////////////////////////////////////////
void SetResourceRoot(const string& resourceRoot);
@@ -113,7 +113,7 @@ private:
string mZipFileName;
char *mPassword;
bool mZipAvailable;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
FILE *mFile;
#else
SceUID mFile;

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _JGE_H_
@@ -32,12 +32,19 @@
bool JGEGetButtonState(u32 button);
bool JGEGetButtonClick(u32 button);
#elif LINUX
void JGEControl();
BOOL JGEGetKeyState(int key);
bool JGEGetButtonState(uint32_t button);
bool JGEGetButtonClick(uint32_t button);
#else
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
@@ -73,11 +80,11 @@ private:
// JMotionSystem* mMotionSystem;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
float mDeltaTime;
JMusic *mCurrentMusic;
#else
SceCtrlData mCtrlPad;
u32 mOldButtons;
@@ -92,7 +99,7 @@ private:
float mDelta;
bool mDebug;
bool mPaused;
char mDebuggingMsg[256];
@@ -103,7 +110,7 @@ private:
static JGE* mInstance;
public:
@@ -187,7 +194,7 @@ public:
/// @return Status of the system.
//////////////////////////////////////////////////////////////////////////
bool IsDone() { return mDone; }
//////////////////////////////////////////////////////////////////////////
/// Set the user's core application class.
@@ -195,7 +202,7 @@ public:
/// @param app - User defined application class.
//////////////////////////////////////////////////////////////////////////
void SetApp(JApp *app);
//////////////////////////////////////////////////////////////////////////
/// Print debug message.
@@ -206,7 +213,7 @@ public:
void Assert(const char *filename, long lineNumber);
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
void SetDelta(int delta);
#endif

View File

@@ -12,8 +12,6 @@
#ifndef _JGUI_H
#define _JGUI_H
#include "JGE.h"
#include "JSprite.h"

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
@@ -21,7 +21,7 @@
//////////////////////////////////////////////////////////////////////////
/// Bitmap font class for LMNOpc's Bitmap Font Builder:
/// http://www.lmnopc.com/bitmapfontbuilder/
///
///
/// Two files are used for each font:
/// 1: xxx.png, font bitmap.
/// 2: xxx.dat, widths for each character
@@ -34,11 +34,11 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Constructor.
///
///
/// @param fontname - Name of the font WITHOUT extensions.
/// @param lineheight - Font height.
/// @param useVideoRAM - Indicate to use video RAM to store the font image or not (PSP only).
///
///
//////////////////////////////////////////////////////////////////////////
JLBFont(const char *fontname, int lineheight, bool useVideoRAM=false);
@@ -46,104 +46,104 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Rendering text to screen.
///
///
/// @param string - text for rendering.
/// @param x - X position of text.
/// @param y - Y position of text.
/// @align - Text aligment.
///
///
//////////////////////////////////////////////////////////////////////////
void DrawString(const char *string, float x, float y, int align=JGETEXT_LEFT);
//////////////////////////////////////////////////////////////////////////
/// Rendering text to screen with syntax similar to printf of C/C++.
///
///
/// @param x - X position of text.
/// @param y - Y position of text.
/// @param format - String formatting.
///
///
//////////////////////////////////////////////////////////////////////////
void printf(float x, float y, const char *format, ...);
//////////////////////////////////////////////////////////////////////////
/// Set font color.
///
///
/// @param color - color of font.
///
///
//////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Set scale for rendering.
///
///
/// @param scale - Scale for rendering characters.
///
///
//////////////////////////////////////////////////////////////////////////
void SetScale(float scale);
//////////////////////////////////////////////////////////////////////////
/// Set angle for rendering.
///
///
/// @param rot - Rotation angle in radian.
///
///
//////////////////////////////////////////////////////////////////////////
void SetRotation(float rot);
//////////////////////////////////////////////////////////////////////////
/// Set font tracking.
///
///
/// @param tracking - Font tracking.
///
///
//////////////////////////////////////////////////////////////////////////
void SetTracking(float tracking);
//////////////////////////////////////////////////////////////////////////
/// Get font color.
///
///
/// @return Font color.
///
///
//////////////////////////////////////////////////////////////////////////
PIXEL_TYPE GetColor() const;
//////////////////////////////////////////////////////////////////////////
/// Get rendering scale.
///
///
/// @return Rendering scale.
///
///
//////////////////////////////////////////////////////////////////////////
float GetScale() const;
//////////////////////////////////////////////////////////////////////////
/// Get rendering angle.
///
///
/// @return Rendering angle.
///
///
//////////////////////////////////////////////////////////////////////////
float GetRotation() const;
//////////////////////////////////////////////////////////////////////////
/// Get font tracking.
///
///
/// @return Font tracking.
///
///
//////////////////////////////////////////////////////////////////////////
float GetTracking() const;
//////////////////////////////////////////////////////////////////////////
/// Get height of font.
///
///
/// @return Height of font.
///
///
//////////////////////////////////////////////////////////////////////////
float GetHeight() const;
//////////////////////////////////////////////////////////////////////////
/// Get width of rendering string on screen.
///
///
/// @param string - NULL terminated string.
///
///
/// @return - Width in pixels
///
///
//////////////////////////////////////////////////////////////////////////
float GetStringWidth(const char *string) const;
@@ -152,9 +152,9 @@ public:
/// is from index 0-127 and the second from 128-255. You should use this
/// function to select which set of characters you want to use. The index
/// base should be either 0 or 128.
///
///
/// @param base - Base for the character set to use.
///
///
//////////////////////////////////////////////////////////////////////////
void SetBase(int base);

View File

@@ -11,7 +11,7 @@
#ifndef _MD2MODEL_H
#define _MD2MODEL_H
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
#else
@@ -236,7 +236,7 @@ private:
void CheckNextState();
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
void CalculateNormal(float *p1, float *p2, float *p3);
#else
void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3);

View File

@@ -15,7 +15,7 @@
using namespace std;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
#else

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _JRENDERER_H_
@@ -21,16 +21,18 @@
#include "JTypes.h"
#ifdef WIN32
#if defined (WIN32)
#include <windows.h>
#elif defined (LINUX)
#else
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
@@ -54,7 +56,7 @@
//////////////////////////////////////////////////////////////////////////
/// A collection of core rendering functions.
/// A collection of core rendering functions.
///
//////////////////////////////////////////////////////////////////////////
class JRenderer
@@ -108,81 +110,81 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Taking a screen shot.
///
/// @note This function works on PSP only. A PNG file will be saved in
///
/// @note This function works on PSP only. A PNG file will be saved in
/// the current folder of the game applicaton.
///
///
//////////////////////////////////////////////////////////////////////////
void ScreenShot(const char* filename);
//////////////////////////////////////////////////////////////////////////
/// Load a texture from file.
///
///
/// @param filename - Name of file.
/// @param mode - Choose to put texture in VRAM (PSP only).
///
///
//////////////////////////////////////////////////////////////////////////
JTexture* LoadTexture(const char* filename, int mode = 0);
//////////////////////////////////////////////////////////////////////////
/// Create texture from memory on the fly.
///
///
/// @param width - Width of texture.
/// @param height - Height of texture.
/// @param mode - Choose to put texture in VRAM (PSP only)
///
///
//////////////////////////////////////////////////////////////////////////
JTexture* CreateTexture(int width, int height, int mode = 0);
//////////////////////////////////////////////////////////////////////////
/// Clear entire screen to a particular color.
///
///
/// @param color - Color to fill the screen.
///
///
//////////////////////////////////////////////////////////////////////////
void ClearScreen(PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Enable VSync for the smoothness of moving objects. (PSP only)
///
///
/// @param flag - true to enable, false to disable.
///
///
//////////////////////////////////////////////////////////////////////////
void EnableVSync(bool flag);
//////////////////////////////////////////////////////////////////////////
/// Enable bi-linear filtering for better looking on-screen images.
///
///
/// @param flag - true to enable, false to disable.
///
///
//////////////////////////////////////////////////////////////////////////
void EnableTextureFilter(bool flag);
//////////////////////////////////////////////////////////////////////////
/// Remove all textures from VRAM (PSP only)
///
///
//////////////////////////////////////////////////////////////////////////
void ResetPrivateVRAM();
//////////////////////////////////////////////////////////////////////////
/// Enable/disable swizzle optimization. (PSP only)
///
///
/// @param s - 1 to enable, 0 to disable.
///
///
//////////////////////////////////////////////////////////////////////////
void SetSwizzle(int s) { mSwizzle = s; }
//////////////////////////////////////////////////////////////////////////
/// Bind texture to be used for the rendering followed.
///
///
/// @param tex - Texture to use.
///
///
//////////////////////////////////////////////////////////////////////////
void BindTexture(JTexture *tex);
//////////////////////////////////////////////////////////////////////////
/// Set texture blending options.
///
///
/// @par Blending options:
///
/// @code
@@ -193,9 +195,9 @@ public:
/// BLEND_ONE_MINUS_SRC_COLOR
/// BLEND_SRC_ALPHA
/// BLEND_ONE_MINUS_SRC_ALPHA
/// BLEND_DST_ALPHA
/// BLEND_DST_ALPHA
/// BLEND_ONE_MINUS_DST_ALPHA
/// BLEND_DST_COLOR
/// BLEND_DST_COLOR
/// BLEND_ONE_MINUS_DST_COLOR
/// BLEND_SRC_ALPHA_SATURATE
///
@@ -203,29 +205,29 @@ public:
///
/// @param src - Blending option for source image.
/// @param dest - Blending option for destination image.
///
///
//////////////////////////////////////////////////////////////////////////
void SetTexBlend(int src, int dest);
//////////////////////////////////////////////////////////////////////////
/// Set texture blending option for source image.
///
///
/// @param src - Blending option for source image.
///
///
//////////////////////////////////////////////////////////////////////////
void SetTexBlendSrc(int src);
//////////////////////////////////////////////////////////////////////////
/// Set texture blending option for destination image.
///
///
/// @param dest - Blending option for destination image.
///
///
//////////////////////////////////////////////////////////////////////////
void SetTexBlendDest(int dest);
//////////////////////////////////////////////////////////////////////////
/// Enable rendering in 2D mode.
///
///
/// @note To be implemented.
///
//////////////////////////////////////////////////////////////////////////
@@ -236,7 +238,7 @@ public:
/// Enable rendering in 3D mode.
///
/// @note To be implemented.
///
///
//////////////////////////////////////////////////////////////////////////
void Enable3D();
@@ -244,12 +246,12 @@ public:
/// Restrict all rendering to a rectangular area.
///
/// @note This is just the glScissor() function of OpenGL.
///
///
/// @param x - Left of the clipping area.
/// @param y - Top of the clipping area.
/// @param width - Width of the clipping area.
/// @param height - Height of the clipping area.
///
///
//////////////////////////////////////////////////////////////////////////
void SetClip(int x, int y, int width, int height);
@@ -271,52 +273,52 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Rotate along X axis.
///
///
/// @param angle - Angle to rotate ( in radians).
///
///
//////////////////////////////////////////////////////////////////////////
void RotateX(float angle);
//////////////////////////////////////////////////////////////////////////
/// Rotate along Y axis.
///
///
/// @param angle - Angle to rotate ( in radians).
///
///
//////////////////////////////////////////////////////////////////////////
void RotateY(float angle);
//////////////////////////////////////////////////////////////////////////
/// Rotate along Z axis.
///
///
/// @param angle - Angle to rotate ( in radians).
///
///
//////////////////////////////////////////////////////////////////////////
void RotateZ(float angle);
//////////////////////////////////////////////////////////////////////////
/// Push matrix.
///
///
//////////////////////////////////////////////////////////////////////////
void PushMatrix();
//////////////////////////////////////////////////////////////////////////
/// Pop matrix.
///
///
//////////////////////////////////////////////////////////////////////////
void PopMatrix();
//////////////////////////////////////////////////////////////////////////
/// Set the field of view angle (in degrees), effective at the next
/// Enable3D() call.
///
///
/// @param fov - The field of view angle (in degrees).
///
///
//////////////////////////////////////////////////////////////////////////
void SetFOV(float fov);
//////////////////////////////////////////////////////////////////////////
/// Render triangles.
///
///
/// @param texture - Texture for the triangles.
/// @param tris - List of triangles.
/// @param start - starting index (Note: Index of triangles, NOT vertices).
@@ -370,7 +372,7 @@ public:
/// @param x2 - Ending vertex, x.
/// @param y2 - Ending vertex, y.
/// @param color - Filling color.
///
///
//////////////////////////////////////////////////////////////////////////
void DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color);
@@ -383,23 +385,23 @@ public:
/// @param y2 - Ending vertex, y.
/// @param lineWidth - Line width.
/// @param color - Filling color.
///
///
//////////////////////////////////////////////////////////////////////////
void DrawLine(float x1, float y1, float x2, float y2, float lineWidth, PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Plot a pixel on screen.
///
///
/// @param x - X position of the pixel.
/// @param y - Y position of the pixel.
/// @param color - Draw colour.
///
///
//////////////////////////////////////////////////////////////////////////
void Plot(float x, float y, PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Plot an array of pixels.
///
///
/// @param x - Array of X positions.
/// @param y - Array of Y positions.
/// @param count - Number of pixels to plot.
@@ -410,7 +412,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Draw polygon with filled colour.
///
///
/// @param x - Array of X positions.
/// @param y - Array of Y positions.
/// @param count - Side count of the polygon.
@@ -421,7 +423,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Draw polygon.
///
///
/// @param x - Array of X positions.
/// @param y - Array of Y positions.
/// @param count - Side count of the polygon.
@@ -429,10 +431,10 @@ public:
///
//////////////////////////////////////////////////////////////////////////
void DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Draw symmetric polygon with certain number of sides.
///
///
/// @param x - X positions of center of the polygon.
/// @param y - Y positions of center of the polygon.
/// @param size - Size of polygon.
@@ -445,7 +447,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Draw solid symmetric polygon with certain number of sides.
///
///
/// @param x - X positions of center of the polygon.
/// @param y - Y positions of center of the polygon.
/// @param size - Size of polygon.
@@ -455,10 +457,10 @@ public:
///
//////////////////////////////////////////////////////////////////////////
void FillPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Draw circle with filled colour.
///
///
/// @param x - X positions of center of the circle.
/// @param y - Y positions of center of the circle.
/// @param radius - Radius of circle.
@@ -469,7 +471,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Draw circle.
///
///
/// @param x - X positions of center of the circle.
/// @param y - Y positions of center of the circle.
/// @param radius - Radius of circle.
@@ -533,11 +535,11 @@ private:
static JRenderer* mInstance;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
GLuint mCurrentTex;
#else
u32 mVideoBufferStart;
@@ -545,7 +547,7 @@ private:
PIXEL_TYPE* mVRAM;
int mCurrentTex;
int mCurrentBlend;
#endif
bool mVsync;
@@ -563,7 +565,7 @@ private:
JImageFilter* mImageFilter;
int mCurrentRenderMode;
float mFOV;
#ifdef USING_MATH_TABLE

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _JSOUNDSYSTEM_H_
@@ -22,13 +22,13 @@
#ifdef WIN32
#include <windows.h>
#elif defined (LINUX)
#else
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
@@ -48,12 +48,12 @@ public:
JMusic();
~JMusic();
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
#else
JCooleyesMP3* mTrack;
#endif
};
@@ -65,8 +65,8 @@ public:
~JSample();
int mVoice;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mSample;
#else
WAVDATA *mSample;
@@ -75,7 +75,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Sound engine for playing sound effects (WAV) and background
/// Sound engine for playing sound effects (WAV) and background
/// music (MP3).
///
//////////////////////////////////////////////////////////////////////////
@@ -96,91 +96,91 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Load music.
///
///
/// @note MP3 is the only supported format for the moment.
///
///
/// @param filename - Name of the music file.
///
///
//////////////////////////////////////////////////////////////////////////
JMusic *LoadMusic(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Delete music from memory.
///
///
/// @param music - Music to be deleted.
///
///
//////////////////////////////////////////////////////////////////////////
//void FreeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Play music.
///
///
/// @param music - Music to be played.
/// @param looping - Play the music in a loop.
///
///
//////////////////////////////////////////////////////////////////////////
void PlayMusic(JMusic *music, bool looping = false);
//////////////////////////////////////////////////////////////////////////
/// Stop playing.
///
///
/// @param music - Music to be stopped.
///
///
//////////////////////////////////////////////////////////////////////////
void StopMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Resume playing.
///
///
/// @param music - Music to be resumed.
///
///
//////////////////////////////////////////////////////////////////////////
void ResumeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Load sound effect.
///
///
/// @note WAV sound effect only.
///
///
/// @param fileName - Sound effect for loading.
///
///
//////////////////////////////////////////////////////////////////////////
JSample *LoadSample(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Delete sound effect from memory.
///
///
/// @param sample - Sound to be deleted.
///
///
//////////////////////////////////////////////////////////////////////////
//void FreeSample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Play sound effect.
///
///
/// @param sample - Sound for playing.
///
///
//////////////////////////////////////////////////////////////////////////
void PlaySample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Set volume for audio playback.
///
///
/// @param volume - New volume.
///
///
//////////////////////////////////////////////////////////////////////////
void SetVolume(int volume);
protected:
JSoundSystem();
~JSoundSystem();
void InitSoundSystem();
void DestroySoundSystem();
private:
#ifdef WIN32
JMusic *mCurrentMusic;

View File

@@ -3,15 +3,15 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _SPRITE_H_
#define _SPRITE_H_
#ifdef WIN32
#if defined (WIN32) || defined(LINUX)
#include <math.h>
#else
#include <fastmath.h>
@@ -36,15 +36,15 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Constructor.
///
/// @param tex - Texture for the first frame and the following frames.
///
/// @param tex - Texture for the first frame and the following frames.
/// NULL to indicate no starting frame.
/// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture.
/// @param width - Width of the frame.
/// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped.
///
///
//////////////////////////////////////////////////////////////////////////
JSprite(JTexture *tex=NULL, float x=0.0f, float y=0.0f, float width=0.0f, float height=0.0f, bool flipped = false);
@@ -52,128 +52,128 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Update animation.
///
///
/// @param dt - Delta time since last update (in second).
///
///
//////////////////////////////////////////////////////////////////////////
virtual void Update(float dt);
//////////////////////////////////////////////////////////////////////////
/// Render current frame.
///
///
//////////////////////////////////////////////////////////////////////////
virtual void Render();
//////////////////////////////////////////////////////////////////////////
/// Set animation type.
///
///
/// @param type - Animation type.
///
///
/// @code
/// ANIMATION_TYPE_LOOPING - Repeat playing (Default).
/// ANIMATION_TYPE_ONCE_AND_GONE - Play animation once only.
/// ANIMATION_TYPE_ONCE_AND_BACK - Play to end and then stay at first frame.
/// ANIMATION_TYPE_PINGPONG - Play forward then backward and repeat.
/// @endcode
///
///
//////////////////////////////////////////////////////////////////////////
void SetAnimationType(int type);
//////////////////////////////////////////////////////////////////////////
/// Enable/Disable sprite.
///
///
/// @param f - True to enable, false to disable.
///
///
//////////////////////////////////////////////////////////////////////////
void SetActive(bool f);
//////////////////////////////////////////////////////////////////////////
/// Get current active status.
///
///
/// @return Active status.
///
///
//////////////////////////////////////////////////////////////////////////
bool IsActive();
//////////////////////////////////////////////////////////////////////////
/// Give sprite an id.
///
///
/// @param id - Id.
///
///
//////////////////////////////////////////////////////////////////////////
void SetId(int id);
//////////////////////////////////////////////////////////////////////////
/// Get sprite id.
///
///
/// @return Sprite id.
//////////////////////////////////////////////////////////////////////////
int GetId();
//////////////////////////////////////////////////////////////////////////
/// Flip a frame or all frames horizontally when rendering.
///
///
/// @param flip - True to flip.
/// @param index - Frame index, -1 to flip all frames.
///
///
//////////////////////////////////////////////////////////////////////////
void SetFlip(bool flip, int index = -1);
//////////////////////////////////////////////////////////////////////////
/// Add new animation frame.
///
///
/// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture.
/// @param width - Width of the frame.
/// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped.
///
///
//////////////////////////////////////////////////////////////////////////
void AddFrame(float x, float y, float width, float height, bool flipped = false);
//////////////////////////////////////////////////////////////////////////
/// Add new animation frame.
///
/// @param tex - Texture for this frame and the following frames.
///
/// @param tex - Texture for this frame and the following frames.
/// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture.
/// @param width - Width of the frame.
/// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped.
///
///
//////////////////////////////////////////////////////////////////////////
void AddFrame(JTexture *tex, float x, float y, float width, float height, bool flipped = false);
//////////////////////////////////////////////////////////////////////////
/// Set playback duration for each frame.
///
///
/// @param duration - Playback duration (in second) for each frame.
///
///
//////////////////////////////////////////////////////////////////////////
void SetDuration(float duration);
//////////////////////////////////////////////////////////////////////////
/// Get index of current frame.
///
///
/// @return Index of current frame.
///
///
//////////////////////////////////////////////////////////////////////////
int GetCurrentFrameIndex();
//////////////////////////////////////////////////////////////////////////
/// Set current frame to a particular index.
///
///
/// @param frame - The new index of current frame.
///
///
//////////////////////////////////////////////////////////////////////////
void SetCurrentFrameIndex(int frame);
//////////////////////////////////////////////////////////////////////////
/// Get current frame image (quad).
///
///
/// @return Quad object.
///
///
//////////////////////////////////////////////////////////////////////////
JQuad* GetCurrentFrame();
@@ -181,39 +181,39 @@ public:
/// Get numer of animation frames.
///
/// @return Numer of animation frames.
///
///
//////////////////////////////////////////////////////////////////////////
int GetFrameCount();
//////////////////////////////////////////////////////////////////////////
/// Get frame image (quad).
///
///
/// @return Quad object.
///
///
//////////////////////////////////////////////////////////////////////////
JQuad* GetFrame(int index);
//////////////////////////////////////////////////////////////////////////
/// Restart animation.
///
///
//////////////////////////////////////////////////////////////////////////
void RestartAnimation();
//////////////////////////////////////////////////////////////////////////
/// Start animation.
///
///
//////////////////////////////////////////////////////////////////////////
void StartAnimation();
//////////////////////////////////////////////////////////////////////////
/// Stop animation.
///
///
//////////////////////////////////////////////////////////////////////////
void StopAnimation();
//////////////////////////////////////////////////////////////////////////
/// Get animation status.
///
///
/// @return animation status
///
//////////////////////////////////////////////////////////////////////////
@@ -221,184 +221,184 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Move some distance from the current position.
///
///
/// @param x - X distance to move.
/// @param y - Y distance to move.
///
///
//////////////////////////////////////////////////////////////////////////
void Move(float x, float y);
//////////////////////////////////////////////////////////////////////////
/// Set position of the sprite.
///
///
/// @param x - X position.
/// @param y - Y position.
///
///
//////////////////////////////////////////////////////////////////////////
void SetPosition(float x, float y);
//////////////////////////////////////////////////////////////////////////
/// Set X position of the sprite.
///
///
/// @param x - X position.
///
///
//////////////////////////////////////////////////////////////////////////
void SetX(float x);
//////////////////////////////////////////////////////////////////////////
/// Set Y position of the sprite.
///
///
/// @param y - Y position.
///
///
//////////////////////////////////////////////////////////////////////////
void SetY(float y);
//////////////////////////////////////////////////////////////////////////
/// Get X position of the sprite.
///
///
/// @return X position.
///
///
//////////////////////////////////////////////////////////////////////////
float GetX();
//////////////////////////////////////////////////////////////////////////
/// Get Y position of the sprite.
///
///
/// @return Y position.
///
///
//////////////////////////////////////////////////////////////////////////
float GetY();
//////////////////////////////////////////////////////////////////////////
/// Get X velocity.
///
///
/// @return X velocity.
///
///
//////////////////////////////////////////////////////////////////////////
float GetXVelocity();
//////////////////////////////////////////////////////////////////////////
/// Get Y velocity.
///
///
/// @return Y velocity.
///
///
//////////////////////////////////////////////////////////////////////////
float GetYVelocity();
//////////////////////////////////////////////////////////////////////////
/// Set alpha value for rendering.
///
///
/// @param alpha - Alpha value.
///
///
//////////////////////////////////////////////////////////////////////////
void SetAlpha(float alpha);
//////////////////////////////////////////////////////////////////////////
/// Get alpha value.
///
///
/// @return Alpha value.
///
///
//////////////////////////////////////////////////////////////////////////
float GetAlpha();
//////////////////////////////////////////////////////////////////////////
/// Set scale of the sprite.
///
///
/// @param hscale - Horizontal scale.
/// @param vscale - Vertical scale.
///
///
//////////////////////////////////////////////////////////////////////////
void SetScale(float hscale, float vscale);
//////////////////////////////////////////////////////////////////////////
/// Set scale of the sprite.
///
///
/// @param scale - Scale for both horizontal and vertical dimension.
///
///
//////////////////////////////////////////////////////////////////////////
void SetScale(float scale);
//////////////////////////////////////////////////////////////////////////
/// Get scale of the sprite.
///
///
/// @return Scale of horizontal (assume same as the vertical).
///
///
//////////////////////////////////////////////////////////////////////////
float GetScale();
//////////////////////////////////////////////////////////////////////////
/// Set rotation factor of the sprite.
///
///
/// @param rot - Rotation angle in radian.
///
///
//////////////////////////////////////////////////////////////////////////
void SetRotation(float rot);
//////////////////////////////////////////////////////////////////////////
/// Get rotation factor of the sprite.
///
///
/// @return Rotation angle in radian.
///
///
//////////////////////////////////////////////////////////////////////////
float GetRotation();
//////////////////////////////////////////////////////////////////////////
/// Set moving speed of the sprite.
///
///
/// @param speed - Moving speed.
///
///
//////////////////////////////////////////////////////////////////////////
void SetSpeed(float speed);
//////////////////////////////////////////////////////////////////////////
/// Get moving speed of the sprite.
///
///
/// @return Moving speed.
///
///
//////////////////////////////////////////////////////////////////////////
float GetSpeed();
//////////////////////////////////////////////////////////////////////////
/// Set moving direction of the sprite.
///
///
/// @param angle - Moving angle in radian.
///
///
//////////////////////////////////////////////////////////////////////////
void SetDirection(float angle);
//////////////////////////////////////////////////////////////////////////
/// Set moving direction of the sprite based on a targeting position.
///
///
/// @param x - X position of the target.
/// @param y - Y position of the target.
///
///
//////////////////////////////////////////////////////////////////////////
void SetDirection(float x, float y);
//////////////////////////////////////////////////////////////////////////
/// Get moving direction of the sprite.
///
///
/// @return Moving angle in radian.
///
///
//////////////////////////////////////////////////////////////////////////
float GetDirection();
//////////////////////////////////////////////////////////////////////////
/// Set anchor point of a frame or all frames of the sprite. All rotation
/// Set anchor point of a frame or all frames of the sprite. All rotation
/// and collision operations are based on this anchor point.
///
///
/// @param x - X position of the anchor point.
/// @param y - Y position of the anchor point.
/// @param index - Frame index, -1 for all frames.
///
///
//////////////////////////////////////////////////////////////////////////
void SetHotSpot(float x, float y, int index=-1);
//////////////////////////////////////////////////////////////////////////
/// Set color of the sprite for rendering.
///
///
/// @param color - Color.
///
///
//////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color);
@@ -406,9 +406,9 @@ public:
//////////////////////////////////////////////////////////////////////////
/// \enum ANIMATION_TYPE
///
///
/// Type of animation.
///
///
//////////////////////////////////////////////////////////////////////////
enum ANIMATION_TYPE
{
@@ -419,12 +419,12 @@ public:
ANIMATION_TYPE_PINGPONG ///< Play forward then backward and repeat.
};
protected:
static JRenderer* mRenderer;
JTexture* mTex;
vector<JQuad*> mFrames;
float mDuration;
@@ -434,24 +434,24 @@ protected:
int mAnimationType;
int mDelta;
bool mAnimating;
float mAlpha;
PIXEL_TYPE mColor;
float mVScale;
float mHScale;
float mRotation;
float mDirection;
float mSpeed;
int mId;
bool mActive;
float mX;
float mY;
};
@@ -459,12 +459,12 @@ protected:
class JSpriteList
{
protected:
int mCount;
JSprite** mList;
//JSpriteList** mVictims;
//JCollisionListener* mCollisionListener;
public:
JSpriteList(int count);
~JSpriteList();

View File

@@ -3,15 +3,17 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _JTYPES_H
#define _JTYPES_H
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
#include <sys/types.h>
#else
@@ -19,7 +21,7 @@
#include <pspgum.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
@@ -64,12 +66,19 @@
#define BLEND_OPTION_BLEND GU_TFX_BLEND
#endif
#if defined (WIN32)
#ifdef WIN32
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#endif
#ifdef LINUX
typedef unsigned char byte;
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef bool BOOL;
#endif
#if defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#include "../Dependencies/include/fmod.h"
@@ -79,13 +88,20 @@
//#define u8 BYTE
//#define u16 WORD
//#define u32 DWORD
/*
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
typedef unsigned char u8;
typedef unsigned short u16;
//Long ?
typedef unsigned int u32;
typedef unsigned long u32;
*/
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#define BLEND_ZERO GL_ZERO
@@ -103,7 +119,7 @@
#define ARGB(a, r, g, b) ((a << 24) | (r << 16) | (g << 8) | b)
#define RGBA(r, g, b, a) ((a << 24) | (b << 16) | (g << 8) | r)
enum PspCtrlButtons
typedef enum PspCtrlButtons
{
PSP_CTRL_SELECT = 0x000001,
PSP_CTRL_START = 0x000008,
@@ -119,8 +135,8 @@
PSP_CTRL_SQUARE = 0x008000,
PSP_CTRL_HOME = 0x010000,
PSP_CTRL_HOLD = 0x020000,
PSP_CTRL_NOTE = 0x800000,
};
PSP_CTRL_NOTE = 0x800000
} PspCtrlButtons;
#define PIXEL_TYPE DWORD
@@ -191,11 +207,10 @@
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
#define SLICE_SIZE_F 64.0f
//LONG ???
typedef unsigned int DWORD;
typedef unsigned long DWORD;
#define BLEND_ZERO 0x1000
#define BLEND_ONE 0x1002
#define BLEND_ONE 0x1002
#define BLEND_SRC_COLOR GU_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GU_SRC_ALPHA
@@ -212,7 +227,7 @@
//PIXEL_TYPE color;
//ScePspFVector3 normal;
ScePspFVector3 pos;
} PSPVertex3D;
} PSPVertex3D;
#endif
@@ -304,7 +319,7 @@ public:
int mFilter;
#ifdef WIN32
#if defined (WIN32) || defined (LINUX)
GLuint mTexId;
#else
@@ -316,10 +331,10 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Custom filter for processing the texture image while loading. You
/// Custom filter for processing the texture image while loading. You
/// can change the pixels by using a custom filter before the image is
/// created as a texture.
///
///
//////////////////////////////////////////////////////////////////////////
class JImageFilter
{
@@ -339,7 +354,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Image quad.
///
///
//////////////////////////////////////////////////////////////////////////
class JQuad
{
@@ -347,74 +362,74 @@ public:
//////////////////////////////////////////////////////////////////////////
/// Constructor.
///
///
/// @param tex - Texture of the quad.
/// @param x - X position of the quad in texture.
/// @param y - Y position of the quad in texture.
/// @param width - Width of the quad.
/// @param height - Height of the quad.
///
///
//////////////////////////////////////////////////////////////////////////
JQuad(JTexture *tex, float x, float y, float width, float height);
//////////////////////////////////////////////////////////////////////////
/// Set blending color of the quad.
///
///
/// @param color - Color.
///
///
//////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color);
//////////////////////////////////////////////////////////////////////////
/// Set anchor point of the quad.
///
///
/// @param x - X position of the anchor point.
/// @param y - Y position of the anchor point.
///
///
//////////////////////////////////////////////////////////////////////////
void SetHotSpot(float x, float y);
//////////////////////////////////////////////////////////////////////////
/// Set UV positions of the quad.
///
///
/// @param x - X position of the quad in texture.
/// @param y - Y position of the quad in texture.
/// @param w - Width of the quad.
/// @param h - Height of the quad.
///
///
//////////////////////////////////////////////////////////////////////////
void SetTextureRect(float x, float y, float w, float h);
//////////////////////////////////////////////////////////////////////////
/// Get UV positions of the quad.
///
///
/// @return x - X position of the quad in texture.
/// @return y - Y position of the quad in texture.
/// @return w - Width of the quad.
/// @return h - Height of the quad.
///
///
//////////////////////////////////////////////////////////////////////////
void GetTextureRect(float *x, float *y, float *w, float *h);
//////////////////////////////////////////////////////////////////////////
/// Set horizontal flipping.
///
///
/// @param hflip - flipping flag;
///
///
//////////////////////////////////////////////////////////////////////////
void SetHFlip(bool hflip) { mHFlipped = hflip; }
//////////////////////////////////////////////////////////////////////////
/// Set vetical flipping.
///
///
/// @param hflip - flipping flag;
///
///
//////////////////////////////////////////////////////////////////////////
void SetVFlip(bool vflip) { mVFlipped = vflip; }
JTexture* mTex;
#ifdef WIN32
#if defined (WIN32) || defined(LINUX)
float mTX0;
float mTY0;
float mTX1;
@@ -441,9 +456,9 @@ public:
//////////////////////////////////////////////////////////////////////////
/// \enum JFONT_TEXT_ALIGNMENT
///
///
/// Font alignment.
///
///
//////////////////////////////////////////////////////////////////////////
enum JFONT_TEXT_ALIGNMENT
{

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//
//-------------------------------------------------------------------------------------
#ifndef _VECTOR2D_H
@@ -13,6 +13,8 @@
#ifdef WIN32
#include <math.h>
#elif defined LINUX
#include <math.h>
#else
#include <fastmath.h>
#endif
@@ -31,7 +33,7 @@ struct Vector2D
inline Vector2D &operator /=(const float scalar) { x /= scalar; y /= scalar; return *this; }
inline Vector2D &operator *=(const float scalar) { x *= scalar; y *= scalar; return *this; }
inline Vector2D &operator +=(const Vector2D &v) { x += v.x; y += v.y; return *this; }
inline Vector2D &operator -=(const Vector2D &v) { x -= v.x; y -= v.y; return *this; }
@@ -41,14 +43,14 @@ struct Vector2D
// cross product
inline float operator ^ (const Vector2D &v) const { return (x * v.y) - (y * v.x); }
inline float operator ^ (const Vector2D &v) const { return (x * v.y) - (y * v.x); }
// dot product
inline float operator * (const Vector2D &v) const { return (x*v.x) + (y*v.y); }
inline float operator * (const Vector2D &v) const { return (x*v.x) + (y*v.y); }
inline float Dot(const Vector2D &v) const { return (x * v.x) + (y * v.y); }
inline float Cross(const Vector2D &v) const { return (x * v.y) - (y * v.x); }
inline float Dot(const Vector2D &v) const { return (x * v.x) + (y * v.y); }
inline float Cross(const Vector2D &v) const { return (x * v.y) - (y * v.x); }
inline Vector2D operator * (float s) const { return Vector2D(x*s, y*s); }
inline Vector2D operator / (float s) const { return Vector2D(x/s, y/s); }
@@ -68,4 +70,4 @@ struct Vector2D
};
#endif
#endif