Apply LF line endings as an SVN property, this time on the JGE source files.
This commit is contained in:
@@ -1,59 +1,59 @@
|
||||
#ifndef DEBUGROUTINES_H
|
||||
#define DEBUGROUTINES_H
|
||||
|
||||
// dirty, but I get OS header includes this way
|
||||
#include "JGE.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#ifdef _DEBUG
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
std::string ToHex(T* pointer)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << std::hex << showbase << setfill('0') << setw(8) << (int) pointer;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_CONFIG
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
OutputDebugString(stream.str().c_str()); \
|
||||
}
|
||||
#else
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
qDebug(stream.str().c_str()); \
|
||||
}
|
||||
#endif //QT_CONFIG
|
||||
|
||||
#endif //#ifdef _DEBUG
|
||||
#endif // Win32, Linux
|
||||
|
||||
#if defined (IOS) && defined (DEBUG)
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::cout << inString << std::endl; \
|
||||
}
|
||||
#endif // IOS, DEBUG
|
||||
|
||||
|
||||
#ifndef DebugTrace
|
||||
#define DebugTrace(inString) (void (0))
|
||||
#endif
|
||||
|
||||
#endif // DEBUGROUTINES_H
|
||||
#ifndef DEBUGROUTINES_H
|
||||
#define DEBUGROUTINES_H
|
||||
|
||||
// dirty, but I get OS header includes this way
|
||||
#include "JGE.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#ifdef _DEBUG
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
std::string ToHex(T* pointer)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << std::hex << showbase << setfill('0') << setw(8) << (int) pointer;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_CONFIG
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
OutputDebugString(stream.str().c_str()); \
|
||||
}
|
||||
#else
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
qDebug(stream.str().c_str()); \
|
||||
}
|
||||
#endif //QT_CONFIG
|
||||
|
||||
#endif //#ifdef _DEBUG
|
||||
#endif // Win32, Linux
|
||||
|
||||
#if defined (IOS) && defined (DEBUG)
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::cout << inString << std::endl; \
|
||||
}
|
||||
#endif // IOS, DEBUG
|
||||
|
||||
|
||||
#ifndef DebugTrace
|
||||
#define DebugTrace(inString) (void (0))
|
||||
#endif
|
||||
|
||||
#endif // DEBUGROUTINES_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _ENCODING_H
|
||||
#define _ENCODING_H
|
||||
|
||||
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
|
||||
u16 charsets_gbk_to_ucs(const u8 * cjk);
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _ENCODING_H
|
||||
#define _ENCODING_H
|
||||
|
||||
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
|
||||
u16 charsets_gbk_to_ucs(const u8 * cjk);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,414 +1,414 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JANIMATOR_H_
|
||||
#define _JANIMATOR_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class JResourceManager;
|
||||
class JQuad;
|
||||
class JAnimatorFrame;
|
||||
class JAnimatorObject;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A frame based animation system. The animation frames and play sequence
|
||||
/// are loaded from a XML file.
|
||||
///
|
||||
/// A sample animation script:
|
||||
///
|
||||
/// @code
|
||||
/// <?xml version="1.0" standalone="no" ?>
|
||||
///
|
||||
/// <script name="abc" type="ANIMATION_TYPE_ONCE_AND_STAY" framerate="20">
|
||||
/// @endcode
|
||||
///
|
||||
/// "type" can be ANIMATION_TYPE_LOOPING, ANIMATION_TYPE_ONCE_AND_STAY,
|
||||
/// ANIMATION_TYPE_ONCE_AND_BACK, ANIMATION_TYPE_ONCE_AND_GONE or
|
||||
/// ANIMATION_TYPE_PINGPONG
|
||||
///
|
||||
/// "framerate" is the rate of playback in frames per seconds.
|
||||
///
|
||||
/// @code
|
||||
/// <frame id="1">
|
||||
/// <obj name="head">
|
||||
/// <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
|
||||
/// </obj>
|
||||
/// <obj name="body">
|
||||
/// <settings quad="body" />
|
||||
/// </obj>
|
||||
/// </frame>
|
||||
/// @endcode
|
||||
///
|
||||
/// Each frame contains one or more frame objects. Each object is a quad with various
|
||||
/// settings. "quad" is the name of the quad. "x" and "y" is the position. "hsize" is
|
||||
/// the horizontal scaling and "vsize" is the vertical scaling. "rotation" is the angle
|
||||
/// that the quad will be rotated in radians. You can also specify the color and alpha
|
||||
/// of the quad with the "r", "g", "b" and "a" parameters.
|
||||
///
|
||||
/// @code
|
||||
/// <frame id="2" time="0.20">
|
||||
/// <obj name="head">
|
||||
/// <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
|
||||
/// </obj>
|
||||
/// <obj name="body">
|
||||
/// <settings quad="body" a="128" />
|
||||
/// </obj>
|
||||
/// </frame>
|
||||
///
|
||||
///
|
||||
/// </script>
|
||||
/// @endcode
|
||||
///
|
||||
/// A frame can also overide the global frame rate by using the "time" parameter (in second)
|
||||
/// as shown above.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimator
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param resourceMgr - ResourceManager to look for images (JQuads)
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimator(JResourceManager* resourceMgr);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimator();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load animation sequence from a script file.
|
||||
///
|
||||
/// @param scriptFile - Animation script.
|
||||
///
|
||||
/// @return True if no problem during loading. False otherwise.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char* scriptFile);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Pause animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Pause();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Resume animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Resume();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update animation.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if animation is playing or not.
|
||||
///
|
||||
/// @return True if playing animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsAnimating();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the animation is active.
|
||||
///
|
||||
/// @return True if active.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsActive();
|
||||
|
||||
JResourceManager* GetResourceManager();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set current frame to a particular index.
|
||||
///
|
||||
/// @param index - The new index of current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCurrentFrameIndex(int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get index of current frame.
|
||||
///
|
||||
/// @return Index of current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetCurrentFrameIndex();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set animation type.
|
||||
///
|
||||
/// @param type - Animation type.
|
||||
///
|
||||
/// @code
|
||||
/// JSprite::ANIMATION_TYPE_LOOPING - Default
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_GONE
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_STAY
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_BACK
|
||||
/// JSprite::ANIMATION_TYPE_PINGPONG
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAnimationType(int type);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the sprite.
|
||||
///
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set anchor point of the animation. All rendering operations will be
|
||||
/// based on this anchor point.
|
||||
///
|
||||
/// @param x - X position of the anchor point.
|
||||
/// @param y - Y position of the anchor point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHotSpot(float x, float y);
|
||||
|
||||
private:
|
||||
JResourceManager* mResource;
|
||||
vector<JAnimatorFrame *> mFrames;
|
||||
|
||||
bool mAnimating;
|
||||
bool mActive;
|
||||
int mCurrentFrame;
|
||||
int mAnimationType;
|
||||
int mFrameDelta;
|
||||
|
||||
float mX;
|
||||
float mY;
|
||||
float mHotSpotX;
|
||||
float mHotSpotY;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A single frame of an animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimatorFrame
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param parent - Parent of the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimatorFrame(JAnimator* parent);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimatorFrame();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Add a new object into the frame.
|
||||
///
|
||||
/// @param obj - New animation object.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddObject(JAnimatorObject *obj);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set play time of the frame.
|
||||
///
|
||||
/// @param duration - Time to play (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFrameTime(float duration);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Frame update.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
/// @return True if the frame is done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render frame.
|
||||
///
|
||||
/// @param x - X position for rendering.
|
||||
/// @param y - Y position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start playing the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
|
||||
private:
|
||||
float mTimer;
|
||||
float mFrameTime;
|
||||
JAnimator* mAnimator;
|
||||
vector<JAnimatorObject *> mObjects;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Animation object (image quad) in a frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimatorObject
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimatorObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimatorObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update object.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render object.
|
||||
///
|
||||
/// @param x - X position for rendering.
|
||||
/// @param y - Y position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set something to show.
|
||||
///
|
||||
/// @param quad - Image quad.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the object.
|
||||
///
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set rotation factor of the object.
|
||||
///
|
||||
/// @param angle - Rotation angle in radian.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetRotation(float angle);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set horizontal scale of the object.
|
||||
///
|
||||
/// @param scale - Horizontal scale.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHScale(float scale);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set vertical scale of the object.
|
||||
///
|
||||
/// @param scale - Vertical scale.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetVScale(float scale);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blending color of the object.
|
||||
///
|
||||
/// @param color - Blending color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set horizontal flipping.
|
||||
///
|
||||
/// @param flag - flipping flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFlip(bool flag);
|
||||
|
||||
private:
|
||||
JRenderer* mRenderer;
|
||||
JQuad* mQuad;
|
||||
|
||||
float mX;
|
||||
float mY;
|
||||
float mRotation;
|
||||
float mHScale;
|
||||
float mVScale;
|
||||
PIXEL_TYPE mColor;
|
||||
bool mFlipped;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JANIMATOR_H_
|
||||
#define _JANIMATOR_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class JResourceManager;
|
||||
class JQuad;
|
||||
class JAnimatorFrame;
|
||||
class JAnimatorObject;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A frame based animation system. The animation frames and play sequence
|
||||
/// are loaded from a XML file.
|
||||
///
|
||||
/// A sample animation script:
|
||||
///
|
||||
/// @code
|
||||
/// <?xml version="1.0" standalone="no" ?>
|
||||
///
|
||||
/// <script name="abc" type="ANIMATION_TYPE_ONCE_AND_STAY" framerate="20">
|
||||
/// @endcode
|
||||
///
|
||||
/// "type" can be ANIMATION_TYPE_LOOPING, ANIMATION_TYPE_ONCE_AND_STAY,
|
||||
/// ANIMATION_TYPE_ONCE_AND_BACK, ANIMATION_TYPE_ONCE_AND_GONE or
|
||||
/// ANIMATION_TYPE_PINGPONG
|
||||
///
|
||||
/// "framerate" is the rate of playback in frames per seconds.
|
||||
///
|
||||
/// @code
|
||||
/// <frame id="1">
|
||||
/// <obj name="head">
|
||||
/// <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
|
||||
/// </obj>
|
||||
/// <obj name="body">
|
||||
/// <settings quad="body" />
|
||||
/// </obj>
|
||||
/// </frame>
|
||||
/// @endcode
|
||||
///
|
||||
/// Each frame contains one or more frame objects. Each object is a quad with various
|
||||
/// settings. "quad" is the name of the quad. "x" and "y" is the position. "hsize" is
|
||||
/// the horizontal scaling and "vsize" is the vertical scaling. "rotation" is the angle
|
||||
/// that the quad will be rotated in radians. You can also specify the color and alpha
|
||||
/// of the quad with the "r", "g", "b" and "a" parameters.
|
||||
///
|
||||
/// @code
|
||||
/// <frame id="2" time="0.20">
|
||||
/// <obj name="head">
|
||||
/// <settings quad="head" x="10" y="10" hsize="1.0" vsize="1.0" rotation="0.0" r="255" g="255" b="255" a="255" />
|
||||
/// </obj>
|
||||
/// <obj name="body">
|
||||
/// <settings quad="body" a="128" />
|
||||
/// </obj>
|
||||
/// </frame>
|
||||
///
|
||||
///
|
||||
/// </script>
|
||||
/// @endcode
|
||||
///
|
||||
/// A frame can also overide the global frame rate by using the "time" parameter (in second)
|
||||
/// as shown above.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimator
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param resourceMgr - ResourceManager to look for images (JQuads)
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimator(JResourceManager* resourceMgr);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimator();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load animation sequence from a script file.
|
||||
///
|
||||
/// @param scriptFile - Animation script.
|
||||
///
|
||||
/// @return True if no problem during loading. False otherwise.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char* scriptFile);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Pause animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Pause();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Resume animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Resume();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update animation.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if animation is playing or not.
|
||||
///
|
||||
/// @return True if playing animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsAnimating();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the animation is active.
|
||||
///
|
||||
/// @return True if active.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsActive();
|
||||
|
||||
JResourceManager* GetResourceManager();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set current frame to a particular index.
|
||||
///
|
||||
/// @param index - The new index of current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCurrentFrameIndex(int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get index of current frame.
|
||||
///
|
||||
/// @return Index of current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetCurrentFrameIndex();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set animation type.
|
||||
///
|
||||
/// @param type - Animation type.
|
||||
///
|
||||
/// @code
|
||||
/// JSprite::ANIMATION_TYPE_LOOPING - Default
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_GONE
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_STAY
|
||||
/// JSprite::ANIMATION_TYPE_ONCE_AND_BACK
|
||||
/// JSprite::ANIMATION_TYPE_PINGPONG
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAnimationType(int type);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the sprite.
|
||||
///
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set anchor point of the animation. All rendering operations will be
|
||||
/// based on this anchor point.
|
||||
///
|
||||
/// @param x - X position of the anchor point.
|
||||
/// @param y - Y position of the anchor point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHotSpot(float x, float y);
|
||||
|
||||
private:
|
||||
JResourceManager* mResource;
|
||||
vector<JAnimatorFrame *> mFrames;
|
||||
|
||||
bool mAnimating;
|
||||
bool mActive;
|
||||
int mCurrentFrame;
|
||||
int mAnimationType;
|
||||
int mFrameDelta;
|
||||
|
||||
float mX;
|
||||
float mY;
|
||||
float mHotSpotX;
|
||||
float mHotSpotY;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A single frame of an animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimatorFrame
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param parent - Parent of the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimatorFrame(JAnimator* parent);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimatorFrame();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Add a new object into the frame.
|
||||
///
|
||||
/// @param obj - New animation object.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddObject(JAnimatorObject *obj);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set play time of the frame.
|
||||
///
|
||||
/// @param duration - Time to play (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFrameTime(float duration);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Frame update.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
/// @return True if the frame is done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render frame.
|
||||
///
|
||||
/// @param x - X position for rendering.
|
||||
/// @param y - Y position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start playing the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
|
||||
private:
|
||||
float mTimer;
|
||||
float mFrameTime;
|
||||
JAnimator* mAnimator;
|
||||
vector<JAnimatorObject *> mObjects;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Animation object (image quad) in a frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JAnimatorObject
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimatorObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
~JAnimatorObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update object.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render object.
|
||||
///
|
||||
/// @param x - X position for rendering.
|
||||
/// @param y - Y position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set something to show.
|
||||
///
|
||||
/// @param quad - Image quad.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the object.
|
||||
///
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set rotation factor of the object.
|
||||
///
|
||||
/// @param angle - Rotation angle in radian.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetRotation(float angle);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set horizontal scale of the object.
|
||||
///
|
||||
/// @param scale - Horizontal scale.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHScale(float scale);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set vertical scale of the object.
|
||||
///
|
||||
/// @param scale - Vertical scale.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetVScale(float scale);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blending color of the object.
|
||||
///
|
||||
/// @param color - Blending color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set horizontal flipping.
|
||||
///
|
||||
/// @param flag - flipping flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFlip(bool flag);
|
||||
|
||||
private:
|
||||
JRenderer* mRenderer;
|
||||
JQuad* mQuad;
|
||||
|
||||
float mX;
|
||||
float mY;
|
||||
float mRotation;
|
||||
float mHScale;
|
||||
float mVScale;
|
||||
PIXEL_TYPE mColor;
|
||||
bool mFlipped;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,88 +1,88 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JAPP_H_
|
||||
#define _JAPP_H_
|
||||
|
||||
class JGE;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Main application class for the system to run. The core game class
|
||||
/// should be derived from this base class.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JApp
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
JApp();
|
||||
virtual ~JApp();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Initialization function.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Create() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Cleanup function before exiting from the game.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update function to be called for each frame update. Should perform
|
||||
/// all the game logic here.
|
||||
///
|
||||
/// @par Example: A simple Update() implementation:
|
||||
/// @code
|
||||
/// void Update()
|
||||
/// {
|
||||
/// float dt = JGE::GetInstance()->GetDelta();
|
||||
/// mX += mSpeed*dt;
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Update() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render function to be called for each frame update. Should do all the
|
||||
/// game rendering here.
|
||||
///
|
||||
/// @par Example: A simple Render() implementation:
|
||||
/// @code
|
||||
/// void Render()
|
||||
/// {
|
||||
/// JRenderer *r = JRenderer::GetInstance();
|
||||
/// r->FillRect(0,0,480,272,ARGB(255,0,0,0));
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Render() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Callback function called when the game is paused by the system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Pause() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Callback function called when the game is resumed by the system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Resume() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JAPP_H_
|
||||
#define _JAPP_H_
|
||||
|
||||
class JGE;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Main application class for the system to run. The core game class
|
||||
/// should be derived from this base class.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JApp
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
JApp();
|
||||
virtual ~JApp();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Initialization function.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Create() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Cleanup function before exiting from the game.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update function to be called for each frame update. Should perform
|
||||
/// all the game logic here.
|
||||
///
|
||||
/// @par Example: A simple Update() implementation:
|
||||
/// @code
|
||||
/// void Update()
|
||||
/// {
|
||||
/// float dt = JGE::GetInstance()->GetDelta();
|
||||
/// mX += mSpeed*dt;
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Update() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render function to be called for each frame update. Should do all the
|
||||
/// game rendering here.
|
||||
///
|
||||
/// @par Example: A simple Render() implementation:
|
||||
/// @code
|
||||
/// void Render()
|
||||
/// {
|
||||
/// JRenderer *r = JRenderer::GetInstance();
|
||||
/// r->FillRect(0,0,480,272,ARGB(255,0,0,0));
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Render() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Callback function called when the game is paused by the system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Pause() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Callback function called when the game is resumed by the system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Resume() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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>
|
||||
// Copyright (c) 2007 Cooleyes
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _COOLEYES_MP3_
|
||||
#define _COOLEYES_MP3_
|
||||
|
||||
|
||||
#define FORCE_BUFFER_ALIGNMENT
|
||||
|
||||
class JCooleyesMP3
|
||||
{
|
||||
public:
|
||||
JCooleyesMP3();
|
||||
~JCooleyesMP3();
|
||||
|
||||
bool Load(const char* filename);
|
||||
void Release();
|
||||
bool Play(bool looping = false);
|
||||
void Stop();
|
||||
void Resume();
|
||||
void FeedAudioData(void* buf, unsigned int length/*, bool mixing = false*/);
|
||||
void Decode();
|
||||
bool IsPlaying();
|
||||
|
||||
void InitBuffers(unsigned long *MP3CodecBuffer, short* decoderBuffer, short* decodedDataOutputBuffer);
|
||||
|
||||
public:
|
||||
bool mPlaying;
|
||||
SceUID mp3_handle;
|
||||
u8* mFileBuffer;
|
||||
u8* mMP3FirstFramePointer;
|
||||
int mFileSize;
|
||||
int mUpdateCounter;
|
||||
u8* mCurrFramePointer;
|
||||
int mDataPointer;
|
||||
int mSamplesPending;
|
||||
bool mAllMP3DataProcessed;
|
||||
|
||||
bool mLooping;
|
||||
|
||||
u32 mSamplePerFrame;
|
||||
u32 mChannelCount;
|
||||
u32 mSampleRate;
|
||||
|
||||
int mOutputBufferIndex;
|
||||
|
||||
short *mDecoderBuffer;
|
||||
short *mDecodedDataOutputBuffer;
|
||||
unsigned long *mMP3CodecBuffer;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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>
|
||||
// Copyright (c) 2007 Cooleyes
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _COOLEYES_MP3_
|
||||
#define _COOLEYES_MP3_
|
||||
|
||||
|
||||
#define FORCE_BUFFER_ALIGNMENT
|
||||
|
||||
class JCooleyesMP3
|
||||
{
|
||||
public:
|
||||
JCooleyesMP3();
|
||||
~JCooleyesMP3();
|
||||
|
||||
bool Load(const char* filename);
|
||||
void Release();
|
||||
bool Play(bool looping = false);
|
||||
void Stop();
|
||||
void Resume();
|
||||
void FeedAudioData(void* buf, unsigned int length/*, bool mixing = false*/);
|
||||
void Decode();
|
||||
bool IsPlaying();
|
||||
|
||||
void InitBuffers(unsigned long *MP3CodecBuffer, short* decoderBuffer, short* decodedDataOutputBuffer);
|
||||
|
||||
public:
|
||||
bool mPlaying;
|
||||
SceUID mp3_handle;
|
||||
u8* mFileBuffer;
|
||||
u8* mMP3FirstFramePointer;
|
||||
int mFileSize;
|
||||
int mUpdateCounter;
|
||||
u8* mCurrFramePointer;
|
||||
int mDataPointer;
|
||||
int mSamplesPending;
|
||||
bool mAllMP3DataProcessed;
|
||||
|
||||
bool mLooping;
|
||||
|
||||
u32 mSamplePerFrame;
|
||||
u32 mChannelCount;
|
||||
u32 mSampleRate;
|
||||
|
||||
int mOutputBufferIndex;
|
||||
|
||||
short *mDecoderBuffer;
|
||||
short *mDecodedDataOutputBuffer;
|
||||
unsigned long *mMP3CodecBuffer;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// Note: Inspired by HGE's DistortionMesh.
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JDISTORT_MESH_H
|
||||
#define _JDISTORT_MESH_H
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
class JDistortionMesh
|
||||
{
|
||||
public:
|
||||
JDistortionMesh(JTexture *tex, float x, float y, float width, float height, int cols, int rows);
|
||||
~JDistortionMesh();
|
||||
|
||||
void Render(float x, float y);
|
||||
void SetColor(int col, int row, PIXEL_TYPE color);
|
||||
void SetDisplacement(int col, int row, float dx, float dy);//, int ref);
|
||||
|
||||
private:
|
||||
|
||||
static JRenderer *mRenderer;
|
||||
Vertex* mVertices;
|
||||
int mRows;
|
||||
int mCols;
|
||||
float mCellWidth;
|
||||
float mCellHeight;
|
||||
float mTexX;
|
||||
float mTexY;
|
||||
float mTexWidth;
|
||||
float mTexHeight;
|
||||
JTexture* mTexture;
|
||||
JQuad* mQuad;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// Note: Inspired by HGE's DistortionMesh.
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JDISTORT_MESH_H
|
||||
#define _JDISTORT_MESH_H
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
class JDistortionMesh
|
||||
{
|
||||
public:
|
||||
JDistortionMesh(JTexture *tex, float x, float y, float width, float height, int cols, int rows);
|
||||
~JDistortionMesh();
|
||||
|
||||
void Render(float x, float y);
|
||||
void SetColor(int col, int row, PIXEL_TYPE color);
|
||||
void SetDisplacement(int col, int row, float dx, float dy);//, int ref);
|
||||
|
||||
private:
|
||||
|
||||
static JRenderer *mRenderer;
|
||||
Vertex* mVertices;
|
||||
int mRows;
|
||||
int mCols;
|
||||
float mCellWidth;
|
||||
float mCellHeight;
|
||||
float mTexX;
|
||||
float mTexY;
|
||||
float mTexWidth;
|
||||
float mTexHeight;
|
||||
JTexture* mTexture;
|
||||
JQuad* mQuad;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,143 +1,143 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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_
|
||||
#define _FILE_SYSTEM_H_
|
||||
|
||||
#define JGE_GET_RES(filename) JFileSystem::GetInstance()->GetResourceFile(filename)
|
||||
#define JGE_GET_RESPATH() JFileSystem::GetInstance()->GetResourceRoot()
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined(IOS)
|
||||
|
||||
#else
|
||||
#include <pspiofilemgr.h>
|
||||
#include <pspiofilemgr_fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "unzip/unzip.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Interface for low level file access with ZIP archive support. All
|
||||
/// file operations in JGE are handled through this class so if a ZIP
|
||||
/// archive is attached, all the resources will be loaded from the
|
||||
/// archive file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class JZipCache {
|
||||
public:
|
||||
JZipCache();
|
||||
~JZipCache();
|
||||
map<string,unz_file_pos *> dir;
|
||||
|
||||
};
|
||||
|
||||
class JFileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get the singleton instance
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static JFileSystem* GetInstance();
|
||||
|
||||
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);
|
||||
string GetResourceRoot();
|
||||
|
||||
// Returns a string prefixed with the resource path
|
||||
string GetResourceFile(string filename);
|
||||
|
||||
protected:
|
||||
JFileSystem();
|
||||
~JFileSystem();
|
||||
|
||||
private:
|
||||
static JFileSystem* mInstance;
|
||||
|
||||
map<string,JZipCache *>mZipCache;
|
||||
string mResourceRoot;
|
||||
string mZipFileName;
|
||||
char *mPassword;
|
||||
bool mZipAvailable;
|
||||
void preloadZip(string filename);
|
||||
#if defined (WIN32) || defined (LINUX) || defined(IOS)
|
||||
FILE *mFile;
|
||||
#else
|
||||
SceUID mFile;
|
||||
#endif
|
||||
unzFile mZipFile;
|
||||
int mFileSize;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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_
|
||||
#define _FILE_SYSTEM_H_
|
||||
|
||||
#define JGE_GET_RES(filename) JFileSystem::GetInstance()->GetResourceFile(filename)
|
||||
#define JGE_GET_RESPATH() JFileSystem::GetInstance()->GetResourceRoot()
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined(IOS)
|
||||
|
||||
#else
|
||||
#include <pspiofilemgr.h>
|
||||
#include <pspiofilemgr_fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "unzip/unzip.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Interface for low level file access with ZIP archive support. All
|
||||
/// file operations in JGE are handled through this class so if a ZIP
|
||||
/// archive is attached, all the resources will be loaded from the
|
||||
/// archive file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class JZipCache {
|
||||
public:
|
||||
JZipCache();
|
||||
~JZipCache();
|
||||
map<string,unz_file_pos *> dir;
|
||||
|
||||
};
|
||||
|
||||
class JFileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get the singleton instance
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static JFileSystem* GetInstance();
|
||||
|
||||
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);
|
||||
string GetResourceRoot();
|
||||
|
||||
// Returns a string prefixed with the resource path
|
||||
string GetResourceFile(string filename);
|
||||
|
||||
protected:
|
||||
JFileSystem();
|
||||
~JFileSystem();
|
||||
|
||||
private:
|
||||
static JFileSystem* mInstance;
|
||||
|
||||
map<string,JZipCache *>mZipCache;
|
||||
string mResourceRoot;
|
||||
string mZipFileName;
|
||||
char *mPassword;
|
||||
bool mZipAvailable;
|
||||
void preloadZip(string filename);
|
||||
#if defined (WIN32) || defined (LINUX) || defined(IOS)
|
||||
FILE *mFile;
|
||||
#else
|
||||
SceUID mFile;
|
||||
#endif
|
||||
unzFile mZipFile;
|
||||
int mFileSize;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,192 +1,192 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JBGK_FONT_H_
|
||||
#define _JBGK_FONT_H_
|
||||
|
||||
|
||||
#include "JTypes.h"
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include "JSprite.h"
|
||||
|
||||
#define BYTE u8
|
||||
#define DWORD u32
|
||||
#define BOOL int
|
||||
|
||||
|
||||
// #define GB_FONT_SIZE 16
|
||||
// #define GB_FONT_DATA_SIZE GB_FONT_SIZE*GB_FONT_SIZE/8
|
||||
// #define GB_FONT_BYTE_COUNT GB_FONT_SIZE/8
|
||||
//
|
||||
#define MAX_CACHE_SIZE 256
|
||||
//
|
||||
// #define CFONT_TEX_WIDTH 256
|
||||
// #define CFONT_TEX_HEIGHT 256
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Chinese bitmap font encoded with GBK encoding. All popurlar font sizes
|
||||
/// are supported and the following have been tested:
|
||||
/// 12x12, 16x16, 18x18, 20x20, 24x24, 28x28 and 32x32.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGBKFont
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGBKFont();
|
||||
|
||||
~JGBKFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Initialization of the font class. You need to provide both a Chinese
|
||||
/// font file and an English one as well.
|
||||
///
|
||||
/// For example:
|
||||
/// @code
|
||||
/// mChineseFont = new JGBKFont();
|
||||
/// mChineseFont->Init("Res/ASC16", "Res/GBK16");
|
||||
/// @endcode
|
||||
///
|
||||
/// @param engFileName - Name of the English font file.
|
||||
/// @param chnFileName - Name of the Chinese font file.
|
||||
/// @param fontsize - Font size.
|
||||
/// @param smallEnglishFont - Indicate to use half width when rendering English characters.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Init(const char* engFileName, const char* chnFileName, int fontsize=16, bool smallEnglishFont=false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Rendering character into cache.
|
||||
///
|
||||
/// @param ch - Single byte or word of character code.
|
||||
///
|
||||
/// @return Index of the character in cache.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int PreCacheChar(const BYTE *ch);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Scan through the string and look up the index of each character in the
|
||||
/// cache and then return all indexes in an array to be rendered later on.
|
||||
///
|
||||
/// @param str - String to look for cache indexes.
|
||||
/// @return dest - Indexes of characters in cache.
|
||||
/// @return Number of characters processed.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int PrepareString(BYTE* str, int* dest);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render string by using the indexes returned from PrepareString.
|
||||
///
|
||||
/// @param text - Cache indexes for rendering.
|
||||
/// @param count - Number of characters to render.
|
||||
/// @param x - X screen position for rendering.
|
||||
/// @param y - Y screen position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderEncodedString(const int* text, int count, float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render string to screen.
|
||||
///
|
||||
/// @param str - String to render.
|
||||
/// @param x - X screen position for rendering.
|
||||
/// @param y - Y screen position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(BYTE* str, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
int GetStringWidth(BYTE* str);
|
||||
int GetStringHeight(BYTE* str);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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 color.
|
||||
///
|
||||
/// @param color - color of font.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set background color.
|
||||
///
|
||||
/// @param color - Background color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBgColor(PIXEL_TYPE color);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
BYTE* mChnFont;
|
||||
BYTE* mEngFont;
|
||||
|
||||
DWORD* mCharBuffer;
|
||||
|
||||
PIXEL_TYPE mColor;
|
||||
PIXEL_TYPE mBgColor;
|
||||
|
||||
int mFontSize;
|
||||
int mBytesPerChar;
|
||||
int mBytesPerRow;
|
||||
|
||||
int mCacheSize;
|
||||
int mCacheImageWidth;
|
||||
int mCacheImageHeight;
|
||||
|
||||
int mCol;
|
||||
int mRow;
|
||||
|
||||
//public:
|
||||
|
||||
JTexture* mTexture;
|
||||
JQuad** mSprites;
|
||||
|
||||
int *mGBCode;
|
||||
|
||||
int mCurr;
|
||||
|
||||
float mScale;
|
||||
float mRotation;
|
||||
|
||||
int mCount;
|
||||
|
||||
bool mSmallEnglishFont;
|
||||
|
||||
void GetStringArea(BYTE* str, int *w, int *h);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JBGK_FONT_H_
|
||||
#define _JBGK_FONT_H_
|
||||
|
||||
|
||||
#include "JTypes.h"
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include "JSprite.h"
|
||||
|
||||
#define BYTE u8
|
||||
#define DWORD u32
|
||||
#define BOOL int
|
||||
|
||||
|
||||
// #define GB_FONT_SIZE 16
|
||||
// #define GB_FONT_DATA_SIZE GB_FONT_SIZE*GB_FONT_SIZE/8
|
||||
// #define GB_FONT_BYTE_COUNT GB_FONT_SIZE/8
|
||||
//
|
||||
#define MAX_CACHE_SIZE 256
|
||||
//
|
||||
// #define CFONT_TEX_WIDTH 256
|
||||
// #define CFONT_TEX_HEIGHT 256
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Chinese bitmap font encoded with GBK encoding. All popurlar font sizes
|
||||
/// are supported and the following have been tested:
|
||||
/// 12x12, 16x16, 18x18, 20x20, 24x24, 28x28 and 32x32.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGBKFont
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGBKFont();
|
||||
|
||||
~JGBKFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Initialization of the font class. You need to provide both a Chinese
|
||||
/// font file and an English one as well.
|
||||
///
|
||||
/// For example:
|
||||
/// @code
|
||||
/// mChineseFont = new JGBKFont();
|
||||
/// mChineseFont->Init("Res/ASC16", "Res/GBK16");
|
||||
/// @endcode
|
||||
///
|
||||
/// @param engFileName - Name of the English font file.
|
||||
/// @param chnFileName - Name of the Chinese font file.
|
||||
/// @param fontsize - Font size.
|
||||
/// @param smallEnglishFont - Indicate to use half width when rendering English characters.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Init(const char* engFileName, const char* chnFileName, int fontsize=16, bool smallEnglishFont=false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Rendering character into cache.
|
||||
///
|
||||
/// @param ch - Single byte or word of character code.
|
||||
///
|
||||
/// @return Index of the character in cache.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int PreCacheChar(const BYTE *ch);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Scan through the string and look up the index of each character in the
|
||||
/// cache and then return all indexes in an array to be rendered later on.
|
||||
///
|
||||
/// @param str - String to look for cache indexes.
|
||||
/// @return dest - Indexes of characters in cache.
|
||||
/// @return Number of characters processed.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int PrepareString(BYTE* str, int* dest);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render string by using the indexes returned from PrepareString.
|
||||
///
|
||||
/// @param text - Cache indexes for rendering.
|
||||
/// @param count - Number of characters to render.
|
||||
/// @param x - X screen position for rendering.
|
||||
/// @param y - Y screen position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderEncodedString(const int* text, int count, float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render string to screen.
|
||||
///
|
||||
/// @param str - String to render.
|
||||
/// @param x - X screen position for rendering.
|
||||
/// @param y - Y screen position for rendering.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(BYTE* str, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
int GetStringWidth(BYTE* str);
|
||||
int GetStringHeight(BYTE* str);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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 color.
|
||||
///
|
||||
/// @param color - color of font.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set background color.
|
||||
///
|
||||
/// @param color - Background color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBgColor(PIXEL_TYPE color);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
BYTE* mChnFont;
|
||||
BYTE* mEngFont;
|
||||
|
||||
DWORD* mCharBuffer;
|
||||
|
||||
PIXEL_TYPE mColor;
|
||||
PIXEL_TYPE mBgColor;
|
||||
|
||||
int mFontSize;
|
||||
int mBytesPerChar;
|
||||
int mBytesPerRow;
|
||||
|
||||
int mCacheSize;
|
||||
int mCacheImageWidth;
|
||||
int mCacheImageHeight;
|
||||
|
||||
int mCol;
|
||||
int mRow;
|
||||
|
||||
//public:
|
||||
|
||||
JTexture* mTexture;
|
||||
JQuad** mSprites;
|
||||
|
||||
int *mGBCode;
|
||||
|
||||
int mCurr;
|
||||
|
||||
float mScale;
|
||||
float mRotation;
|
||||
|
||||
int mCount;
|
||||
|
||||
bool mSmallEnglishFont;
|
||||
|
||||
void GetStringArea(BYTE* str, int *w, int *h);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _GAME_LAUNCHER_H_
|
||||
#define _GAME_LAUNCHER_H_
|
||||
|
||||
|
||||
#include "JApp.h"
|
||||
#include "JTypes.h"
|
||||
#include "JFileSystem.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// An interface for JGE to get the user defined JApp class.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGameLauncher
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get user defined JApp instance. The function will be called when
|
||||
/// JGE starts.
|
||||
///
|
||||
/// @return - User defined JApp instance.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JApp* GetGameApp();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get application name. Mainly for Windows build to setup the name
|
||||
/// on the title bar.
|
||||
///
|
||||
/// @return - Application name.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
char *GetName();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get initialization flags.
|
||||
///
|
||||
/// @return - Initialization flags.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u32 GetInitFlags();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _GAME_LAUNCHER_H_
|
||||
#define _GAME_LAUNCHER_H_
|
||||
|
||||
|
||||
#include "JApp.h"
|
||||
#include "JTypes.h"
|
||||
#include "JFileSystem.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// An interface for JGE to get the user defined JApp class.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGameLauncher
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get user defined JApp instance. The function will be called when
|
||||
/// JGE starts.
|
||||
///
|
||||
/// @return - User defined JApp instance.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JApp* GetGameApp();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get application name. Mainly for Windows build to setup the name
|
||||
/// on the title bar.
|
||||
///
|
||||
/// @return - Application name.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
char *GetName();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get initialization flags.
|
||||
///
|
||||
/// @return - Initialization flags.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
u32 GetInitFlags();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,259 +1,259 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JGAME_OBJECT_H_
|
||||
#define _JGAME_OBJECT_H_
|
||||
|
||||
#include "JTypes.h"
|
||||
#include "JRenderer.h"
|
||||
#include "JSprite.h"
|
||||
|
||||
|
||||
#define FLASH_TIME 0.10f
|
||||
#define FLASHING_COUNT 6
|
||||
|
||||
#define RENDER_FLAG_ANGLE 0x0001
|
||||
#define RENDER_FLAG_SIZE 0x0002
|
||||
#define RENDER_FLAG_ROTATION 0x0004
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A super Sprite class for in-game entities. Extra functions are added
|
||||
/// in addition to a normal Sprite for easier control of in-game
|
||||
/// activities.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGameObject: public JSprite
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param tex - Texture for first frame. NULL for no starting frame.
|
||||
/// @param x - X position of texture for the frame.
|
||||
/// @param y - Y position of texture for the frame.
|
||||
/// @param width - Width of the frame.
|
||||
/// @param height - Height of the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGameObject(JTexture *tex, float x, float y, float width, float height);
|
||||
|
||||
virtual ~JGameObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update function.
|
||||
///
|
||||
/// @param dt - Delta time since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Function to handle collision.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void OnCollide();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set bounding box for collision detection. All the following collision
|
||||
/// detections will be done using bounding box.
|
||||
///
|
||||
/// @param x - X position of the bounding box (relative to this sprite).
|
||||
/// @param y - Y position of the bounding box (relative to this sprite).
|
||||
/// @param width - Width of the bounding box.
|
||||
/// @param height - Height of the bounding box.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBBox(float x, float y, float width, float height);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get bounding box relative to screen position.
|
||||
///
|
||||
/// @param x - X of screen position.
|
||||
/// @param y - Y of screen position.
|
||||
///
|
||||
/// @return xNow - X position of the bounding box (relative to screen).
|
||||
/// @return yNow - Y position of the bounding box (relative to screen).
|
||||
/// @return width - Width of the bounding box.
|
||||
/// @return height - Height of the bounding box.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetBBox(float x, float y, float* xNow, float* yNow, float* width, float *height);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set up a circle for collision detection. All the following collision
|
||||
/// detections will be done using circle to circle collision detection.
|
||||
///
|
||||
/// @param cx - X of the circle center.
|
||||
/// @param cy - Y of the circle center.
|
||||
/// @param radius - Radius of the circle.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCollisionCircle(float cx, float cy, float radius);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check for collision. Either bounding box or circle to circle
|
||||
/// collision detection will be used depending on which one is setup last.
|
||||
///
|
||||
/// @param target - Target to check for collision.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Collide(JGameObject *target);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set object that has collided with this object.
|
||||
///
|
||||
/// @param target - Object that has collided with this object.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCollisionTarget(JGameObject *target);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get object that has collided with this object.
|
||||
///
|
||||
/// @return Object that has collided with this object.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGameObject *GetCollisionTarget();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set damage point of this object.
|
||||
///
|
||||
/// @param pt - Damage point.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHitPoint(int pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get damage point of this object.
|
||||
///
|
||||
/// @return Damage point.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetHitPoint();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blood of this object.
|
||||
///
|
||||
/// @param pt - Blood value.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBlood(int pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get blood of this object.
|
||||
///
|
||||
/// @return Blood value.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetBlood();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable alpha animation during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of changing the alpha value.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableAlpha(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable scaling during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of changing the scaling value.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableScaling(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable rotation during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of rotation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableRotation(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set rendering flags.
|
||||
///
|
||||
/// @param flags - Rendering flags encoded in bits.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetRenderFlags(int flags);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start flashing during render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartFlashing();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start flashing during render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopFlashing();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if object is flashing.
|
||||
///
|
||||
/// @return Flashing status.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsFlashing();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
u32 mRenderFlags;
|
||||
|
||||
|
||||
bool mUseBoundingBox;
|
||||
|
||||
float mBBoxX;
|
||||
float mBBoxY;
|
||||
float mBBoxWidth;
|
||||
float mBBoxHeight;
|
||||
|
||||
float mCenterX;
|
||||
float mCenterY;
|
||||
float mRadius;
|
||||
|
||||
bool mDoAlpha;
|
||||
float mAlphaDelta;
|
||||
bool mDoScaling;
|
||||
float mScaleDelta;
|
||||
bool mDoRotation;
|
||||
float mRotationDelta;
|
||||
|
||||
bool mFlashing;
|
||||
float mFlashTimer;
|
||||
int mFlashCounter;
|
||||
|
||||
|
||||
protected:
|
||||
JGameObject *mCollisionTarget;
|
||||
bool mCollided;
|
||||
|
||||
int mHitPoint;
|
||||
int mBlood;
|
||||
int mOriginalBlood;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JGAME_OBJECT_H_
|
||||
#define _JGAME_OBJECT_H_
|
||||
|
||||
#include "JTypes.h"
|
||||
#include "JRenderer.h"
|
||||
#include "JSprite.h"
|
||||
|
||||
|
||||
#define FLASH_TIME 0.10f
|
||||
#define FLASHING_COUNT 6
|
||||
|
||||
#define RENDER_FLAG_ANGLE 0x0001
|
||||
#define RENDER_FLAG_SIZE 0x0002
|
||||
#define RENDER_FLAG_ROTATION 0x0004
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// A super Sprite class for in-game entities. Extra functions are added
|
||||
/// in addition to a normal Sprite for easier control of in-game
|
||||
/// activities.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JGameObject: public JSprite
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param tex - Texture for first frame. NULL for no starting frame.
|
||||
/// @param x - X position of texture for the frame.
|
||||
/// @param y - Y position of texture for the frame.
|
||||
/// @param width - Width of the frame.
|
||||
/// @param height - Height of the frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGameObject(JTexture *tex, float x, float y, float width, float height);
|
||||
|
||||
virtual ~JGameObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update function.
|
||||
///
|
||||
/// @param dt - Delta time since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render current frame.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Function to handle collision.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void OnCollide();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set bounding box for collision detection. All the following collision
|
||||
/// detections will be done using bounding box.
|
||||
///
|
||||
/// @param x - X position of the bounding box (relative to this sprite).
|
||||
/// @param y - Y position of the bounding box (relative to this sprite).
|
||||
/// @param width - Width of the bounding box.
|
||||
/// @param height - Height of the bounding box.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBBox(float x, float y, float width, float height);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get bounding box relative to screen position.
|
||||
///
|
||||
/// @param x - X of screen position.
|
||||
/// @param y - Y of screen position.
|
||||
///
|
||||
/// @return xNow - X position of the bounding box (relative to screen).
|
||||
/// @return yNow - Y position of the bounding box (relative to screen).
|
||||
/// @return width - Width of the bounding box.
|
||||
/// @return height - Height of the bounding box.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetBBox(float x, float y, float* xNow, float* yNow, float* width, float *height);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set up a circle for collision detection. All the following collision
|
||||
/// detections will be done using circle to circle collision detection.
|
||||
///
|
||||
/// @param cx - X of the circle center.
|
||||
/// @param cy - Y of the circle center.
|
||||
/// @param radius - Radius of the circle.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCollisionCircle(float cx, float cy, float radius);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check for collision. Either bounding box or circle to circle
|
||||
/// collision detection will be used depending on which one is setup last.
|
||||
///
|
||||
/// @param target - Target to check for collision.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Collide(JGameObject *target);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set object that has collided with this object.
|
||||
///
|
||||
/// @param target - Object that has collided with this object.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetCollisionTarget(JGameObject *target);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get object that has collided with this object.
|
||||
///
|
||||
/// @return Object that has collided with this object.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JGameObject *GetCollisionTarget();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set damage point of this object.
|
||||
///
|
||||
/// @param pt - Damage point.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetHitPoint(int pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get damage point of this object.
|
||||
///
|
||||
/// @return Damage point.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetHitPoint();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blood of this object.
|
||||
///
|
||||
/// @param pt - Blood value.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBlood(int pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get blood of this object.
|
||||
///
|
||||
/// @return Blood value.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetBlood();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable alpha animation during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of changing the alpha value.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableAlpha(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable scaling during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of changing the scaling value.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableScaling(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Enable rotation during update.
|
||||
///
|
||||
/// @param flag - Enable flag.
|
||||
/// @param delta - Rate of rotation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EnableRotation(bool flag, float delta=0.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set rendering flags.
|
||||
///
|
||||
/// @param flags - Rendering flags encoded in bits.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetRenderFlags(int flags);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start flashing during render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartFlashing();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start flashing during render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopFlashing();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if object is flashing.
|
||||
///
|
||||
/// @return Flashing status.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsFlashing();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
u32 mRenderFlags;
|
||||
|
||||
|
||||
bool mUseBoundingBox;
|
||||
|
||||
float mBBoxX;
|
||||
float mBBoxY;
|
||||
float mBBoxWidth;
|
||||
float mBBoxHeight;
|
||||
|
||||
float mCenterX;
|
||||
float mCenterY;
|
||||
float mRadius;
|
||||
|
||||
bool mDoAlpha;
|
||||
float mAlphaDelta;
|
||||
bool mDoScaling;
|
||||
float mScaleDelta;
|
||||
bool mDoRotation;
|
||||
float mRotationDelta;
|
||||
|
||||
bool mFlashing;
|
||||
float mFlashTimer;
|
||||
int mFlashCounter;
|
||||
|
||||
|
||||
protected:
|
||||
JGameObject *mCollisionTarget;
|
||||
bool mCollided;
|
||||
|
||||
int mHitPoint;
|
||||
int mBlood;
|
||||
int mOriginalBlood;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,187 +1,187 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 JLBF_H
|
||||
#define JLBF_H
|
||||
|
||||
#define PRINTF_BUFFER_SIZE 256
|
||||
#define MAX_CHAR 256
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include <string>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// Each font contains 2 sets of characters ASCII code (32-159).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JLBFont
|
||||
{
|
||||
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);
|
||||
|
||||
~JLBFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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, float leftOffset = 0, float width = 0);
|
||||
void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// There are usually 2 sets of characters in the font image. The first set
|
||||
/// 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);
|
||||
|
||||
|
||||
private:
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
JTexture* mTexture;
|
||||
JQuad* mQuad;
|
||||
|
||||
float mXPos[MAX_CHAR];
|
||||
float mYPos[MAX_CHAR];
|
||||
float mCharWidth[MAX_CHAR];
|
||||
|
||||
float mHeight;
|
||||
float mScale;
|
||||
float mRotation;
|
||||
float mTracking;
|
||||
float mSpacing;
|
||||
|
||||
PIXEL_TYPE mColor;
|
||||
int mBlend;
|
||||
|
||||
int mBase;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 JLBF_H
|
||||
#define JLBF_H
|
||||
|
||||
#define PRINTF_BUFFER_SIZE 256
|
||||
#define MAX_CHAR 256
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include <string>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// Each font contains 2 sets of characters ASCII code (32-159).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JLBFont
|
||||
{
|
||||
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);
|
||||
|
||||
~JLBFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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, float leftOffset = 0, float width = 0);
|
||||
void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// There are usually 2 sets of characters in the font image. The first set
|
||||
/// 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);
|
||||
|
||||
|
||||
private:
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
JTexture* mTexture;
|
||||
JQuad* mQuad;
|
||||
|
||||
float mXPos[MAX_CHAR];
|
||||
float mYPos[MAX_CHAR];
|
||||
float mCharWidth[MAX_CHAR];
|
||||
|
||||
float mHeight;
|
||||
float mScale;
|
||||
float mRotation;
|
||||
float mTracking;
|
||||
float mSpacing;
|
||||
|
||||
PIXEL_TYPE mColor;
|
||||
int mBlend;
|
||||
|
||||
int mBase;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,255 +1,255 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _MD2MODEL_H
|
||||
#define _MD2MODEL_H
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspgum.h>
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
#include "Vector3D.h"
|
||||
|
||||
|
||||
#define SMALLEST_FP 0.000001f
|
||||
|
||||
#define MAX_FRAMES 512
|
||||
#define MAX_ANIMATION 16
|
||||
|
||||
//#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
//#pragma pack(pop)
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
enum MD2AnimationStates
|
||||
{
|
||||
STATE_IDLE,
|
||||
STATE_RUNNING,
|
||||
STATE_SHOT_NOT_FALLING_DOWN,
|
||||
STATE_SHOT_IN_SHOULDER,
|
||||
STATE_JUMP,
|
||||
STATE_IDLE2,
|
||||
STATE_SHOT_FALLING_DOWN,
|
||||
STATE_IDLE3,
|
||||
STATE_IDLE4,
|
||||
STATE_CROUCHING,
|
||||
STATE_CROUCHING_CRAWL,
|
||||
STATE_IDLE_CROUCHING,
|
||||
STATE_KNEELING_DYING,
|
||||
STATE_FALLING_BACK_DYING,
|
||||
STATE_FALING_FORWARD_DYING,
|
||||
STATE_FALLING_BACK_SLOWLY_DYING
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
class MD2Animation
|
||||
{
|
||||
public:
|
||||
int mStartFrame;
|
||||
int mEndFrame;
|
||||
|
||||
MD2Animation(int start, int end);
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// texture coordinate
|
||||
typedef struct
|
||||
{
|
||||
float s;
|
||||
float t;
|
||||
} texCoord_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// texture coordinate index
|
||||
typedef struct
|
||||
{
|
||||
short s;
|
||||
short t;
|
||||
} stIndex_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// info for a single frame point
|
||||
typedef struct
|
||||
{
|
||||
unsigned char v[3];
|
||||
unsigned char normalIndex; // not used
|
||||
} framePoint_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// information for a single frame
|
||||
typedef struct
|
||||
{
|
||||
float scale[3];
|
||||
float translate[3];
|
||||
char name[16];
|
||||
framePoint_t fp[1];
|
||||
} frame_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// data for a single triangle
|
||||
typedef struct
|
||||
{
|
||||
unsigned short meshIndex[3]; // vertex indices
|
||||
unsigned short stIndex[3]; // texture coordinate indices
|
||||
} mesh_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// the model data
|
||||
typedef struct
|
||||
{
|
||||
int numFrames; // number of frames
|
||||
int numPoints; // number of points
|
||||
int numTriangles; // number of triangles
|
||||
int numST; // number of skins
|
||||
int frameSize; // size of each frame in bytes
|
||||
int texWidth, texHeight; // texture width, height
|
||||
int currentFrame; // current frame # in animation
|
||||
int nextFrame; // next frame # in animation
|
||||
float interpol; // percent through current frame
|
||||
mesh_t *triIndex; // triangle list
|
||||
texCoord_t *st; // texture coordinate list
|
||||
Vector3D *pointList; // vertex list
|
||||
JTexture *modelTex; // texture
|
||||
} modelData_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
int ident; // identifies as MD2 file "IDP2"
|
||||
int version; //
|
||||
int skinwidth; // width of texture
|
||||
int skinheight; // height of texture
|
||||
int framesize; // number of bytes per frame
|
||||
int numSkins; // number of textures
|
||||
int numXYZ; // number of points
|
||||
int numST; // number of texture
|
||||
int numTris; // number of triangles
|
||||
int numGLcmds;
|
||||
int numFrames; // total number of frames
|
||||
int offsetSkins; // offset to skin names (64 bytes each)
|
||||
int offsetST; // offset of texture s-t values
|
||||
int offsetTris; // offset of triangle mesh
|
||||
int offsetFrames; // offset of frame data (points)
|
||||
int offsetGLcmds; // type of OpenGL commands to use
|
||||
int offsetEnd; // end of file
|
||||
} modelHeader_t;
|
||||
|
||||
|
||||
class JRenderer;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Helper class to display Quake 2 MD2 model.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JMD2Model
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JMD2Model();
|
||||
|
||||
~JMD2Model();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set model state.
|
||||
///
|
||||
/// @param newState - Model state.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetState(int newState);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load MD2 model.
|
||||
///
|
||||
/// @param filename - Name of MD2 file.
|
||||
/// @param texturenName - Name of texture.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(char *filename, char *textureName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render a single frame of the model.
|
||||
///
|
||||
/// @param frameNum - Frame to render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(int frameNum);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update animation.
|
||||
///
|
||||
/// @param dt - Time elpased since last update (in seconds).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set speed of animation.
|
||||
///
|
||||
/// @param speed - Speed of animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAnimationSpeed(float speed);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the model.
|
||||
///
|
||||
/// @param percent - Interpolating percentage.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
modelData_t *mModel;
|
||||
|
||||
void CheckNextState();
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
void CalculateNormal(float *p1, float *p2, float *p3);
|
||||
#else
|
||||
void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3);
|
||||
#endif
|
||||
|
||||
MD2Animation **mAnimations;
|
||||
int mState;
|
||||
int mNextState;
|
||||
|
||||
float mAnimationSpeed;
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _MD2MODEL_H
|
||||
#define _MD2MODEL_H
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspgum.h>
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
#include "Vector3D.h"
|
||||
|
||||
|
||||
#define SMALLEST_FP 0.000001f
|
||||
|
||||
#define MAX_FRAMES 512
|
||||
#define MAX_ANIMATION 16
|
||||
|
||||
//#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
//#pragma pack(pop)
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
enum MD2AnimationStates
|
||||
{
|
||||
STATE_IDLE,
|
||||
STATE_RUNNING,
|
||||
STATE_SHOT_NOT_FALLING_DOWN,
|
||||
STATE_SHOT_IN_SHOULDER,
|
||||
STATE_JUMP,
|
||||
STATE_IDLE2,
|
||||
STATE_SHOT_FALLING_DOWN,
|
||||
STATE_IDLE3,
|
||||
STATE_IDLE4,
|
||||
STATE_CROUCHING,
|
||||
STATE_CROUCHING_CRAWL,
|
||||
STATE_IDLE_CROUCHING,
|
||||
STATE_KNEELING_DYING,
|
||||
STATE_FALLING_BACK_DYING,
|
||||
STATE_FALING_FORWARD_DYING,
|
||||
STATE_FALLING_BACK_SLOWLY_DYING
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
class MD2Animation
|
||||
{
|
||||
public:
|
||||
int mStartFrame;
|
||||
int mEndFrame;
|
||||
|
||||
MD2Animation(int start, int end);
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// texture coordinate
|
||||
typedef struct
|
||||
{
|
||||
float s;
|
||||
float t;
|
||||
} texCoord_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// texture coordinate index
|
||||
typedef struct
|
||||
{
|
||||
short s;
|
||||
short t;
|
||||
} stIndex_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// info for a single frame point
|
||||
typedef struct
|
||||
{
|
||||
unsigned char v[3];
|
||||
unsigned char normalIndex; // not used
|
||||
} framePoint_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// information for a single frame
|
||||
typedef struct
|
||||
{
|
||||
float scale[3];
|
||||
float translate[3];
|
||||
char name[16];
|
||||
framePoint_t fp[1];
|
||||
} frame_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// data for a single triangle
|
||||
typedef struct
|
||||
{
|
||||
unsigned short meshIndex[3]; // vertex indices
|
||||
unsigned short stIndex[3]; // texture coordinate indices
|
||||
} mesh_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// the model data
|
||||
typedef struct
|
||||
{
|
||||
int numFrames; // number of frames
|
||||
int numPoints; // number of points
|
||||
int numTriangles; // number of triangles
|
||||
int numST; // number of skins
|
||||
int frameSize; // size of each frame in bytes
|
||||
int texWidth, texHeight; // texture width, height
|
||||
int currentFrame; // current frame # in animation
|
||||
int nextFrame; // next frame # in animation
|
||||
float interpol; // percent through current frame
|
||||
mesh_t *triIndex; // triangle list
|
||||
texCoord_t *st; // texture coordinate list
|
||||
Vector3D *pointList; // vertex list
|
||||
JTexture *modelTex; // texture
|
||||
} modelData_t;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
int ident; // identifies as MD2 file "IDP2"
|
||||
int version; //
|
||||
int skinwidth; // width of texture
|
||||
int skinheight; // height of texture
|
||||
int framesize; // number of bytes per frame
|
||||
int numSkins; // number of textures
|
||||
int numXYZ; // number of points
|
||||
int numST; // number of texture
|
||||
int numTris; // number of triangles
|
||||
int numGLcmds;
|
||||
int numFrames; // total number of frames
|
||||
int offsetSkins; // offset to skin names (64 bytes each)
|
||||
int offsetST; // offset of texture s-t values
|
||||
int offsetTris; // offset of triangle mesh
|
||||
int offsetFrames; // offset of frame data (points)
|
||||
int offsetGLcmds; // type of OpenGL commands to use
|
||||
int offsetEnd; // end of file
|
||||
} modelHeader_t;
|
||||
|
||||
|
||||
class JRenderer;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Helper class to display Quake 2 MD2 model.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JMD2Model
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JMD2Model();
|
||||
|
||||
~JMD2Model();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set model state.
|
||||
///
|
||||
/// @param newState - Model state.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetState(int newState);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load MD2 model.
|
||||
///
|
||||
/// @param filename - Name of MD2 file.
|
||||
/// @param texturenName - Name of texture.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(char *filename, char *textureName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render a single frame of the model.
|
||||
///
|
||||
/// @param frameNum - Frame to render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(int frameNum);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update animation.
|
||||
///
|
||||
/// @param dt - Time elpased since last update (in seconds).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set speed of animation.
|
||||
///
|
||||
/// @param speed - Speed of animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAnimationSpeed(float speed);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the model.
|
||||
///
|
||||
/// @param percent - Interpolating percentage.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
modelData_t *mModel;
|
||||
|
||||
void CheckNextState();
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
void CalculateNormal(float *p1, float *p2, float *p3);
|
||||
#else
|
||||
void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3);
|
||||
#endif
|
||||
|
||||
MD2Animation **mAnimations;
|
||||
int mState;
|
||||
int mNextState;
|
||||
|
||||
float mAnimationSpeed;
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,82 +1,82 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _OBJMODEL_H
|
||||
#define _OBJMODEL_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspgum.h>
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
#include "Vector3D.h"
|
||||
|
||||
class JTexture;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Helper class to display Wavefront OBJ model.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JOBJModel
|
||||
{
|
||||
|
||||
struct Face
|
||||
{
|
||||
int mVertCount;
|
||||
int mVertIdx[4];
|
||||
int mTexIdx[4];
|
||||
int mNormalIdx[4];
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JOBJModel();
|
||||
|
||||
~JOBJModel();
|
||||
|
||||
int ReadLine(char *output, const char *buffer, int start, int size);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load OBJ model.
|
||||
///
|
||||
/// @param modelName - Name of OBJ file.
|
||||
/// @param texturenName - Name of texture.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *modelName, const char *textureName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the model to screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
private:
|
||||
int mPolycount;
|
||||
Vertex3D* mPolygons;
|
||||
JTexture* mTexture;
|
||||
};
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _OBJMODEL_H
|
||||
#define _OBJMODEL_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspgum.h>
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
#include "Vector3D.h"
|
||||
|
||||
class JTexture;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Helper class to display Wavefront OBJ model.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JOBJModel
|
||||
{
|
||||
|
||||
struct Face
|
||||
{
|
||||
int mVertCount;
|
||||
int mVertIdx[4];
|
||||
int mTexIdx[4];
|
||||
int mNormalIdx[4];
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JOBJModel();
|
||||
|
||||
~JOBJModel();
|
||||
|
||||
int ReadLine(char *output, const char *buffer, int start, int size);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load OBJ model.
|
||||
///
|
||||
/// @param modelName - Name of OBJ file.
|
||||
/// @param texturenName - Name of texture.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *modelName, const char *textureName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the model to screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
private:
|
||||
int mPolycount;
|
||||
Vertex3D* mPolygons;
|
||||
JTexture* mTexture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_H__
|
||||
#define __PARTICLE_H__
|
||||
|
||||
#include "JApp.h"
|
||||
#include "JRenderer.h"
|
||||
#include "Vector2D.h"
|
||||
|
||||
|
||||
#define MAX_KEYS 8
|
||||
|
||||
class JParticleData
|
||||
{
|
||||
public:
|
||||
JParticleData();
|
||||
void Init();
|
||||
void Clear();
|
||||
void AddKey(float keyTime, float keyValue);
|
||||
void Update(float dt);
|
||||
void SetScale(float scale);
|
||||
|
||||
float mCurr;
|
||||
float mTarget;
|
||||
float mDelta;
|
||||
float mTimer;
|
||||
int mKeyCount;
|
||||
int mKeyIndex;
|
||||
float mKeyTime[MAX_KEYS];
|
||||
float mKeyValue[MAX_KEYS];
|
||||
|
||||
float mScale;
|
||||
};
|
||||
|
||||
|
||||
enum ParticleField
|
||||
{
|
||||
FIELD_SPEED,
|
||||
FIELD_SIZE,
|
||||
FIELD_ROTATION,
|
||||
FIELD_ALPHA,
|
||||
FIELD_RED,
|
||||
FIELD_GREEN,
|
||||
FIELD_BLUE,
|
||||
FIELD_RADIAL_ACCEL,
|
||||
FIELD_TANGENTIAL_ACCEL,
|
||||
FIELD_GRAVITY,
|
||||
FIELD_COUNT
|
||||
};
|
||||
|
||||
class JParticle
|
||||
{
|
||||
public:
|
||||
|
||||
bool mActive;
|
||||
|
||||
JParticle();
|
||||
~JParticle();
|
||||
|
||||
bool Update(float dt);
|
||||
void Render();
|
||||
void Init(float lifeTime);
|
||||
|
||||
void InitPosition(float ox, float oy, float xoffset, float yoffset);
|
||||
void SetPosition(float x, float y);
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
JParticleData* GetField(int index);
|
||||
JParticleData* GetDataPtr();
|
||||
|
||||
void Move(float x, float y);
|
||||
void SetVelocity(float x, float y);
|
||||
void SetSize(float size);
|
||||
|
||||
|
||||
private:
|
||||
static JRenderer* mRenderer;
|
||||
JQuad* mQuad;
|
||||
|
||||
Vector2D mOrigin;
|
||||
Vector2D mPos;
|
||||
Vector2D mVelocity;
|
||||
|
||||
//float mSpeed;
|
||||
float mSize;
|
||||
|
||||
float mLifetime;
|
||||
|
||||
JParticleData mData[FIELD_COUNT];
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_H__
|
||||
#define __PARTICLE_H__
|
||||
|
||||
#include "JApp.h"
|
||||
#include "JRenderer.h"
|
||||
#include "Vector2D.h"
|
||||
|
||||
|
||||
#define MAX_KEYS 8
|
||||
|
||||
class JParticleData
|
||||
{
|
||||
public:
|
||||
JParticleData();
|
||||
void Init();
|
||||
void Clear();
|
||||
void AddKey(float keyTime, float keyValue);
|
||||
void Update(float dt);
|
||||
void SetScale(float scale);
|
||||
|
||||
float mCurr;
|
||||
float mTarget;
|
||||
float mDelta;
|
||||
float mTimer;
|
||||
int mKeyCount;
|
||||
int mKeyIndex;
|
||||
float mKeyTime[MAX_KEYS];
|
||||
float mKeyValue[MAX_KEYS];
|
||||
|
||||
float mScale;
|
||||
};
|
||||
|
||||
|
||||
enum ParticleField
|
||||
{
|
||||
FIELD_SPEED,
|
||||
FIELD_SIZE,
|
||||
FIELD_ROTATION,
|
||||
FIELD_ALPHA,
|
||||
FIELD_RED,
|
||||
FIELD_GREEN,
|
||||
FIELD_BLUE,
|
||||
FIELD_RADIAL_ACCEL,
|
||||
FIELD_TANGENTIAL_ACCEL,
|
||||
FIELD_GRAVITY,
|
||||
FIELD_COUNT
|
||||
};
|
||||
|
||||
class JParticle
|
||||
{
|
||||
public:
|
||||
|
||||
bool mActive;
|
||||
|
||||
JParticle();
|
||||
~JParticle();
|
||||
|
||||
bool Update(float dt);
|
||||
void Render();
|
||||
void Init(float lifeTime);
|
||||
|
||||
void InitPosition(float ox, float oy, float xoffset, float yoffset);
|
||||
void SetPosition(float x, float y);
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
JParticleData* GetField(int index);
|
||||
JParticleData* GetDataPtr();
|
||||
|
||||
void Move(float x, float y);
|
||||
void SetVelocity(float x, float y);
|
||||
void SetSize(float size);
|
||||
|
||||
|
||||
private:
|
||||
static JRenderer* mRenderer;
|
||||
JQuad* mQuad;
|
||||
|
||||
Vector2D mOrigin;
|
||||
Vector2D mPos;
|
||||
Vector2D mVelocity;
|
||||
|
||||
//float mSpeed;
|
||||
float mSize;
|
||||
|
||||
float mLifetime;
|
||||
|
||||
JParticleData mData[FIELD_COUNT];
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,146 +1,146 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_EFFECT_H__
|
||||
#define __PARTICLE_EFFECT_H__
|
||||
|
||||
#define MAX_EMITTER 5
|
||||
|
||||
class JParticleSystem;
|
||||
class JParticleEmitter;
|
||||
class JResourceManager;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Particle effect. Each particle effect can contain one or more emitters.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleEffect
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param mgr - Resource manager for retrieving image quads for the particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleEffect(JResourceManager* mgr);
|
||||
|
||||
~JParticleEffect();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load effect from file.
|
||||
///
|
||||
/// @param filename - Name of effect file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char* filename);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update particle effect.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render particle effect.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the particle effect is finished.
|
||||
///
|
||||
/// @return True if done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Done();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set particle system.
|
||||
///
|
||||
/// @param particleSys - Particle system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetParticleSystem(JParticleSystem* particleSys);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get particle system.
|
||||
///
|
||||
/// @return Particle system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleSystem* GetParticleSystem();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the effect. New particles will be emitted from the
|
||||
/// new position but the existing active particles will not be affected.
|
||||
///
|
||||
/// @param x - X screen position.
|
||||
/// @param y - Y screen position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get X position.
|
||||
///
|
||||
/// @return X position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetX();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get Y position.
|
||||
///
|
||||
/// @return Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetY();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Move the particle effect over to a new position. All the existing
|
||||
/// particles will be moved relatively.
|
||||
///
|
||||
/// @param X - X screen position.
|
||||
/// @param y - Y screen position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MoveTo(float x, float y);
|
||||
|
||||
protected:
|
||||
JParticleSystem* mParticleSystem;
|
||||
JResourceManager* mResourceManager;
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
int mEmitterCount;
|
||||
JParticleEmitter* mParticleEmitters[MAX_EMITTER];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_EFFECT_H__
|
||||
#define __PARTICLE_EFFECT_H__
|
||||
|
||||
#define MAX_EMITTER 5
|
||||
|
||||
class JParticleSystem;
|
||||
class JParticleEmitter;
|
||||
class JResourceManager;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Particle effect. Each particle effect can contain one or more emitters.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleEffect
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param mgr - Resource manager for retrieving image quads for the particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleEffect(JResourceManager* mgr);
|
||||
|
||||
~JParticleEffect();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load effect from file.
|
||||
///
|
||||
/// @param filename - Name of effect file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char* filename);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update particle effect.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render particle effect.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the particle effect is finished.
|
||||
///
|
||||
/// @return True if done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Done();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set particle system.
|
||||
///
|
||||
/// @param particleSys - Particle system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetParticleSystem(JParticleSystem* particleSys);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get particle system.
|
||||
///
|
||||
/// @return Particle system.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleSystem* GetParticleSystem();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set position of the effect. New particles will be emitted from the
|
||||
/// new position but the existing active particles will not be affected.
|
||||
///
|
||||
/// @param x - X screen position.
|
||||
/// @param y - Y screen position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get X position.
|
||||
///
|
||||
/// @return X position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetX();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get Y position.
|
||||
///
|
||||
/// @return Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetY();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Move the particle effect over to a new position. All the existing
|
||||
/// particles will be moved relatively.
|
||||
///
|
||||
/// @param X - X screen position.
|
||||
/// @param y - Y screen position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MoveTo(float x, float y);
|
||||
|
||||
protected:
|
||||
JParticleSystem* mParticleSystem;
|
||||
JResourceManager* mResourceManager;
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
int mEmitterCount;
|
||||
JParticleEmitter* mParticleEmitters[MAX_EMITTER];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,221 +1,221 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_EMITTER_H__
|
||||
#define __PARTICLE_EMITTER_H__
|
||||
|
||||
#define INIT_PARTICLE_COUNT 32
|
||||
#define MAX_PARTICLE_COUNT 256
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class JParticleEffect;
|
||||
class JParticle;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Particle emitter. This is where the particles actually generated.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleEmitter
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param parent - Particle effect that contains this emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleEmitter(JParticleEffect* parent);
|
||||
|
||||
~JParticleEmitter();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blending mode for rendering.
|
||||
///
|
||||
/// @param srcBlend - Blending mode for source.
|
||||
/// @param destBlend - Blending mode for destination.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBlending(int srcBlend, int destBlend);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set image quad for particles.
|
||||
///
|
||||
/// @param quad - Image quad.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start emitting particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Restart the emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ReStart();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update the emitter.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render particles emitted by this emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the emitter is done.
|
||||
///
|
||||
/// @return True if the emitter is done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Done();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set active flag.
|
||||
///
|
||||
/// @param flag - Active flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetActive(bool flag);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Move all particles to a distance.
|
||||
///
|
||||
/// @param x - X distance to move.
|
||||
/// @param y - Y distance to move
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MoveAllParticles(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Emit certain amount of particles.
|
||||
///
|
||||
/// @param count - Number of particles to emit.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EmitParticles(int count);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get idle particle to reuse.
|
||||
///
|
||||
/// @return Idel particle to use.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticle* GetIdleParticle();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put a particle in action.
|
||||
///
|
||||
/// @param par - Particle to start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartParticle(JParticle *par);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set the maximum number of particles that this emitter can emit.
|
||||
///
|
||||
/// @param count - Maximum number of particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetMaxParticleCount(int count);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum JParticleEmitterMode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum JParticleEmitterMode
|
||||
{
|
||||
MODE_REPEAT, ///< Emit particles and repeat when done.
|
||||
MODE_ONCE, ///< Emit once.
|
||||
MODE_NTIMES, ///< Emit N times.
|
||||
MODE_CONTINUOUS, ///< Emit particles continuously.
|
||||
MODE_COUNT
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum JParticleEmitterType
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum JParticleEmitterType
|
||||
{
|
||||
TYPE_POINT, ///< Emit from one point.
|
||||
TYPE_AREA, ///< Emit from a rectangle area.
|
||||
TYPE_HORIZONTAL, ///< Emit from a horizontal line.
|
||||
TYPE_VERTICAL, ///< Emit from a vertical line.
|
||||
TYPE_CIRCLE, ///< Emit from a circle.
|
||||
TYPE_COUNT
|
||||
};
|
||||
|
||||
protected:
|
||||
JParticleEffect* mParent;
|
||||
JQuad* mQuad;
|
||||
|
||||
public:
|
||||
int mType;
|
||||
int mId;
|
||||
|
||||
JParticleData mQuantity;
|
||||
JParticleData mData[FIELD_COUNT];
|
||||
|
||||
float mLifeBase;
|
||||
float mLifeMax;
|
||||
|
||||
float mAngleBase;
|
||||
float mAngleMax;
|
||||
|
||||
float mSpeedBase;
|
||||
float mSpeedMax;
|
||||
|
||||
float mSizeBase;
|
||||
float mSizeMax;
|
||||
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
int mQuadIndex;
|
||||
|
||||
int mEmitterMode;
|
||||
int mRepeatTimes;
|
||||
|
||||
float mLife;
|
||||
|
||||
|
||||
private:
|
||||
bool mActive;
|
||||
float mEmitTimer;
|
||||
|
||||
int mRepeatCounter;
|
||||
int mActiveParticleCount;
|
||||
|
||||
int mSrcBlending;
|
||||
int mDestBlending;
|
||||
int mMaxParticleCount;
|
||||
|
||||
vector<JParticle*> mParticles;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_EMITTER_H__
|
||||
#define __PARTICLE_EMITTER_H__
|
||||
|
||||
#define INIT_PARTICLE_COUNT 32
|
||||
#define MAX_PARTICLE_COUNT 256
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class JParticleEffect;
|
||||
class JParticle;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Particle emitter. This is where the particles actually generated.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleEmitter
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param parent - Particle effect that contains this emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleEmitter(JParticleEffect* parent);
|
||||
|
||||
~JParticleEmitter();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set blending mode for rendering.
|
||||
///
|
||||
/// @param srcBlend - Blending mode for source.
|
||||
/// @param destBlend - Blending mode for destination.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetBlending(int srcBlend, int destBlend);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set image quad for particles.
|
||||
///
|
||||
/// @param quad - Image quad.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetQuad(JQuad *quad);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start emitting particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Start();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Restart the emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ReStart();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update the emitter.
|
||||
///
|
||||
/// @param dt - Time elapsed since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render particles emitted by this emitter.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the emitter is done.
|
||||
///
|
||||
/// @return True if the emitter is done.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Done();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set active flag.
|
||||
///
|
||||
/// @param flag - Active flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetActive(bool flag);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Move all particles to a distance.
|
||||
///
|
||||
/// @param x - X distance to move.
|
||||
/// @param y - Y distance to move
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MoveAllParticles(float x, float y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Emit certain amount of particles.
|
||||
///
|
||||
/// @param count - Number of particles to emit.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EmitParticles(int count);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get idle particle to reuse.
|
||||
///
|
||||
/// @return Idel particle to use.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticle* GetIdleParticle();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put a particle in action.
|
||||
///
|
||||
/// @param par - Particle to start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartParticle(JParticle *par);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set the maximum number of particles that this emitter can emit.
|
||||
///
|
||||
/// @param count - Maximum number of particles.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetMaxParticleCount(int count);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum JParticleEmitterMode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum JParticleEmitterMode
|
||||
{
|
||||
MODE_REPEAT, ///< Emit particles and repeat when done.
|
||||
MODE_ONCE, ///< Emit once.
|
||||
MODE_NTIMES, ///< Emit N times.
|
||||
MODE_CONTINUOUS, ///< Emit particles continuously.
|
||||
MODE_COUNT
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum JParticleEmitterType
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum JParticleEmitterType
|
||||
{
|
||||
TYPE_POINT, ///< Emit from one point.
|
||||
TYPE_AREA, ///< Emit from a rectangle area.
|
||||
TYPE_HORIZONTAL, ///< Emit from a horizontal line.
|
||||
TYPE_VERTICAL, ///< Emit from a vertical line.
|
||||
TYPE_CIRCLE, ///< Emit from a circle.
|
||||
TYPE_COUNT
|
||||
};
|
||||
|
||||
protected:
|
||||
JParticleEffect* mParent;
|
||||
JQuad* mQuad;
|
||||
|
||||
public:
|
||||
int mType;
|
||||
int mId;
|
||||
|
||||
JParticleData mQuantity;
|
||||
JParticleData mData[FIELD_COUNT];
|
||||
|
||||
float mLifeBase;
|
||||
float mLifeMax;
|
||||
|
||||
float mAngleBase;
|
||||
float mAngleMax;
|
||||
|
||||
float mSpeedBase;
|
||||
float mSpeedMax;
|
||||
|
||||
float mSizeBase;
|
||||
float mSizeMax;
|
||||
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
int mQuadIndex;
|
||||
|
||||
int mEmitterMode;
|
||||
int mRepeatTimes;
|
||||
|
||||
float mLife;
|
||||
|
||||
|
||||
private:
|
||||
bool mActive;
|
||||
float mEmitTimer;
|
||||
|
||||
int mRepeatCounter;
|
||||
int mActiveParticleCount;
|
||||
|
||||
int mSrcBlending;
|
||||
int mDestBlending;
|
||||
int mMaxParticleCount;
|
||||
|
||||
vector<JParticle*> mParticles;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,114 +1,114 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_SYSTEM_H__
|
||||
#define __PARTICLE_SYSTEM_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
|
||||
#include "JParticle.h"
|
||||
|
||||
|
||||
class JParticleEffect;
|
||||
class JParticleEmitter;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// The particle system of JGE++ is built on a key frame concept with
|
||||
/// multiple emitters for each effect. It's inspired by the particle system
|
||||
/// of Torque Game Builder. At each key frame, you can specify the value
|
||||
/// of the changeable states of the particle. This gives you lots of
|
||||
/// control over the particles and making it possible to create
|
||||
/// almost all of the spectacular effects out of your imagination.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleSystem
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleSystem();
|
||||
|
||||
~JParticleSystem();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update all active effects.
|
||||
///
|
||||
/// @param dt - Delta time since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render all active effects.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start an effect.
|
||||
///
|
||||
/// @param effect - Effect to start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartEffect(JParticleEffect* effect);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop all effects.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopAllEffects();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete all effects from memory.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ClearAll();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the particle system is active or not.
|
||||
///
|
||||
/// @return True if active.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsActive();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set active flag.
|
||||
///
|
||||
/// @param flag - Active flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetActive(bool flag);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool mActive;
|
||||
|
||||
list<JParticleEffect*> mEffects;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 __PARTICLE_SYSTEM_H__
|
||||
#define __PARTICLE_SYSTEM_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "JGE.h"
|
||||
|
||||
#include "JParticle.h"
|
||||
|
||||
|
||||
class JParticleEffect;
|
||||
class JParticleEmitter;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// The particle system of JGE++ is built on a key frame concept with
|
||||
/// multiple emitters for each effect. It's inspired by the particle system
|
||||
/// of Torque Game Builder. At each key frame, you can specify the value
|
||||
/// of the changeable states of the particle. This gives you lots of
|
||||
/// control over the particles and making it possible to create
|
||||
/// almost all of the spectacular effects out of your imagination.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JParticleSystem
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JParticleSystem();
|
||||
|
||||
~JParticleSystem();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Update all active effects.
|
||||
///
|
||||
/// @param dt - Delta time since last update (in second).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update(float dt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render all active effects.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Start an effect.
|
||||
///
|
||||
/// @param effect - Effect to start playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartEffect(JParticleEffect* effect);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop all effects.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopAllEffects();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete all effects from memory.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ClearAll();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Check if the particle system is active or not.
|
||||
///
|
||||
/// @return True if active.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsActive();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set active flag.
|
||||
///
|
||||
/// @param flag - Active flag.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetActive(bool flag);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool mActive;
|
||||
|
||||
list<JParticleEffect*> mEffects;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,30 +1,30 @@
|
||||
#ifndef _JSOCKET_H_
|
||||
#define _JSOCKET_H_
|
||||
|
||||
#include <queue>
|
||||
using namespace std;
|
||||
|
||||
//TODO config ?
|
||||
#define SERVER_PORT 20666
|
||||
|
||||
class JSocket{
|
||||
public:
|
||||
queue<char> received_data;
|
||||
queue<char> tosend_data;
|
||||
static JSocket * mInstance;
|
||||
int start_server(const char *szIpAddr);
|
||||
int start_client(const char *szIpAddr);
|
||||
|
||||
JSocket();
|
||||
~JSocket();
|
||||
static int connected;
|
||||
private:
|
||||
void init();
|
||||
void readWrite(int sock);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#else
|
||||
int make_socket(uint16_t port);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _JSOCKET_H_
|
||||
#define _JSOCKET_H_
|
||||
|
||||
#include <queue>
|
||||
using namespace std;
|
||||
|
||||
//TODO config ?
|
||||
#define SERVER_PORT 20666
|
||||
|
||||
class JSocket{
|
||||
public:
|
||||
queue<char> received_data;
|
||||
queue<char> tosend_data;
|
||||
static JSocket * mInstance;
|
||||
int start_server(const char *szIpAddr);
|
||||
int start_client(const char *szIpAddr);
|
||||
|
||||
JSocket();
|
||||
~JSocket();
|
||||
static int connected;
|
||||
private:
|
||||
void init();
|
||||
void readWrite(int sock);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#else
|
||||
int make_socket(uint16_t port);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,167 +1,167 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JSPLINE_H
|
||||
#define _JSPLINE_H
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MID_POINT_THRESHOLD 1.0f
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Position of a single dot on screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param _x - X position.
|
||||
/// @param _y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Point(float _x, float _y) { x = _x; y = _y; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor, set position to default (0.0f, 0.0f)
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Point() { x = 0.0f; y = 0.0f; }
|
||||
|
||||
float x; ///< X position.
|
||||
float y; ///< Y position.
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Catmull Rom spline.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSpline
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JSpline();
|
||||
~JSpline();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load spline from a file.
|
||||
///
|
||||
/// Here is a sample spline definition file:
|
||||
///
|
||||
/// @code
|
||||
/// <?xml version="1.0" standalone="no" ?>
|
||||
/// <path>
|
||||
/// <contro_point x="89" y="270" />
|
||||
/// <contro_point x="113" y="154" />
|
||||
/// <contro_point x="227" y="94" />
|
||||
/// <contro_point x="347" y="154" />
|
||||
/// <contro_point x="367" y="278" />
|
||||
/// </path>
|
||||
/// @endcode
|
||||
///
|
||||
/// @param filename - Name of spline definition file.
|
||||
/// @param xscale - Scaling factor for X of all control points.
|
||||
/// @param yscale - Scaling factor for Y of all control points.
|
||||
///
|
||||
/// @return True if loaded.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *filename, float xscale=1.0f, float yscale=1.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Add a control point to the spline.
|
||||
///
|
||||
/// @param pt - Control point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddControlPoint(const Point &pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a control point of the spline.
|
||||
///
|
||||
/// @param index - Control point index.
|
||||
///
|
||||
/// @return Control point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetControlPoint(Point &point, int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Work out all pixels of the spline.
|
||||
///
|
||||
/// @note Have to call this function before calling GetPixel, GetPixelCount
|
||||
/// and Render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GeneratePixels();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a point between 2nd and 3rd control point.
|
||||
///
|
||||
/// @param t - Fraction of the curve between 2nd and 3rd control point. (0.0f ~ 1.0f)
|
||||
/// @param p0 - 1st control point.
|
||||
/// @param p1 - 2nd control point.
|
||||
/// @param p2 - 3rd control point.
|
||||
/// @param p3 - 4th control point.
|
||||
///
|
||||
/// @return Position of the desire point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PointOnCurve(Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a number of pixels for this spline.
|
||||
///
|
||||
/// @return Number of pixels for this spline.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetPixelCount();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a pixel on the spline.
|
||||
///
|
||||
/// @param index - Pixel index.
|
||||
///
|
||||
/// @return Position of the desire point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetPixel(Point &point, int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the spline to screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y, PIXEL_TYPE color=ARGB(255,255,255,255), PIXEL_TYPE controlColor=ARGB(192,0,192,0));
|
||||
|
||||
private:
|
||||
|
||||
vector<Point> mMidPoints;
|
||||
vector<Point> mPixels;
|
||||
int mCount;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JSPLINE_H
|
||||
#define _JSPLINE_H
|
||||
|
||||
#include "JRenderer.h"
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MID_POINT_THRESHOLD 1.0f
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Position of a single dot on screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param _x - X position.
|
||||
/// @param _y - Y position.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Point(float _x, float _y) { x = _x; y = _y; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor, set position to default (0.0f, 0.0f)
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Point() { x = 0.0f; y = 0.0f; }
|
||||
|
||||
float x; ///< X position.
|
||||
float y; ///< Y position.
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Catmull Rom spline.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSpline
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JSpline();
|
||||
~JSpline();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load spline from a file.
|
||||
///
|
||||
/// Here is a sample spline definition file:
|
||||
///
|
||||
/// @code
|
||||
/// <?xml version="1.0" standalone="no" ?>
|
||||
/// <path>
|
||||
/// <contro_point x="89" y="270" />
|
||||
/// <contro_point x="113" y="154" />
|
||||
/// <contro_point x="227" y="94" />
|
||||
/// <contro_point x="347" y="154" />
|
||||
/// <contro_point x="367" y="278" />
|
||||
/// </path>
|
||||
/// @endcode
|
||||
///
|
||||
/// @param filename - Name of spline definition file.
|
||||
/// @param xscale - Scaling factor for X of all control points.
|
||||
/// @param yscale - Scaling factor for Y of all control points.
|
||||
///
|
||||
/// @return True if loaded.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *filename, float xscale=1.0f, float yscale=1.0f);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Add a control point to the spline.
|
||||
///
|
||||
/// @param pt - Control point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddControlPoint(const Point &pt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a control point of the spline.
|
||||
///
|
||||
/// @param index - Control point index.
|
||||
///
|
||||
/// @return Control point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetControlPoint(Point &point, int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Work out all pixels of the spline.
|
||||
///
|
||||
/// @note Have to call this function before calling GetPixel, GetPixelCount
|
||||
/// and Render.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GeneratePixels();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a point between 2nd and 3rd control point.
|
||||
///
|
||||
/// @param t - Fraction of the curve between 2nd and 3rd control point. (0.0f ~ 1.0f)
|
||||
/// @param p0 - 1st control point.
|
||||
/// @param p1 - 2nd control point.
|
||||
/// @param p2 - 3rd control point.
|
||||
/// @param p3 - 4th control point.
|
||||
///
|
||||
/// @return Position of the desire point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PointOnCurve(Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a number of pixels for this spline.
|
||||
///
|
||||
/// @return Number of pixels for this spline.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetPixelCount();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get a pixel on the spline.
|
||||
///
|
||||
/// @param index - Pixel index.
|
||||
///
|
||||
/// @return Position of the desire point.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetPixel(Point &point, int index);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render the spline to screen.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Render(float x, float y, PIXEL_TYPE color=ARGB(255,255,255,255), PIXEL_TYPE controlColor=ARGB(192,0,192,0));
|
||||
|
||||
private:
|
||||
|
||||
vector<Point> mMidPoints;
|
||||
vector<Point> mPixels;
|
||||
int mCount;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,487 +1,487 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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_
|
||||
|
||||
#if defined (WIN32) || defined(LINUX) || defined(IOS)
|
||||
#include <math.h>
|
||||
#else
|
||||
#include <fastmath.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Sprite is a container of single static image or animation frames.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSprite
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @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);
|
||||
|
||||
virtual ~JSprite();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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 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();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsAnimating();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// 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);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum ANIMATION_TYPE
|
||||
///
|
||||
/// Type of animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum ANIMATION_TYPE
|
||||
{
|
||||
ANIMATION_TYPE_LOOPING, ///< Repeat playing (Default).
|
||||
ANIMATION_TYPE_ONCE_AND_STAY, ///< Play to the end and stay at last frame
|
||||
ANIMATION_TYPE_ONCE_AND_BACK, ///< Play to end and then stay at first frame.
|
||||
ANIMATION_TYPE_ONCE_AND_GONE, ///< Play animation once only.
|
||||
ANIMATION_TYPE_PINGPONG ///< Play forward then backward and repeat.
|
||||
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
JTexture* mTex;
|
||||
vector<JQuad*> mFrames;
|
||||
float mDuration;
|
||||
float mTimer;
|
||||
int mFrameCount;
|
||||
int mCurrentFrame;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class JSpriteList
|
||||
{
|
||||
protected:
|
||||
|
||||
int mCount;
|
||||
JSprite** mList;
|
||||
//JSpriteList** mVictims;
|
||||
//JCollisionListener* mCollisionListener;
|
||||
|
||||
public:
|
||||
JSpriteList(int count);
|
||||
~JSpriteList();
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
void AddSprite(JSprite* sprite);//, JSpriteList* victim);
|
||||
|
||||
//bool CheckCollision(JSprite* sprite); // check collision against the provided list
|
||||
//void SetCollisionListener(JCollisionListener *listener);
|
||||
JSprite* Activate(float x, float y);
|
||||
void Activate(float x, float y, int index);
|
||||
|
||||
JSprite* GetSprite(int index);
|
||||
|
||||
void EnableAll(bool flag);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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_
|
||||
|
||||
#if defined (WIN32) || defined(LINUX) || defined(IOS)
|
||||
#include <math.h>
|
||||
#else
|
||||
#include <fastmath.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "JRenderer.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Sprite is a container of single static image or animation frames.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSprite
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @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);
|
||||
|
||||
virtual ~JSprite();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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 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();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsAnimating();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// 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);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum ANIMATION_TYPE
|
||||
///
|
||||
/// Type of animation.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum ANIMATION_TYPE
|
||||
{
|
||||
ANIMATION_TYPE_LOOPING, ///< Repeat playing (Default).
|
||||
ANIMATION_TYPE_ONCE_AND_STAY, ///< Play to the end and stay at last frame
|
||||
ANIMATION_TYPE_ONCE_AND_BACK, ///< Play to end and then stay at first frame.
|
||||
ANIMATION_TYPE_ONCE_AND_GONE, ///< Play animation once only.
|
||||
ANIMATION_TYPE_PINGPONG ///< Play forward then backward and repeat.
|
||||
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static JRenderer* mRenderer;
|
||||
|
||||
JTexture* mTex;
|
||||
vector<JQuad*> mFrames;
|
||||
float mDuration;
|
||||
float mTimer;
|
||||
int mFrameCount;
|
||||
int mCurrentFrame;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class JSpriteList
|
||||
{
|
||||
protected:
|
||||
|
||||
int mCount;
|
||||
JSprite** mList;
|
||||
//JSpriteList** mVictims;
|
||||
//JCollisionListener* mCollisionListener;
|
||||
|
||||
public:
|
||||
JSpriteList(int count);
|
||||
~JSpriteList();
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
void AddSprite(JSprite* sprite);//, JSpriteList* victim);
|
||||
|
||||
//bool CheckCollision(JSprite* sprite); // check collision against the provided list
|
||||
//void SetCollisionListener(JCollisionListener *listener);
|
||||
JSprite* Activate(float x, float y);
|
||||
void Activate(float x, float y, int index);
|
||||
|
||||
JSprite* GetSprite(int index);
|
||||
|
||||
void EnableAll(bool flag);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,307 +1,307 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JTTFONT_H
|
||||
#define _JTTFONT_H
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#define TTF_CACHE_SIZE 256
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// True Type font support with the help of Freetype library. JTTFont has
|
||||
/// a simple caching system so that a character which has been rendered before
|
||||
/// can be retrieved from the cache instead of drawing it again by the
|
||||
/// Freetype library. This can give you a much faster rendering speed.
|
||||
/// Also, if you only need to use a limited number of characters
|
||||
/// in your game, you can actually cache all your characters in the cache
|
||||
/// beforehand and unload the font to save memory.
|
||||
///
|
||||
/// @par For example, if you only want to use the standard ASCII characters in
|
||||
/// your game:
|
||||
///
|
||||
/// @code
|
||||
///
|
||||
/// // in Create()
|
||||
/// mTTFont = new JTTFont();
|
||||
/// mTTFont->Load("arial.ttf", 32); // size 32
|
||||
///
|
||||
/// if (mTTFont->PreCacheASCII())
|
||||
/// mTTFont->Unload();
|
||||
/// ...
|
||||
///
|
||||
/// // in Render()
|
||||
/// mTTFont->RenderString("Hello World!", 240, 80, JGETEXT_CENTER);
|
||||
///
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JTTFont
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param cacheImageSize - Size of the texture used for caching. This can
|
||||
/// be 64x64, 128x128(default), 256x256 or 512x512.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JTTFont(int cacheImageSize=CACHE_IMAGE_256x256);
|
||||
|
||||
~JTTFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum FONT_LOADING_MODE
|
||||
///
|
||||
/// Font loading options.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum FONT_LOADING_MODE
|
||||
{
|
||||
MODE_NORMAL, ///< Load only.
|
||||
MODE_PRECACHE_ASCII, ///< Load the font and cache all ASCII characters.
|
||||
MODE_PRECACHE_ASCII_EX ///< Load the font and cache all Extended ASCII characters.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum CACHE_IMAGE_SIZE
|
||||
///
|
||||
/// Size of the texture used for caching.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum CACHE_IMAGE_SIZE
|
||||
{
|
||||
CACHE_IMAGE_64x64, ///< 64x64
|
||||
CACHE_IMAGE_128x128, ///< 128x128
|
||||
CACHE_IMAGE_256x256, ///< 256x256
|
||||
CACHE_IMAGE_512x512 ///< 512x512
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set color of font.
|
||||
///
|
||||
/// @param color - Font color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set angle of the font for rendering.
|
||||
///
|
||||
/// @param angle - Angle in radians.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAngle(float angle);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set font size.
|
||||
///
|
||||
/// @param size - Font size.
|
||||
///
|
||||
/// @note Setting font size will clear the cache.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool SetSize(int size);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load font file.
|
||||
///
|
||||
/// @param filename - Name of True Type font.
|
||||
/// @param size - Initial font size. Default is 12.
|
||||
/// @param mode - Loading mode.
|
||||
///
|
||||
/// @return - True if no error.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *filename, int size=12, int mode=MODE_NORMAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Create font using font data from another JTTFont instance.
|
||||
///
|
||||
/// @param fontSource - Source of font data.
|
||||
/// @param size - Initial font size. Default is 12.
|
||||
/// @param mode - Loading mode.
|
||||
///
|
||||
/// @return - True if no error.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(JTTFont *fontSource, int size=12, int mode=MODE_NORMAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Unload font file and related Freetype objects from memory.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Unload(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render Unicode string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const u16 *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render ASCII string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const char *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render Chinese (GBK) string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const u8 *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of an Unicode string into cache
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const u16 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of an ASCII string into cache.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const char *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of a Chinese (GBK) string into cache.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const u8 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of Unicode string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const u16 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of ASCII string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const char *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of Chinese (GBK) string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const u8 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put all standard ASCII characters (0x20-0x7F) into cache.
|
||||
///
|
||||
/// @return - True if success.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PreCacheASCII();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put all ASCII characters (0x20-0xFF) into cache.
|
||||
///
|
||||
/// @return - True if success.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PreCacheExtendedASCII();
|
||||
|
||||
void SetAntialias(bool flag);
|
||||
|
||||
protected:
|
||||
FT_Library GetFontLibrary();
|
||||
FT_Byte* GetFontBits();
|
||||
int GetFontBitsSize();
|
||||
|
||||
private:
|
||||
|
||||
int RenderString(const u16 *text, float x, float y, bool render);
|
||||
int RenderString(const char *text, float x, float y, bool render);
|
||||
int RenderString(const u8 *text, float x, float y, bool render);
|
||||
|
||||
|
||||
int PreCacheChar(u16 ch, u16 cachedCode);
|
||||
int GetCachedChar(u16 cachedCode);
|
||||
void DrawBitmap(void *image, FT_Bitmap *bitmap, FT_Int x, FT_Int y, int width, int height);
|
||||
|
||||
|
||||
JTexture* mTexture;
|
||||
|
||||
JQuad* mQuads[TTF_CACHE_SIZE];
|
||||
u16 mCachedCode[TTF_CACHE_SIZE];
|
||||
u8 mXAdvance[TTF_CACHE_SIZE];
|
||||
|
||||
int mCurr;
|
||||
|
||||
int mTexWidth;
|
||||
int mTexHeight;
|
||||
int mMaxCharWidth;
|
||||
int mMaxCharHeight;
|
||||
int mMaxCharCount;
|
||||
int mColCount;
|
||||
int mRowCount;
|
||||
|
||||
bool mASCIIDirectMapping;
|
||||
|
||||
JTTFont* mFontSource;
|
||||
bool mSharingFont;
|
||||
|
||||
int mSize;
|
||||
PIXEL_TYPE mColor;
|
||||
float mAngle;
|
||||
FT_Library mLibrary;
|
||||
FT_Face mFace;
|
||||
|
||||
FT_Byte* mFontBits;
|
||||
int mFontBitsSize;
|
||||
|
||||
bool mAntialias;
|
||||
|
||||
bool mFontLoaded;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 _JTTFONT_H
|
||||
#define _JTTFONT_H
|
||||
|
||||
#include "../../JGE/include/JGE.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#define TTF_CACHE_SIZE 256
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// True Type font support with the help of Freetype library. JTTFont has
|
||||
/// a simple caching system so that a character which has been rendered before
|
||||
/// can be retrieved from the cache instead of drawing it again by the
|
||||
/// Freetype library. This can give you a much faster rendering speed.
|
||||
/// Also, if you only need to use a limited number of characters
|
||||
/// in your game, you can actually cache all your characters in the cache
|
||||
/// beforehand and unload the font to save memory.
|
||||
///
|
||||
/// @par For example, if you only want to use the standard ASCII characters in
|
||||
/// your game:
|
||||
///
|
||||
/// @code
|
||||
///
|
||||
/// // in Create()
|
||||
/// mTTFont = new JTTFont();
|
||||
/// mTTFont->Load("arial.ttf", 32); // size 32
|
||||
///
|
||||
/// if (mTTFont->PreCacheASCII())
|
||||
/// mTTFont->Unload();
|
||||
/// ...
|
||||
///
|
||||
/// // in Render()
|
||||
/// mTTFont->RenderString("Hello World!", 240, 80, JGETEXT_CENTER);
|
||||
///
|
||||
/// @endcode
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JTTFont
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Constructor.
|
||||
///
|
||||
/// @param cacheImageSize - Size of the texture used for caching. This can
|
||||
/// be 64x64, 128x128(default), 256x256 or 512x512.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JTTFont(int cacheImageSize=CACHE_IMAGE_256x256);
|
||||
|
||||
~JTTFont();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum FONT_LOADING_MODE
|
||||
///
|
||||
/// Font loading options.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum FONT_LOADING_MODE
|
||||
{
|
||||
MODE_NORMAL, ///< Load only.
|
||||
MODE_PRECACHE_ASCII, ///< Load the font and cache all ASCII characters.
|
||||
MODE_PRECACHE_ASCII_EX ///< Load the font and cache all Extended ASCII characters.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \enum CACHE_IMAGE_SIZE
|
||||
///
|
||||
/// Size of the texture used for caching.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum CACHE_IMAGE_SIZE
|
||||
{
|
||||
CACHE_IMAGE_64x64, ///< 64x64
|
||||
CACHE_IMAGE_128x128, ///< 128x128
|
||||
CACHE_IMAGE_256x256, ///< 256x256
|
||||
CACHE_IMAGE_512x512 ///< 512x512
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set color of font.
|
||||
///
|
||||
/// @param color - Font color.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set angle of the font for rendering.
|
||||
///
|
||||
/// @param angle - Angle in radians.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAngle(float angle);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set font size.
|
||||
///
|
||||
/// @param size - Font size.
|
||||
///
|
||||
/// @note Setting font size will clear the cache.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool SetSize(int size);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load font file.
|
||||
///
|
||||
/// @param filename - Name of True Type font.
|
||||
/// @param size - Initial font size. Default is 12.
|
||||
/// @param mode - Loading mode.
|
||||
///
|
||||
/// @return - True if no error.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(const char *filename, int size=12, int mode=MODE_NORMAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Create font using font data from another JTTFont instance.
|
||||
///
|
||||
/// @param fontSource - Source of font data.
|
||||
/// @param size - Initial font size. Default is 12.
|
||||
/// @param mode - Loading mode.
|
||||
///
|
||||
/// @return - True if no error.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Load(JTTFont *fontSource, int size=12, int mode=MODE_NORMAL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Unload font file and related Freetype objects from memory.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Unload(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render Unicode string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const u16 *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render ASCII string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const char *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Render Chinese (GBK) string to screen.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
/// @param x - X position.
|
||||
/// @param y - Y position.
|
||||
/// @param alignment - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RenderString(const u8 *text, float x, float y, int alignment=JGETEXT_LEFT);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of an Unicode string into cache
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const u16 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of an ASCII string into cache.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const char *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put characters of a Chinese (GBK) string into cache.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PreCacheString(const u8 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of Unicode string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated Unicode-16 string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const u16 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of ASCII string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated ASCII string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const char *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get width of Chinese (GBK) string on screen.
|
||||
///
|
||||
/// @param text - NULL terminated GBK encoded string.
|
||||
///
|
||||
/// @return - Width in pixels
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetWidth(const u8 *text);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put all standard ASCII characters (0x20-0x7F) into cache.
|
||||
///
|
||||
/// @return - True if success.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PreCacheASCII();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Put all ASCII characters (0x20-0xFF) into cache.
|
||||
///
|
||||
/// @return - True if success.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PreCacheExtendedASCII();
|
||||
|
||||
void SetAntialias(bool flag);
|
||||
|
||||
protected:
|
||||
FT_Library GetFontLibrary();
|
||||
FT_Byte* GetFontBits();
|
||||
int GetFontBitsSize();
|
||||
|
||||
private:
|
||||
|
||||
int RenderString(const u16 *text, float x, float y, bool render);
|
||||
int RenderString(const char *text, float x, float y, bool render);
|
||||
int RenderString(const u8 *text, float x, float y, bool render);
|
||||
|
||||
|
||||
int PreCacheChar(u16 ch, u16 cachedCode);
|
||||
int GetCachedChar(u16 cachedCode);
|
||||
void DrawBitmap(void *image, FT_Bitmap *bitmap, FT_Int x, FT_Int y, int width, int height);
|
||||
|
||||
|
||||
JTexture* mTexture;
|
||||
|
||||
JQuad* mQuads[TTF_CACHE_SIZE];
|
||||
u16 mCachedCode[TTF_CACHE_SIZE];
|
||||
u8 mXAdvance[TTF_CACHE_SIZE];
|
||||
|
||||
int mCurr;
|
||||
|
||||
int mTexWidth;
|
||||
int mTexHeight;
|
||||
int mMaxCharWidth;
|
||||
int mMaxCharHeight;
|
||||
int mMaxCharCount;
|
||||
int mColCount;
|
||||
int mRowCount;
|
||||
|
||||
bool mASCIIDirectMapping;
|
||||
|
||||
JTTFont* mFontSource;
|
||||
bool mSharingFont;
|
||||
|
||||
int mSize;
|
||||
PIXEL_TYPE mColor;
|
||||
float mAngle;
|
||||
FT_Library mLibrary;
|
||||
FT_Face mFace;
|
||||
|
||||
FT_Byte* mFontBits;
|
||||
int mFontBitsSize;
|
||||
|
||||
bool mAntialias;
|
||||
|
||||
bool mFontLoaded;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
#define _VECTOR2D_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include <math.h>
|
||||
#elif (defined LINUX) || (defined IOS)
|
||||
#include <math.h>
|
||||
#else
|
||||
#include <fastmath.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct Vector2D
|
||||
{
|
||||
|
||||
float x, y;
|
||||
static const Vector2D& Blank() { static const Vector2D V(0, 0); return V; }
|
||||
|
||||
inline Vector2D(void) {}
|
||||
|
||||
inline Vector2D(float _x,float _y) : x(_x), y(_y) {}
|
||||
|
||||
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; }
|
||||
|
||||
inline bool operator ==(const Vector2D &v) const { return x == v.x && y == v.y; }
|
||||
inline bool operator !=(const Vector2D &v) const { return x != v.x || y != v.y; }
|
||||
|
||||
|
||||
// cross product
|
||||
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 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); }
|
||||
inline Vector2D operator + (const Vector2D &v) const { return Vector2D(x+v.x, y+v.y); }
|
||||
inline Vector2D operator - (const Vector2D &v) const { return Vector2D(x-v.x, y-v.y); }
|
||||
friend Vector2D operator * (float k, const Vector2D& v) { return Vector2D(v.x*k, v.y*k); }
|
||||
inline Vector2D operator -(void) const { return Vector2D(-x, -y); }
|
||||
|
||||
inline float Length(void) const;
|
||||
float Normalize(void) ;
|
||||
Vector2D Direction(void) const;
|
||||
float Angle(const Vector2D& xE);
|
||||
Vector2D& Rotate(float angle);
|
||||
Vector2D& Rotate(const Vector2D& xCentre, float fAngle);
|
||||
void Clamp(const Vector2D& min, const Vector2D& max);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
#define _VECTOR2D_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include <math.h>
|
||||
#elif (defined LINUX) || (defined IOS)
|
||||
#include <math.h>
|
||||
#else
|
||||
#include <fastmath.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct Vector2D
|
||||
{
|
||||
|
||||
float x, y;
|
||||
static const Vector2D& Blank() { static const Vector2D V(0, 0); return V; }
|
||||
|
||||
inline Vector2D(void) {}
|
||||
|
||||
inline Vector2D(float _x,float _y) : x(_x), y(_y) {}
|
||||
|
||||
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; }
|
||||
|
||||
inline bool operator ==(const Vector2D &v) const { return x == v.x && y == v.y; }
|
||||
inline bool operator !=(const Vector2D &v) const { return x != v.x || y != v.y; }
|
||||
|
||||
|
||||
// cross product
|
||||
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 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); }
|
||||
inline Vector2D operator + (const Vector2D &v) const { return Vector2D(x+v.x, y+v.y); }
|
||||
inline Vector2D operator - (const Vector2D &v) const { return Vector2D(x-v.x, y-v.y); }
|
||||
friend Vector2D operator * (float k, const Vector2D& v) { return Vector2D(v.x*k, v.y*k); }
|
||||
inline Vector2D operator -(void) const { return Vector2D(-x, -y); }
|
||||
|
||||
inline float Length(void) const;
|
||||
float Normalize(void) ;
|
||||
Vector2D Direction(void) const;
|
||||
float Angle(const Vector2D& xE);
|
||||
Vector2D& Rotate(float angle);
|
||||
Vector2D& Rotate(const Vector2D& xCentre, float fAngle);
|
||||
void Clamp(const Vector2D& min, const Vector2D& max);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,95 +1,95 @@
|
||||
#ifndef __VECTOR3D_H_
|
||||
#define __VECTOR3D_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*************************** Macros and constants ***************************/
|
||||
// returns a number ranging from -1.0 to 1.0
|
||||
#define FRAND (((float)rand()-(float)rand())/RAND_MAX)
|
||||
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
|
||||
|
||||
#define SQUARE(x) (x)*(x)
|
||||
|
||||
|
||||
struct Vector3D
|
||||
{
|
||||
Vector3D(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||
Vector3D(const Vector3D &v) : x(v.x), y(v.y), z(v.z) {}
|
||||
Vector3D() : x(0.0f), y(0.0f), z(0.0f) {}
|
||||
|
||||
Vector3D& operator=(const Vector3D &rhs)
|
||||
{
|
||||
x = rhs.x;
|
||||
y = rhs.y;
|
||||
z = rhs.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// vector add
|
||||
Vector3D operator+(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(x + rhs.x, y + rhs.y, z + rhs.z);
|
||||
}
|
||||
|
||||
// vector subtract
|
||||
Vector3D operator-(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(x - rhs.x, y - rhs.y, z - rhs.z);
|
||||
}
|
||||
|
||||
// scalar multiplication
|
||||
Vector3D operator*(const float scalar) const
|
||||
{
|
||||
return Vector3D(x * scalar, y * scalar, z * scalar);
|
||||
}
|
||||
|
||||
// dot product
|
||||
float operator*(const Vector3D &rhs) const
|
||||
{
|
||||
return x * rhs.x + y * rhs.y + z * rhs.z;
|
||||
}
|
||||
|
||||
// cross product
|
||||
Vector3D operator^(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(y * rhs.z - rhs.y * z, rhs.x * z - x * rhs.z, x * rhs.y - rhs.x * y);
|
||||
}
|
||||
|
||||
float& operator[](int index)
|
||||
{
|
||||
return v[index];
|
||||
}
|
||||
|
||||
float Length()
|
||||
{
|
||||
float length = (float)sqrt(SQUARE(x) + SQUARE(y) + SQUARE(z));
|
||||
return (length != 0.0f) ? length : 1.0f;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Normalize()
|
||||
|
||||
Helper function to normalize vectors
|
||||
*****************************************************************************/
|
||||
Vector3D Normalize()
|
||||
{
|
||||
*this = *this * (1.0f/Length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
float v[3];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __VECTOR3D_H_
|
||||
#define __VECTOR3D_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*************************** Macros and constants ***************************/
|
||||
// returns a number ranging from -1.0 to 1.0
|
||||
#define FRAND (((float)rand()-(float)rand())/RAND_MAX)
|
||||
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
|
||||
|
||||
#define SQUARE(x) (x)*(x)
|
||||
|
||||
|
||||
struct Vector3D
|
||||
{
|
||||
Vector3D(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||
Vector3D(const Vector3D &v) : x(v.x), y(v.y), z(v.z) {}
|
||||
Vector3D() : x(0.0f), y(0.0f), z(0.0f) {}
|
||||
|
||||
Vector3D& operator=(const Vector3D &rhs)
|
||||
{
|
||||
x = rhs.x;
|
||||
y = rhs.y;
|
||||
z = rhs.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// vector add
|
||||
Vector3D operator+(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(x + rhs.x, y + rhs.y, z + rhs.z);
|
||||
}
|
||||
|
||||
// vector subtract
|
||||
Vector3D operator-(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(x - rhs.x, y - rhs.y, z - rhs.z);
|
||||
}
|
||||
|
||||
// scalar multiplication
|
||||
Vector3D operator*(const float scalar) const
|
||||
{
|
||||
return Vector3D(x * scalar, y * scalar, z * scalar);
|
||||
}
|
||||
|
||||
// dot product
|
||||
float operator*(const Vector3D &rhs) const
|
||||
{
|
||||
return x * rhs.x + y * rhs.y + z * rhs.z;
|
||||
}
|
||||
|
||||
// cross product
|
||||
Vector3D operator^(const Vector3D &rhs) const
|
||||
{
|
||||
return Vector3D(y * rhs.z - rhs.y * z, rhs.x * z - x * rhs.z, x * rhs.y - rhs.x * y);
|
||||
}
|
||||
|
||||
float& operator[](int index)
|
||||
{
|
||||
return v[index];
|
||||
}
|
||||
|
||||
float Length()
|
||||
{
|
||||
float length = (float)sqrt(SQUARE(x) + SQUARE(y) + SQUARE(z));
|
||||
return (length != 0.0f) ? length : 1.0f;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Normalize()
|
||||
|
||||
Helper function to normalize vectors
|
||||
*****************************************************************************/
|
||||
Vector3D Normalize()
|
||||
{
|
||||
*this = *this * (1.0f/Length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
float v[3];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeColor*** helper classes
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGECOLOR_H
|
||||
#define HGECOLOR_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
|
||||
#include "../JTypes.h"
|
||||
|
||||
#define hgeColor hgeColorRGB
|
||||
|
||||
inline void ColorClamp(float &x) { if(x<0.0f) x=0.0f; if(x>1.0f) x=1.0f; }
|
||||
|
||||
|
||||
class hgeColorRGB
|
||||
{
|
||||
public:
|
||||
float r,g,b,a;
|
||||
|
||||
hgeColorRGB(float _r, float _g, float _b, float _a) { r=_r; g=_g; b=_b; a=_a; }
|
||||
hgeColorRGB(DWORD col) { SetHWColor(col); }
|
||||
hgeColorRGB() { r=g=b=a=0; }
|
||||
|
||||
hgeColorRGB operator- (const hgeColorRGB &c) const { return hgeColorRGB(r-c.r, g-c.g, b-c.b, a-c.a); }
|
||||
hgeColorRGB operator+ (const hgeColorRGB &c) const { return hgeColorRGB(r+c.r, g+c.g, b+c.b, a+c.a); }
|
||||
hgeColorRGB operator* (const hgeColorRGB &c) const { return hgeColorRGB(r*c.r, g*c.g, b*c.b, a*c.a); }
|
||||
hgeColorRGB& operator-= (const hgeColorRGB &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; return *this; }
|
||||
hgeColorRGB& operator+= (const hgeColorRGB &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; return *this; }
|
||||
bool operator== (const hgeColorRGB &c) const { return (r==c.r && g==c.g && b==c.b && a==c.a); }
|
||||
bool operator!= (const hgeColorRGB &c) const { return (r!=c.r || g!=c.g || b!=c.b || a!=c.a); }
|
||||
|
||||
hgeColorRGB operator/ (const float scalar) const { return hgeColorRGB(r/scalar, g/scalar, b/scalar, a/scalar); }
|
||||
hgeColorRGB operator* (const float scalar) const { return hgeColorRGB(r*scalar, g*scalar, b*scalar, a*scalar); }
|
||||
hgeColorRGB& operator*= (const float scalar) { r*=scalar; g*=scalar; b*=scalar; a*=scalar; return *this; }
|
||||
|
||||
void Clamp() { ColorClamp(r); ColorClamp(g); ColorClamp(b); ColorClamp(a); }
|
||||
void SetHWColor(DWORD col) { a = (col>>24)/255.0f; r = ((col>>16) & 0xFF)/255.0f; g = ((col>>8) & 0xFF)/255.0f; b = (col & 0xFF)/255.0f; }
|
||||
DWORD GetHWColor() const { return ARGB(((int)(a*255.0f)), ((int)(r*255.0f)), ((int)(g*255.0f)), ((int)(b*255.0f))); }
|
||||
};
|
||||
|
||||
inline hgeColorRGB operator* (const float sc, const hgeColorRGB &c) { return c*sc; }
|
||||
|
||||
|
||||
class hgeColorHSV
|
||||
{
|
||||
public:
|
||||
float h,s,v,a;
|
||||
|
||||
hgeColorHSV(float _h, float _s, float _v, float _a) { h=_h; s=_s; v=_v; a=_a; }
|
||||
hgeColorHSV(DWORD col) { SetHWColor(col); }
|
||||
hgeColorHSV() { h=s=v=a=0; }
|
||||
|
||||
hgeColorHSV operator- (const hgeColorHSV &c) const { return hgeColorHSV(h-c.h, s-c.s, v-c.v, a-c.a); }
|
||||
hgeColorHSV operator+ (const hgeColorHSV &c) const { return hgeColorHSV(h+c.h, s+c.s, v+c.v, a+c.a); }
|
||||
hgeColorHSV operator* (const hgeColorHSV &c) const { return hgeColorHSV(h*c.h, s*c.s, v*c.v, a*c.a); }
|
||||
hgeColorHSV& operator-= (const hgeColorHSV &c) { h-=c.h; s-=c.s; v-=c.v; a-=c.a; return *this; }
|
||||
hgeColorHSV& operator+= (const hgeColorHSV &c) { h+=c.h; s+=c.s; v+=c.v; a+=c.a; return *this; }
|
||||
bool operator== (const hgeColorHSV &c) const { return (h==c.h && s==c.s && v==c.v && a==c.a); }
|
||||
bool operator!= (const hgeColorHSV &c) const { return (h!=c.h || s!=c.s || v!=c.v || a!=c.a); }
|
||||
|
||||
hgeColorHSV operator/ (const float scalar) const { return hgeColorHSV(h/scalar, s/scalar, v/scalar, a/scalar); }
|
||||
hgeColorHSV operator* (const float scalar) const { return hgeColorHSV(h*scalar, s*scalar, v*scalar, a*scalar); }
|
||||
hgeColorHSV& operator*= (const float scalar) { h*=scalar; s*=scalar; v*=scalar; a*=scalar; return *this; }
|
||||
|
||||
void Clamp() { ColorClamp(h); ColorClamp(s); ColorClamp(v); ColorClamp(a); }
|
||||
void SetHWColor(DWORD col);
|
||||
DWORD GetHWColor() const;
|
||||
};
|
||||
|
||||
inline hgeColorHSV operator* (const float sc, const hgeColorHSV &c) { return c*sc; }
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeColor*** helper classes
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGECOLOR_H
|
||||
#define HGECOLOR_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
|
||||
#include "../JTypes.h"
|
||||
|
||||
#define hgeColor hgeColorRGB
|
||||
|
||||
inline void ColorClamp(float &x) { if(x<0.0f) x=0.0f; if(x>1.0f) x=1.0f; }
|
||||
|
||||
|
||||
class hgeColorRGB
|
||||
{
|
||||
public:
|
||||
float r,g,b,a;
|
||||
|
||||
hgeColorRGB(float _r, float _g, float _b, float _a) { r=_r; g=_g; b=_b; a=_a; }
|
||||
hgeColorRGB(DWORD col) { SetHWColor(col); }
|
||||
hgeColorRGB() { r=g=b=a=0; }
|
||||
|
||||
hgeColorRGB operator- (const hgeColorRGB &c) const { return hgeColorRGB(r-c.r, g-c.g, b-c.b, a-c.a); }
|
||||
hgeColorRGB operator+ (const hgeColorRGB &c) const { return hgeColorRGB(r+c.r, g+c.g, b+c.b, a+c.a); }
|
||||
hgeColorRGB operator* (const hgeColorRGB &c) const { return hgeColorRGB(r*c.r, g*c.g, b*c.b, a*c.a); }
|
||||
hgeColorRGB& operator-= (const hgeColorRGB &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; return *this; }
|
||||
hgeColorRGB& operator+= (const hgeColorRGB &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; return *this; }
|
||||
bool operator== (const hgeColorRGB &c) const { return (r==c.r && g==c.g && b==c.b && a==c.a); }
|
||||
bool operator!= (const hgeColorRGB &c) const { return (r!=c.r || g!=c.g || b!=c.b || a!=c.a); }
|
||||
|
||||
hgeColorRGB operator/ (const float scalar) const { return hgeColorRGB(r/scalar, g/scalar, b/scalar, a/scalar); }
|
||||
hgeColorRGB operator* (const float scalar) const { return hgeColorRGB(r*scalar, g*scalar, b*scalar, a*scalar); }
|
||||
hgeColorRGB& operator*= (const float scalar) { r*=scalar; g*=scalar; b*=scalar; a*=scalar; return *this; }
|
||||
|
||||
void Clamp() { ColorClamp(r); ColorClamp(g); ColorClamp(b); ColorClamp(a); }
|
||||
void SetHWColor(DWORD col) { a = (col>>24)/255.0f; r = ((col>>16) & 0xFF)/255.0f; g = ((col>>8) & 0xFF)/255.0f; b = (col & 0xFF)/255.0f; }
|
||||
DWORD GetHWColor() const { return ARGB(((int)(a*255.0f)), ((int)(r*255.0f)), ((int)(g*255.0f)), ((int)(b*255.0f))); }
|
||||
};
|
||||
|
||||
inline hgeColorRGB operator* (const float sc, const hgeColorRGB &c) { return c*sc; }
|
||||
|
||||
|
||||
class hgeColorHSV
|
||||
{
|
||||
public:
|
||||
float h,s,v,a;
|
||||
|
||||
hgeColorHSV(float _h, float _s, float _v, float _a) { h=_h; s=_s; v=_v; a=_a; }
|
||||
hgeColorHSV(DWORD col) { SetHWColor(col); }
|
||||
hgeColorHSV() { h=s=v=a=0; }
|
||||
|
||||
hgeColorHSV operator- (const hgeColorHSV &c) const { return hgeColorHSV(h-c.h, s-c.s, v-c.v, a-c.a); }
|
||||
hgeColorHSV operator+ (const hgeColorHSV &c) const { return hgeColorHSV(h+c.h, s+c.s, v+c.v, a+c.a); }
|
||||
hgeColorHSV operator* (const hgeColorHSV &c) const { return hgeColorHSV(h*c.h, s*c.s, v*c.v, a*c.a); }
|
||||
hgeColorHSV& operator-= (const hgeColorHSV &c) { h-=c.h; s-=c.s; v-=c.v; a-=c.a; return *this; }
|
||||
hgeColorHSV& operator+= (const hgeColorHSV &c) { h+=c.h; s+=c.s; v+=c.v; a+=c.a; return *this; }
|
||||
bool operator== (const hgeColorHSV &c) const { return (h==c.h && s==c.s && v==c.v && a==c.a); }
|
||||
bool operator!= (const hgeColorHSV &c) const { return (h!=c.h || s!=c.s || v!=c.v || a!=c.a); }
|
||||
|
||||
hgeColorHSV operator/ (const float scalar) const { return hgeColorHSV(h/scalar, s/scalar, v/scalar, a/scalar); }
|
||||
hgeColorHSV operator* (const float scalar) const { return hgeColorHSV(h*scalar, s*scalar, v*scalar, a*scalar); }
|
||||
hgeColorHSV& operator*= (const float scalar) { h*=scalar; s*=scalar; v*=scalar; a*=scalar; return *this; }
|
||||
|
||||
void Clamp() { ColorClamp(h); ColorClamp(s); ColorClamp(v); ColorClamp(a); }
|
||||
void SetHWColor(DWORD col);
|
||||
DWORD GetHWColor() const;
|
||||
};
|
||||
|
||||
inline hgeColorHSV operator* (const float sc, const hgeColorHSV &c) { return c*sc; }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeDistortionMesh helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEDISTORT_H
|
||||
#define HGEDISTORT_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
#include "../JTypes.h"
|
||||
|
||||
|
||||
#define HGEDISP_NODE 0
|
||||
#define HGEDISP_TOPLEFT 1
|
||||
#define HGEDISP_CENTER 2
|
||||
|
||||
class JTexture;
|
||||
class JQuad;
|
||||
|
||||
/*
|
||||
** HGE Distortion mesh class
|
||||
*/
|
||||
class hgeDistortionMesh
|
||||
{
|
||||
public:
|
||||
hgeDistortionMesh(int cols, int rows);
|
||||
hgeDistortionMesh(const hgeDistortionMesh &dm);
|
||||
~hgeDistortionMesh();
|
||||
|
||||
hgeDistortionMesh& operator= (const hgeDistortionMesh &dm);
|
||||
|
||||
void Render(float x, float y);
|
||||
void Clear(PIXEL_TYPE col=ARGB(0xFF,0xFF,0xFF,0xFF), float z=0.5f);
|
||||
|
||||
void SetTexture(JTexture* tex);
|
||||
void SetTextureRect(float x, float y, float w, float h);
|
||||
void SetBlendMode(int blend);
|
||||
void SetZ(int col, int row, float z);
|
||||
void SetColor(int col, int row, PIXEL_TYPE color);
|
||||
void SetDisplacement(int col, int row, float dx, float dy, int ref);
|
||||
|
||||
JTexture* GetTexture() const {return quad->mTex;}
|
||||
void GetTextureRect(float *x, float *y, float *w, float *h) const { *x=tx; *y=ty; *w=width; *h=height; }
|
||||
int GetBlendMode() const { return 0; }
|
||||
float GetZ(int col, int row) const;
|
||||
PIXEL_TYPE GetColor(int col, int row) const;
|
||||
void GetDisplacement(int col, int row, float *dx, float *dy, int ref) const;
|
||||
|
||||
int GetRows() { return nRows; }
|
||||
int GetCols() { return nCols; }
|
||||
|
||||
private:
|
||||
hgeDistortionMesh();
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
Vertex *disp_array;
|
||||
int nRows, nCols;
|
||||
float cellw,cellh;
|
||||
float tx,ty,width,height;
|
||||
JQuad* quad;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeDistortionMesh helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEDISTORT_H
|
||||
#define HGEDISTORT_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
#include "../JTypes.h"
|
||||
|
||||
|
||||
#define HGEDISP_NODE 0
|
||||
#define HGEDISP_TOPLEFT 1
|
||||
#define HGEDISP_CENTER 2
|
||||
|
||||
class JTexture;
|
||||
class JQuad;
|
||||
|
||||
/*
|
||||
** HGE Distortion mesh class
|
||||
*/
|
||||
class hgeDistortionMesh
|
||||
{
|
||||
public:
|
||||
hgeDistortionMesh(int cols, int rows);
|
||||
hgeDistortionMesh(const hgeDistortionMesh &dm);
|
||||
~hgeDistortionMesh();
|
||||
|
||||
hgeDistortionMesh& operator= (const hgeDistortionMesh &dm);
|
||||
|
||||
void Render(float x, float y);
|
||||
void Clear(PIXEL_TYPE col=ARGB(0xFF,0xFF,0xFF,0xFF), float z=0.5f);
|
||||
|
||||
void SetTexture(JTexture* tex);
|
||||
void SetTextureRect(float x, float y, float w, float h);
|
||||
void SetBlendMode(int blend);
|
||||
void SetZ(int col, int row, float z);
|
||||
void SetColor(int col, int row, PIXEL_TYPE color);
|
||||
void SetDisplacement(int col, int row, float dx, float dy, int ref);
|
||||
|
||||
JTexture* GetTexture() const {return quad->mTex;}
|
||||
void GetTextureRect(float *x, float *y, float *w, float *h) const { *x=tx; *y=ty; *w=width; *h=height; }
|
||||
int GetBlendMode() const { return 0; }
|
||||
float GetZ(int col, int row) const;
|
||||
PIXEL_TYPE GetColor(int col, int row) const;
|
||||
void GetDisplacement(int col, int row, float *dx, float *dy, int ref) const;
|
||||
|
||||
int GetRows() { return nRows; }
|
||||
int GetCols() { return nCols; }
|
||||
|
||||
private:
|
||||
hgeDistortionMesh();
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
Vertex *disp_array;
|
||||
int nRows, nCols;
|
||||
float cellw,cellh;
|
||||
float tx,ty,width,height;
|
||||
JQuad* quad;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeFont helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEFONT_H
|
||||
#define HGEFONT_H
|
||||
|
||||
#include "../JTypes.h"
|
||||
//#include "hge.h"
|
||||
//#include "hgesprite.h"
|
||||
|
||||
|
||||
#define HGETEXT_LEFT 0
|
||||
#define HGETEXT_RIGHT 1
|
||||
#define HGETEXT_CENTER 2
|
||||
#define HGETEXT_HORZMASK 0x03
|
||||
|
||||
#define HGETEXT_TOP 0
|
||||
#define HGETEXT_BOTTOM 4
|
||||
#define HGETEXT_MIDDLE 8
|
||||
#define HGETEXT_VERTMASK 0x0C
|
||||
|
||||
class JTexture;
|
||||
class JQuad;
|
||||
/*
|
||||
** HGE Font class
|
||||
*/
|
||||
class hgeFont
|
||||
{
|
||||
public:
|
||||
hgeFont(const char *filename, bool bMipmap=false);
|
||||
~hgeFont();
|
||||
|
||||
void Render(float x, float y, int align, const char *string);
|
||||
void printf(float x, float y, int align, const char *format, ...);
|
||||
void printfb(float x, float y, float w, float h, int align, const char *format, ...);
|
||||
|
||||
void SetColor(PIXEL_TYPE col);
|
||||
void SetZ(float z);
|
||||
void SetBlendMode(int blend);
|
||||
void SetScale(float scale) {fScale=scale;}
|
||||
void SetProportion(float prop) { fProportion=prop; }
|
||||
void SetRotation(float rot) {fRot=rot;}
|
||||
void SetTracking(float tracking) {fTracking=tracking;}
|
||||
void SetSpacing(float spacing) {fSpacing=spacing;}
|
||||
|
||||
PIXEL_TYPE GetColor() const {return dwCol;}
|
||||
float GetZ() const {return fZ;}
|
||||
int GetBlendMode() const {return nBlend;}
|
||||
float GetScale() const {return fScale;}
|
||||
float GetProportion() const { return fProportion; }
|
||||
float GetRotation() const {return fRot;}
|
||||
float GetTracking() const {return fTracking;}
|
||||
float GetSpacing() const {return fSpacing;}
|
||||
|
||||
JQuad* GetSprite(char chr) const { return letters[(unsigned char)chr]; }
|
||||
float GetHeight() const { return fHeight; }
|
||||
float GetStringWidth(const char *string) const;
|
||||
|
||||
private:
|
||||
hgeFont();
|
||||
hgeFont(const hgeFont &fnt);
|
||||
hgeFont& operator= (const hgeFont &fnt);
|
||||
|
||||
char* _get_line(char *file, char *line);
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
static char buffer[256];
|
||||
|
||||
JTexture* hTexture;
|
||||
JQuad* letters[256];
|
||||
float pre[256];
|
||||
float post[256];
|
||||
float fHeight;
|
||||
float fScale;
|
||||
float fProportion;
|
||||
float fRot;
|
||||
float fTracking;
|
||||
float fSpacing;
|
||||
|
||||
PIXEL_TYPE dwCol;
|
||||
float fZ;
|
||||
int nBlend;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeFont helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEFONT_H
|
||||
#define HGEFONT_H
|
||||
|
||||
#include "../JTypes.h"
|
||||
//#include "hge.h"
|
||||
//#include "hgesprite.h"
|
||||
|
||||
|
||||
#define HGETEXT_LEFT 0
|
||||
#define HGETEXT_RIGHT 1
|
||||
#define HGETEXT_CENTER 2
|
||||
#define HGETEXT_HORZMASK 0x03
|
||||
|
||||
#define HGETEXT_TOP 0
|
||||
#define HGETEXT_BOTTOM 4
|
||||
#define HGETEXT_MIDDLE 8
|
||||
#define HGETEXT_VERTMASK 0x0C
|
||||
|
||||
class JTexture;
|
||||
class JQuad;
|
||||
/*
|
||||
** HGE Font class
|
||||
*/
|
||||
class hgeFont
|
||||
{
|
||||
public:
|
||||
hgeFont(const char *filename, bool bMipmap=false);
|
||||
~hgeFont();
|
||||
|
||||
void Render(float x, float y, int align, const char *string);
|
||||
void printf(float x, float y, int align, const char *format, ...);
|
||||
void printfb(float x, float y, float w, float h, int align, const char *format, ...);
|
||||
|
||||
void SetColor(PIXEL_TYPE col);
|
||||
void SetZ(float z);
|
||||
void SetBlendMode(int blend);
|
||||
void SetScale(float scale) {fScale=scale;}
|
||||
void SetProportion(float prop) { fProportion=prop; }
|
||||
void SetRotation(float rot) {fRot=rot;}
|
||||
void SetTracking(float tracking) {fTracking=tracking;}
|
||||
void SetSpacing(float spacing) {fSpacing=spacing;}
|
||||
|
||||
PIXEL_TYPE GetColor() const {return dwCol;}
|
||||
float GetZ() const {return fZ;}
|
||||
int GetBlendMode() const {return nBlend;}
|
||||
float GetScale() const {return fScale;}
|
||||
float GetProportion() const { return fProportion; }
|
||||
float GetRotation() const {return fRot;}
|
||||
float GetTracking() const {return fTracking;}
|
||||
float GetSpacing() const {return fSpacing;}
|
||||
|
||||
JQuad* GetSprite(char chr) const { return letters[(unsigned char)chr]; }
|
||||
float GetHeight() const { return fHeight; }
|
||||
float GetStringWidth(const char *string) const;
|
||||
|
||||
private:
|
||||
hgeFont();
|
||||
hgeFont(const hgeFont &fnt);
|
||||
hgeFont& operator= (const hgeFont &fnt);
|
||||
|
||||
char* _get_line(char *file, char *line);
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
static char buffer[256];
|
||||
|
||||
JTexture* hTexture;
|
||||
JQuad* letters[256];
|
||||
float pre[256];
|
||||
float post[256];
|
||||
float fHeight;
|
||||
float fScale;
|
||||
float fProportion;
|
||||
float fRot;
|
||||
float fTracking;
|
||||
float fSpacing;
|
||||
|
||||
PIXEL_TYPE dwCol;
|
||||
float fZ;
|
||||
int nBlend;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,165 +1,165 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeParticleSystem helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEPARTICLE_H
|
||||
#define HGEPARTICLE_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
//#include "hgesprite.h"
|
||||
#include "hgevector.h"
|
||||
#include "hgecolor.h"
|
||||
#include "hgerect.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
class JQuad;
|
||||
|
||||
#define MAX_PARTICLES 500
|
||||
#define MAX_PSYSTEMS 100
|
||||
|
||||
struct hgeParticle
|
||||
{
|
||||
hgeVector vecLocation;
|
||||
hgeVector vecVelocity;
|
||||
|
||||
float fGravity;
|
||||
float fRadialAccel;
|
||||
float fTangentialAccel;
|
||||
|
||||
float fSpin;
|
||||
float fSpinDelta;
|
||||
|
||||
float fSize;
|
||||
float fSizeDelta;
|
||||
|
||||
hgeColor colColor; // + alpha
|
||||
hgeColor colColorDelta;
|
||||
|
||||
float fAge;
|
||||
float fTerminalAge;
|
||||
};
|
||||
|
||||
struct hgeParticleSystemInfo
|
||||
{
|
||||
JQuad* sprite; // texture + blend mode
|
||||
int nEmission; // particles per sec
|
||||
float fLifetime;
|
||||
|
||||
float fParticleLifeMin;
|
||||
float fParticleLifeMax;
|
||||
|
||||
float fDirection;
|
||||
float fSpread;
|
||||
bool bRelative;
|
||||
|
||||
float fSpeedMin;
|
||||
float fSpeedMax;
|
||||
|
||||
float fGravityMin;
|
||||
float fGravityMax;
|
||||
|
||||
float fRadialAccelMin;
|
||||
float fRadialAccelMax;
|
||||
|
||||
float fTangentialAccelMin;
|
||||
float fTangentialAccelMax;
|
||||
|
||||
float fSizeStart;
|
||||
float fSizeEnd;
|
||||
float fSizeVar;
|
||||
|
||||
float fSpinStart;
|
||||
float fSpinEnd;
|
||||
float fSpinVar;
|
||||
|
||||
hgeColor colColorStart; // + alpha
|
||||
hgeColor colColorEnd;
|
||||
float fColorVar;
|
||||
float fAlphaVar;
|
||||
};
|
||||
|
||||
class hgeParticleSystem
|
||||
{
|
||||
public:
|
||||
hgeParticleSystemInfo info;
|
||||
|
||||
hgeParticleSystem(const char *filename, JQuad *sprite);
|
||||
hgeParticleSystem(hgeParticleSystemInfo *psi);
|
||||
hgeParticleSystem(const hgeParticleSystem &ps);
|
||||
~hgeParticleSystem() { }
|
||||
|
||||
hgeParticleSystem& operator= (const hgeParticleSystem &ps);
|
||||
|
||||
|
||||
void Render();
|
||||
void FireAt(float x, float y);
|
||||
void Fire();
|
||||
void Stop(bool bKillParticles=false);
|
||||
void Update(float fDeltaTime);
|
||||
void MoveTo(float x, float y, bool bMoveParticles=false);
|
||||
void Transpose(float x, float y) { fTx=x; fTy=y; }
|
||||
void TrackBoundingBox(bool bTrack) { bUpdateBoundingBox=bTrack; }
|
||||
|
||||
int GetParticlesAlive() const { return nParticlesAlive; }
|
||||
float GetAge() const { return fAge; }
|
||||
void GetPosition(float *x, float *y) const { *x=vecLocation.x; *y=vecLocation.y; }
|
||||
void GetTransposition(float *x, float *y) const { *x=fTx; *y=fTy; }
|
||||
hgeRect* GetBoundingBox(hgeRect *rect) const { memcpy(rect, &rectBoundingBox, sizeof(hgeRect)); return rect; }
|
||||
|
||||
private:
|
||||
hgeParticleSystem();
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
float fAge;
|
||||
float fEmissionResidue;
|
||||
|
||||
hgeVector vecPrevLocation;
|
||||
hgeVector vecLocation;
|
||||
float fTx, fTy;
|
||||
|
||||
int nParticlesAlive;
|
||||
hgeRect rectBoundingBox;
|
||||
bool bUpdateBoundingBox;
|
||||
|
||||
typedef std::list<hgeParticle> ParticleBuffer;
|
||||
ParticleBuffer mParticleBuffer;
|
||||
|
||||
float mTimer;
|
||||
};
|
||||
|
||||
class hgeParticleManager
|
||||
{
|
||||
public:
|
||||
hgeParticleManager();
|
||||
~hgeParticleManager();
|
||||
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
|
||||
hgeParticleSystem* SpawnPS(hgeParticleSystemInfo *psi, float x, float y);
|
||||
bool IsPSAlive(hgeParticleSystem *ps) const;
|
||||
void Transpose(float x, float y);
|
||||
void GetTransposition(float *dx, float *dy) const {*dx=tX; *dy=tY;}
|
||||
void KillPS(hgeParticleSystem *ps);
|
||||
void KillAll();
|
||||
|
||||
private:
|
||||
hgeParticleManager(const hgeParticleManager &);
|
||||
hgeParticleManager& operator= (const hgeParticleManager &);
|
||||
|
||||
int nPS;
|
||||
float tX;
|
||||
float tY;
|
||||
hgeParticleSystem* psList[MAX_PSYSTEMS];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeParticleSystem helper class header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEPARTICLE_H
|
||||
#define HGEPARTICLE_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
//#include "hgesprite.h"
|
||||
#include "hgevector.h"
|
||||
#include "hgecolor.h"
|
||||
#include "hgerect.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
class JQuad;
|
||||
|
||||
#define MAX_PARTICLES 500
|
||||
#define MAX_PSYSTEMS 100
|
||||
|
||||
struct hgeParticle
|
||||
{
|
||||
hgeVector vecLocation;
|
||||
hgeVector vecVelocity;
|
||||
|
||||
float fGravity;
|
||||
float fRadialAccel;
|
||||
float fTangentialAccel;
|
||||
|
||||
float fSpin;
|
||||
float fSpinDelta;
|
||||
|
||||
float fSize;
|
||||
float fSizeDelta;
|
||||
|
||||
hgeColor colColor; // + alpha
|
||||
hgeColor colColorDelta;
|
||||
|
||||
float fAge;
|
||||
float fTerminalAge;
|
||||
};
|
||||
|
||||
struct hgeParticleSystemInfo
|
||||
{
|
||||
JQuad* sprite; // texture + blend mode
|
||||
int nEmission; // particles per sec
|
||||
float fLifetime;
|
||||
|
||||
float fParticleLifeMin;
|
||||
float fParticleLifeMax;
|
||||
|
||||
float fDirection;
|
||||
float fSpread;
|
||||
bool bRelative;
|
||||
|
||||
float fSpeedMin;
|
||||
float fSpeedMax;
|
||||
|
||||
float fGravityMin;
|
||||
float fGravityMax;
|
||||
|
||||
float fRadialAccelMin;
|
||||
float fRadialAccelMax;
|
||||
|
||||
float fTangentialAccelMin;
|
||||
float fTangentialAccelMax;
|
||||
|
||||
float fSizeStart;
|
||||
float fSizeEnd;
|
||||
float fSizeVar;
|
||||
|
||||
float fSpinStart;
|
||||
float fSpinEnd;
|
||||
float fSpinVar;
|
||||
|
||||
hgeColor colColorStart; // + alpha
|
||||
hgeColor colColorEnd;
|
||||
float fColorVar;
|
||||
float fAlphaVar;
|
||||
};
|
||||
|
||||
class hgeParticleSystem
|
||||
{
|
||||
public:
|
||||
hgeParticleSystemInfo info;
|
||||
|
||||
hgeParticleSystem(const char *filename, JQuad *sprite);
|
||||
hgeParticleSystem(hgeParticleSystemInfo *psi);
|
||||
hgeParticleSystem(const hgeParticleSystem &ps);
|
||||
~hgeParticleSystem() { }
|
||||
|
||||
hgeParticleSystem& operator= (const hgeParticleSystem &ps);
|
||||
|
||||
|
||||
void Render();
|
||||
void FireAt(float x, float y);
|
||||
void Fire();
|
||||
void Stop(bool bKillParticles=false);
|
||||
void Update(float fDeltaTime);
|
||||
void MoveTo(float x, float y, bool bMoveParticles=false);
|
||||
void Transpose(float x, float y) { fTx=x; fTy=y; }
|
||||
void TrackBoundingBox(bool bTrack) { bUpdateBoundingBox=bTrack; }
|
||||
|
||||
int GetParticlesAlive() const { return nParticlesAlive; }
|
||||
float GetAge() const { return fAge; }
|
||||
void GetPosition(float *x, float *y) const { *x=vecLocation.x; *y=vecLocation.y; }
|
||||
void GetTransposition(float *x, float *y) const { *x=fTx; *y=fTy; }
|
||||
hgeRect* GetBoundingBox(hgeRect *rect) const { memcpy(rect, &rectBoundingBox, sizeof(hgeRect)); return rect; }
|
||||
|
||||
private:
|
||||
hgeParticleSystem();
|
||||
|
||||
//static HGE *hge;
|
||||
|
||||
float fAge;
|
||||
float fEmissionResidue;
|
||||
|
||||
hgeVector vecPrevLocation;
|
||||
hgeVector vecLocation;
|
||||
float fTx, fTy;
|
||||
|
||||
int nParticlesAlive;
|
||||
hgeRect rectBoundingBox;
|
||||
bool bUpdateBoundingBox;
|
||||
|
||||
typedef std::list<hgeParticle> ParticleBuffer;
|
||||
ParticleBuffer mParticleBuffer;
|
||||
|
||||
float mTimer;
|
||||
};
|
||||
|
||||
class hgeParticleManager
|
||||
{
|
||||
public:
|
||||
hgeParticleManager();
|
||||
~hgeParticleManager();
|
||||
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
|
||||
hgeParticleSystem* SpawnPS(hgeParticleSystemInfo *psi, float x, float y);
|
||||
bool IsPSAlive(hgeParticleSystem *ps) const;
|
||||
void Transpose(float x, float y);
|
||||
void GetTransposition(float *dx, float *dy) const {*dx=tX; *dy=tY;}
|
||||
void KillPS(hgeParticleSystem *ps);
|
||||
void KillAll();
|
||||
|
||||
private:
|
||||
hgeParticleManager(const hgeParticleManager &);
|
||||
hgeParticleManager& operator= (const hgeParticleManager &);
|
||||
|
||||
int nPS;
|
||||
float tX;
|
||||
float tY;
|
||||
hgeParticleSystem* psList[MAX_PSYSTEMS];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeRect helper class
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGERECT_H
|
||||
#define HGERECT_H
|
||||
|
||||
|
||||
class hgeRect
|
||||
{
|
||||
public:
|
||||
float x1, y1, x2, y2;
|
||||
|
||||
hgeRect(float _x1, float _y1, float _x2, float _y2) {x1=_x1; y1=_y1; x2=_x2; y2=_y2; bClean=false; }
|
||||
hgeRect() {bClean=true;}
|
||||
|
||||
void Clear() {bClean=true;}
|
||||
bool IsClean() const {return bClean;}
|
||||
void Set(float _x1, float _y1, float _x2, float _y2) { x1=_x1; x2=_x2; y1=_y1; y2=_y2; bClean=false; }
|
||||
void SetRadius(float x, float y, float r) { x1=x-r; x2=x+r; y1=y-r; y2=y+r; bClean=false; }
|
||||
void Encapsulate(float x, float y);
|
||||
bool TestPoint(float x, float y) const;
|
||||
bool Intersect(const hgeRect *rect) const;
|
||||
|
||||
private:
|
||||
bool bClean;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeRect helper class
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGERECT_H
|
||||
#define HGERECT_H
|
||||
|
||||
|
||||
class hgeRect
|
||||
{
|
||||
public:
|
||||
float x1, y1, x2, y2;
|
||||
|
||||
hgeRect(float _x1, float _y1, float _x2, float _y2) {x1=_x1; y1=_y1; x2=_x2; y2=_y2; bClean=false; }
|
||||
hgeRect() {bClean=true;}
|
||||
|
||||
void Clear() {bClean=true;}
|
||||
bool IsClean() const {return bClean;}
|
||||
void Set(float _x1, float _y1, float _x2, float _y2) { x1=_x1; x2=_x2; y1=_y1; y2=_y2; bClean=false; }
|
||||
void SetRadius(float x, float y, float r) { x1=x-r; x2=x+r; y1=y-r; y2=y+r; bClean=false; }
|
||||
void Encapsulate(float x, float y);
|
||||
bool TestPoint(float x, float y) const;
|
||||
bool Intersect(const hgeRect *rect) const;
|
||||
|
||||
private:
|
||||
bool bClean;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeVector helper class
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEVECTOR_H
|
||||
#define HGEVECTOR_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*
|
||||
** Fast 1.0/sqrtf(float) routine
|
||||
*/
|
||||
float InvSqrt(float x);
|
||||
|
||||
class hgeVector
|
||||
{
|
||||
public:
|
||||
float x,y;
|
||||
|
||||
hgeVector(float _x, float _y) { x=_x; y=_y; }
|
||||
hgeVector() { x=0; y=0; }
|
||||
|
||||
hgeVector operator- () const { return hgeVector(-x, -y); }
|
||||
hgeVector operator- (const hgeVector &v) const { return hgeVector(x-v.x, y-v.y); }
|
||||
hgeVector operator+ (const hgeVector &v) const { return hgeVector(x+v.x, y+v.y); }
|
||||
hgeVector& operator-= (const hgeVector &v) { x-=v.x; y-=v.y; return *this; }
|
||||
hgeVector& operator+= (const hgeVector &v) { x+=v.x; y+=v.y; return *this; }
|
||||
bool operator== (const hgeVector &v) const { return (x==v.x && y==v.y); }
|
||||
bool operator!= (const hgeVector &v) const { return (x!=v.x || y!=v.y); }
|
||||
|
||||
hgeVector operator/ (const float scalar) const { return hgeVector(x/scalar, y/scalar); }
|
||||
hgeVector operator* (const float scalar) const { return hgeVector(x*scalar, y*scalar); }
|
||||
hgeVector& operator*= (const float scalar) { x*=scalar; y*=scalar; return *this; }
|
||||
|
||||
float Dot(const hgeVector *v) const { return x*v->x + y*v->y; }
|
||||
float Length() const { return sqrtf(Dot(this)); }
|
||||
float Angle(const hgeVector *v = 0) const;
|
||||
|
||||
void Clamp(const float max) { if(Length() > max) { Normalize(); x *= max; y *= max; } }
|
||||
hgeVector* Normalize() { float rc=InvSqrt(Dot(this)); x*=rc; y*=rc; return this; }
|
||||
hgeVector* Rotate(float a);
|
||||
};
|
||||
|
||||
inline hgeVector operator* (const float s, const hgeVector &v) { return v*s; }
|
||||
inline float operator^ (const hgeVector &v, const hgeVector &u) { return v.Angle(&u); }
|
||||
inline float operator% (const hgeVector &v, const hgeVector &u) { return v.Dot(&u); }
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
** Haaf's Game Engine 1.7
|
||||
** Copyright (C) 2003-2007, Relish Games
|
||||
** hge.relishgames.com
|
||||
**
|
||||
** hgeVector helper class
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HGEVECTOR_H
|
||||
#define HGEVECTOR_H
|
||||
|
||||
|
||||
//#include "hge.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*
|
||||
** Fast 1.0/sqrtf(float) routine
|
||||
*/
|
||||
float InvSqrt(float x);
|
||||
|
||||
class hgeVector
|
||||
{
|
||||
public:
|
||||
float x,y;
|
||||
|
||||
hgeVector(float _x, float _y) { x=_x; y=_y; }
|
||||
hgeVector() { x=0; y=0; }
|
||||
|
||||
hgeVector operator- () const { return hgeVector(-x, -y); }
|
||||
hgeVector operator- (const hgeVector &v) const { return hgeVector(x-v.x, y-v.y); }
|
||||
hgeVector operator+ (const hgeVector &v) const { return hgeVector(x+v.x, y+v.y); }
|
||||
hgeVector& operator-= (const hgeVector &v) { x-=v.x; y-=v.y; return *this; }
|
||||
hgeVector& operator+= (const hgeVector &v) { x+=v.x; y+=v.y; return *this; }
|
||||
bool operator== (const hgeVector &v) const { return (x==v.x && y==v.y); }
|
||||
bool operator!= (const hgeVector &v) const { return (x!=v.x || y!=v.y); }
|
||||
|
||||
hgeVector operator/ (const float scalar) const { return hgeVector(x/scalar, y/scalar); }
|
||||
hgeVector operator* (const float scalar) const { return hgeVector(x*scalar, y*scalar); }
|
||||
hgeVector& operator*= (const float scalar) { x*=scalar; y*=scalar; return *this; }
|
||||
|
||||
float Dot(const hgeVector *v) const { return x*v->x + y*v->y; }
|
||||
float Length() const { return sqrtf(Dot(this)); }
|
||||
float Angle(const hgeVector *v = 0) const;
|
||||
|
||||
void Clamp(const float max) { if(Length() > max) { Normalize(); x *= max; y *= max; } }
|
||||
hgeVector* Normalize() { float rc=InvSqrt(Dot(this)); x*=rc; y*=rc; return this; }
|
||||
hgeVector* Rotate(float a);
|
||||
};
|
||||
|
||||
inline hgeVector operator* (const float s, const hgeVector &v) { return v*s; }
|
||||
inline float operator^ (const hgeVector &v, const hgeVector &u) { return v.Angle(&u); }
|
||||
inline float operator% (const hgeVector &v, const hgeVector &u) { return v.Dot(&u); }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,132 +1,132 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
||||
{
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||
const char *passwd; /* password string */
|
||||
unsigned char *buf; /* where to write header */
|
||||
int bufSize;
|
||||
unsigned long* pkeys;
|
||||
const unsigned long* pcrc_32_tab;
|
||||
unsigned long crcForCrypting;
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
if (bufSize<RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
||||
{
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||
const char *passwd; /* password string */
|
||||
unsigned char *buf; /* where to write header */
|
||||
int bufSize;
|
||||
unsigned long* pkeys;
|
||||
const unsigned long* pcrc_32_tab;
|
||||
unsigned long crcForCrypting;
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
if (bufSize<RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
|
||||
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
|
||||
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/* iowin32.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* iowin32.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
/*
|
||||
Additional tools for Minizip
|
||||
Code: Xavier Roche '2004
|
||||
License: Same as ZLIB (www.gzip.org)
|
||||
*/
|
||||
|
||||
#ifndef _zip_tools_H
|
||||
#define _zip_tools_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#include "unzip.h"
|
||||
|
||||
/* Repair a ZIP file (missing central directory)
|
||||
file: file to recover
|
||||
fileOut: output file after recovery
|
||||
fileOutTmp: temporary file name used for recovery
|
||||
*/
|
||||
extern int ZEXPORT unzRepair(const char* file,
|
||||
const char* fileOut,
|
||||
const char* fileOutTmp,
|
||||
uLong* nRecovered,
|
||||
uLong* bytesRecovered);
|
||||
|
||||
#endif
|
||||
/*
|
||||
Additional tools for Minizip
|
||||
Code: Xavier Roche '2004
|
||||
License: Same as ZLIB (www.gzip.org)
|
||||
*/
|
||||
|
||||
#ifndef _zip_tools_H
|
||||
#define _zip_tools_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#include "unzip.h"
|
||||
|
||||
/* Repair a ZIP file (missing central directory)
|
||||
file: file to recover
|
||||
fileOut: output file after recovery
|
||||
fileOutTmp: temporary file name used for recovery
|
||||
*/
|
||||
extern int ZEXPORT unzRepair(const char* file,
|
||||
const char* fileOut,
|
||||
const char* fileOutTmp,
|
||||
uLong* nRecovered,
|
||||
uLong* bytesRecovered);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,356 +1,356 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
|
||||
@@ -1,235 +1,235 @@
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||
typedef zipFile__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tm_zip tmz_date; /* date in understandable format */
|
||||
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
typedef const char* zipcharpc;
|
||||
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
an Unix computer "zlib/zlib113.zip".
|
||||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file.
|
||||
(useful if the file contain a self extractor code)
|
||||
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
|
||||
add files in existing zip (be sure you don't add file that doesn't exist)
|
||||
If the zipfile cannot be opened, the return value is NULL.
|
||||
Else, the return value is a zipFile Handle, usable with other function
|
||||
of this zip package.
|
||||
*/
|
||||
|
||||
/* Note : there is no delete function into a zipfile.
|
||||
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||
*/
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCtypting));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
/*
|
||||
Close the current file in the zipfile, for fiel opened with
|
||||
parameter raw=1 in zipOpenNewFileInZip2
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||
typedef zipFile__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tm_zip tmz_date; /* date in understandable format */
|
||||
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
typedef const char* zipcharpc;
|
||||
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
an Unix computer "zlib/zlib113.zip".
|
||||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file.
|
||||
(useful if the file contain a self extractor code)
|
||||
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
|
||||
add files in existing zip (be sure you don't add file that doesn't exist)
|
||||
If the zipfile cannot be opened, the return value is NULL.
|
||||
Else, the return value is a zipFile Handle, usable with other function
|
||||
of this zip package.
|
||||
*/
|
||||
|
||||
/* Note : there is no delete function into a zipfile.
|
||||
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||
*/
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCtypting));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
/*
|
||||
Close the current file in the zipfile, for fiel opened with
|
||||
parameter raw=1 in zipOpenNewFileInZip2
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
/*
|
||||
* Helper for use with the PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under GPL
|
||||
*
|
||||
* vram.c - Standard C high performance VRAM allocation routines.
|
||||
*
|
||||
* Copyright (c) 2007 Alexander Berl 'Raphael' <raphael@fx-world.org>
|
||||
* http://wordpress.fx-world.org
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef vram_h__
|
||||
#define vram_h__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* vrelptr( void *ptr ); // make a pointer relative to memory base address (ATTENTION: A NULL rel ptr is not illegal/invalid!)
|
||||
void* vabsptr( void *ptr ); // make a pointer absolute (default return type of valloc)
|
||||
|
||||
void* valloc( size_t size );
|
||||
void vfree( void* ptr );
|
||||
size_t vmemavail();
|
||||
size_t vlargestblock();
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Debug printf (to stdout) a trace of the current Memblocks
|
||||
void __memwalk();
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifdef vram_h__
|
||||
/*
|
||||
* Helper for use with the PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under GPL
|
||||
*
|
||||
* vram.c - Standard C high performance VRAM allocation routines.
|
||||
*
|
||||
* Copyright (c) 2007 Alexander Berl 'Raphael' <raphael@fx-world.org>
|
||||
* http://wordpress.fx-world.org
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef vram_h__
|
||||
#define vram_h__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* vrelptr( void *ptr ); // make a pointer relative to memory base address (ATTENTION: A NULL rel ptr is not illegal/invalid!)
|
||||
void* vabsptr( void *ptr ); // make a pointer absolute (default return type of valloc)
|
||||
|
||||
void* valloc( size_t size );
|
||||
void vfree( void* ptr );
|
||||
size_t vmemavail();
|
||||
size_t vlargestblock();
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Debug printf (to stdout) a trace of the current Memblocks
|
||||
void __memwalk();
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifdef vram_h__
|
||||
|
||||
Reference in New Issue
Block a user