1
General chat / Re: Happy Birthday Nino!
« on: December 22, 2007 »Happy Birthday Nino ,

Emil.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
shocky , there is no word that represent our thanks for your posting.
Yes there is, people here make me glad every time they release something into this community!
Because of this, it's always a pleasure to post source
hehe ... you are so kind , as usual.
shocky , there is no word that represent our thanks for your posting.

;**********************************************
;
;
; OgreMagic Library with PureBasic Test
;
; By Emil Halim
;
; 22/8/2007
;
;**********************************************
XIncludeFile #PB_Compiler_Home + "Includes\Imports\Dx9.pbi"
XIncludeFile #PB_Compiler_Home + "Includes\Imports\OgreMagic.pbi"
Global D3DDevice.IDirect3DDevice9
OpenWindow(1,0,0,640,480,"OgreMagic with PureBasic",#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget )
SetWindowPos_(WindowID(1),#HWND_TOPMOST,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE)
D3DDevice = D3D_OpenWindowedScreen(WindowID(1),640,480)
InitialMagicLibrary(D3DDevice,640,480)
If(ML_FileExist("MagicMedia.cfg"))
ML_SetMediaDirectoryFromFile("MagicMedia.cfg")
Else
ML_SetMediaDirectory("../OgreMagic/MagicMedia/")
EndIf
Tweety.l = ML_LoadStaticSprite("Tweety.bmp",0)
ML_SetSpriteColorKeyFromPoint(Tweety,0,0)
Repeat
D3DDevice\Clear(0,0,#D3DCLEAR_TARGET,0,0,0)
D3DDevice\BeginScene()
ML_UseOrthogonalView()
ML_SetAlpha(1.0,#AllPoints)
ML_SetColor(255,255,255,#AllPoints)
ML_SetBlendMode(#ALPHABLEND)
ML_SetSpriteTexture(ML_GetDefualtFont(),0)
ML_SetColor(255,255,0,#AllPoints)
ML_DrawString("Welcome To OgreMagic World",200,350)
ML_SetSpriteTexture(Tweety,0)
ML_DrawSprite(Tweety,320,240)
ML_DrawLogo(0.8,75,60)
ML_UsePerspectiveView()
D3DDevice\EndScene()
D3DDevice\Present(0,0,0,0)
EventID = WindowEvent()
Until EventID = #PB_Event_CloseWindow
D3D_Release(D3DDevice)
End


, it is really helpful , but i am still stuck.
struct Tcoord
{
float x,y;
};
struct BoundBox
{
float halfWidth;
float halfHeight;
Tcoord point1;
Tcoord point2;
Tcoord point3;
Tcoord point4;
};
void UpdateBoundBox(BoundBox* bBox,float Cx,float Cy,float THETA )
{
float cosw = cos(THETA);
float sinw = sin(THETA);
float x1 = Cx - bBox->halfWidth;
float x2 = Cx + bBox->halfWidth;
float x3 = Cx + bBox->halfWidth;
float x4 = Cx - bBox->halfWidth;
float y1 = Cy + bBox->halfHeight;
float y2 = Cy + bBox->halfHeight;
float y3 = Cy - bBox->halfHeight;
float y4 = Cy - bBox->halfHeight;
bBox->point1.x = x1 * cosw - y1 * sinw;
bBox->point1.y = x1 * cosw + y1 * sinw;
bBox->point2.x = x2 * cosw - y2 * sinw;
bBox->point2.y = x2 * cosw + y2 * sinw;
bBox->point3.x = x3 * cosw - y3 * sinw;
bBox->point3.y = x3 * cosw + y3 * sinw;
bBox->point4.x = x4 * cosw - y4 * sinw;
bBox->point4.y = x4 * cosw + y4 * sinw;
}
, big thanks must go to Relsoft and P01.
/**********************************************************
2 D p a t h s t u f f
***********************************************************/
struct Tcoord
{
float x,y;
};
struct Path2D
{
float m_x;
float m_y;
float m_t;
float m_speed;
int m_index;
int m_maxindex;
Tcoord* p_coords;
float m_old_x;
float m_old_y;
double m_angle;
double m_RotOffset;
};
DLL_EXPORT Path2D* ML_Create2DPath(int MaxPoints,float Speed,float RotOffset)
{
Path2D* path = new Path2D;
path->m_maxindex = MaxPoints;
path->p_coords = new Tcoord[MaxPoints];
path->m_speed = Speed;
path->m_x = path->m_y = path->m_t =
path->m_index = path->m_old_x = path->m_old_y =
path->m_angle = 0;
path->m_RotOffset = RotOffset;
return path;
}
DLL_EXPORT void ML_AddpointTo2DPath(Path2D* path,float x,float y)
{
if(path->m_maxindex>path->m_index && path->m_index>=0)
{
path->p_coords[path->m_index].x = x;
path->p_coords[path->m_index].y = y;
path->m_index++;
}
}
DLL_EXPORT void ML_AddpointTo2DPathByIndex(Path2D* path,int index,float x,float y)
{
if(path->m_maxindex>index && path->m_index>=0)
{
path->p_coords[index].x = x;
path->p_coords[index].y = y;
}
}
DLL_EXPORT void ML_SetPathSpeed(Path2D* path,float speed)
{
path->m_speed = speed;
}
// big thanks to Relsoft for catmull
DLL_EXPORT void ML_Update2DPath(Path2D* path)
{
float t1 = path->m_t;
float t2 = t1 * t1;
float t3 = t2 * t1;
Tcoord p0, p1, p2, p3;
p0.x = path->p_coords[path->m_index].x;
p0.y = path->p_coords[path->m_index].y;
p1.x = path->p_coords[(path->m_index + 1) % path->m_maxindex].x;
p1.y = path->p_coords[(path->m_index + 1) % path->m_maxindex].y;
p2.x = path->p_coords[(path->m_index + 2) % path->m_maxindex].x;
p2.y = path->p_coords[(path->m_index + 2) % path->m_maxindex].y;
p3.x = path->p_coords[(path->m_index + 3) % path->m_maxindex].x;
p3.y = path->p_coords[(path->m_index + 3) % path->m_maxindex].y;
path->m_x = 0.5 * ( ( 2.0 * p1.x ) + ( -p0.x + p2.x ) * t1 +
( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 +
( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 );
path->m_y = 0.5 * ( ( 2.0 * p1.y ) + ( -p0.y + p2.y ) * t1 +
( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 +
( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 );
path->m_t += path->m_speed;
if(path->m_t > 1.0)
{
path->m_t -= 1.0;
path->m_index = (path->m_index + 1) % path->m_maxindex;
}
path->m_angle = atan2(path->m_x - path->m_old_x , path->m_y - path->m_old_y)- path->m_RotOffset;
path->m_old_x = path->m_x;
path->m_old_y = path->m_y;
}
All it takes is a little magic dust and it can look quite different...
Exe attached
, but is not that chessfield scrolling that same as that one in IROSP4.bas except that it is vertically here ?